Mantid
Loading...
Searching...
No Matches
CatalogSearchParam.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
9#include <boost/algorithm/string/regex.hpp>
10
11namespace Mantid::ICat {
13CatalogSearchParam::CatalogSearchParam() : m_startRun(0), m_endRun(0), m_startDate(0), m_endDate(0), m_myData(false) {}
14
19void CatalogSearchParam::setRunStart(const double &startRun) { m_startRun = startRun; }
20
25void CatalogSearchParam::setRunEnd(const double &endRun) { m_endRun = endRun; }
26
31void CatalogSearchParam::setInstrument(const std::string &instrName) { m_instrName = instrName; }
32
37void CatalogSearchParam::setStartDate(const time_t &startDate) { m_startDate = startDate; }
38
43void CatalogSearchParam::setEndDate(const time_t &endDate) { m_endDate = endDate; }
44
49void CatalogSearchParam::setKeywords(const std::string &keywords) { m_keywords = keywords; }
50
55void CatalogSearchParam::setInvestigationName(const std::string &instName) { m_investigationName = instName; }
56
61void CatalogSearchParam::setDatafileName(const std::string &datafileName) { m_datafileName = datafileName; }
62
67void CatalogSearchParam::setSampleName(const std::string &sampleName) { m_sampleName = sampleName; }
68
73void CatalogSearchParam::setInvestigatorSurName(const std::string &investigatorName) {
74 m_investigatorSurname = investigatorName;
75}
76
81void CatalogSearchParam::setInvestigationType(const std::string &invstType) { m_investigationType = invstType; }
82
87void CatalogSearchParam::setMyData(bool flag) { m_myData = flag; }
88
93void CatalogSearchParam::setInvestigationId(const std::string &investigationId) { m_investigationId = investigationId; }
94
99const double &CatalogSearchParam::getRunStart() const { return m_startRun; }
100
105const double &CatalogSearchParam::getRunEnd() const { return m_endRun; }
106
111const std::string &CatalogSearchParam::getInstrument() const { return m_instrName; }
112
117const time_t &CatalogSearchParam::getStartDate() const { return m_startDate; }
118
123const time_t &CatalogSearchParam::getEndDate() const { return m_endDate; }
124
129const std::string &CatalogSearchParam::getKeywords() const { return m_keywords; }
130
136
141const std::string &CatalogSearchParam::getDatafileName() const { return m_datafileName; }
142
147const std::string &CatalogSearchParam::getSampleName() const { return m_sampleName; }
148
154
160
166
171const std::string &CatalogSearchParam::getInvestigationId() const { return m_investigationId; }
172
178time_t CatalogSearchParam::getTimevalue(const std::string &inputDate) {
179 // Prevent any possible errors.
180 if (inputDate.empty())
181 return 0;
182 // A container to hold the segments of the date.
183 std::vector<std::string> dateSegments;
184 // Split input by "/" prior to rearranging the date
185 boost::algorithm::split_regex(dateSegments, inputDate, boost::regex("/"));
186 // Reorganise the date to be ISO format.
187 std::string isoDate = dateSegments.at(2) + "-" + dateSegments.at(1) + "-" + dateSegments.at(0) + " 00:00:00.000";
188 // Return the date as time_t value.
189 return Types::Core::DateAndTime(isoDate).to_time_t();
190}
191} // namespace Mantid::ICat
const std::string & getInvestigationName() const
Get the name of the investigation to search for.
void setKeywords(const std::string &keywords)
Set the keywords to search for.
void setSampleName(const std::string &sampleName)
Set the sample name to search for.
void setInvestigationId(const std::string &)
Set the investigation id to search for.
std::string m_investigationName
investigation anme
const double & getRunStart() const
Get the start run from user input.
std::string m_instrName
instrument name
const std::string & getSampleName() const
Get the sample name.
const std::string & getInvestigatorSurName() const
Get the investigators name.
time_t getTimevalue(const std::string &inputDate)
Saves the start/end date times to time_t value.
const std::string & getInvestigationId() const
Get the investigation id.
const time_t & getStartDate() const
Get the investigation start date.
void setRunEnd(const double &endRun)
Set the end run to search for.
const time_t & getEndDate() const
Get the investigation end date.
std::string m_keywords
search keywords
const std::string & getDatafileName() const
Get the datafile name.
const std::string & getInstrument() const
Get the instrument name.
void setDatafileName(const std::string &datafileName)
Set the datafile name to search for.
void setInvestigatorSurName(const std::string &investigatorName)
Set the investigators name to search for.
const std::string & getKeywords() const
Get the keywords to search investigations for.
const std::string & getInvestigationType() const
Get the investigation type.
void setInvestigationName(const std::string &instName)
Set the investigation name to search for.
void setInstrument(const std::string &instrName)
Set the instrument to search for.
std::string m_datafileName
Datafile name.
double m_startRun
start run number
void setRunStart(const double &startRun)
Set the start run to search for.
std::string m_sampleName
sample name
const double & getRunEnd() const
Get the end run.
std::string m_investigationType
investigation type
std::string m_investigatorSurname
investigator surname
bool getMyData() const
Get the "my data only" flag.
std::string m_investigationId
investigation id
void setStartDate(const time_t &startDate)
Set the start date to search for.
void setEndDate(const time_t &endDate)
Set the end date to search for.
void setInvestigationType(const std::string &invstType)
Set the investigation type to search for.
void setMyData(bool flag)
Set the "my data only" flag to search only user's data if true.