33 std::transform(s.begin(), s.end(), result.begin(), toupper);
96 const
std::vector<
std::
string> &suffixes)
const {
97 if (basenames.size() == 0) {
102 const auto basename = *basenames.cbegin();
105 boost::smatch result;
106 if (!boost::regex_match(basename, result, FILE_REGEX)) {
107 g_log.
debug() <<
"Unexpected input passed to getArchivePath():" << std::endl << basename << std::endl;
112 assert(result.size() == 3);
113 const std::string instrument = toUpperCase(result[1]);
114 const std::string run = result[2];
116 const auto &config = Mantid::Kernel::ConfigService::Instance();
117 std::string facility;
119 facility = config.getInstrument(instrument).facility().name();
121 if (facility !=
"HFIR" && facility !=
"SNS") {
125 g_log.
debug() <<
"\"" << instrument <<
"\" is not an instrument known to Mantid." << std::endl;
133 const QueryParameters params{{
"facility", facility},
134 {
"instrument", instrument},
135 {
"projection",
"location"},
136 {
"tags",
"type/raw"},
137 {
"sort_by",
"ingested"},
138 {
"sort_direction",
"DESCENDING"},
139 {
"ranges_q",
"indexed.run_number:" + run}};
147 auto defaultOncat = ONCat::fromMantidSettings();
148 auto *oncat = m_oncat ? m_oncat.get() : defaultOncat.get();
150 const auto datafiles = [&]() {
152 return oncat->list(
"api",
"datafiles", params);
153 }
catch (CatalogError &ce) {
154 g_log.
debug() <<
"Error while calling ONCat:" << std::endl << ce.what() << std::endl;
155 return std::vector<ONCatEntity>();
159 if (datafiles.size() == 0) {
160 g_log.
debug() <<
"ONCat does not know the location of run \"" << run <<
"\" for \"" << instrument <<
"\"."
165 g_log.
debug() <<
"All datafiles returned from ONCat:" << std::endl;
166 for (
const auto &datafile : datafiles) {
167 g_log.
debug() << datafile.toString() << std::endl;
177 const auto location = *datafiles.cbegin()->get<std::string>(
"location");
181 for (
const auto &suffix : suffixes) {
182 const std::string fullSuffix = basename + suffix;
183 if (toUpperCase(location).ends_with(toUpperCase(fullSuffix))) {
188 if (toUpperCase(location).ends_with(toUpperCase(basename))) {