33 std::transform(s.begin(), s.end(), result.begin(), toupper);
97 const std::vector<std::string> &suffixes)
const {
98 if (basenames.size() == 0) {
103 const auto basename = *basenames.cbegin();
106 boost::smatch result;
107 if (!boost::regex_match(basename, result, FILE_REGEX)) {
108 g_log.
debug() <<
"Unexpected input passed to getArchivePath():" << std::endl << basename << std::endl;
113 assert(result.size() == 3);
114 const std::string instrument = toUpperCase(result[1]);
115 const std::string run = result[2];
117 const auto &config = Mantid::Kernel::ConfigService::Instance();
118 std::string facility;
120 facility = config.getInstrument(instrument).facility().name();
122 if (facility !=
"HFIR" && facility !=
"SNS") {
126 g_log.
debug() <<
"\"" << instrument <<
"\" is not an instrument known to Mantid." << std::endl;
134 const QueryParameters params{{
"facility", facility},
135 {
"instrument", instrument},
136 {
"projection",
"location"},
137 {
"tags",
"type/raw"},
138 {
"sort_by",
"ingested"},
139 {
"sort_direction",
"DESCENDING"},
140 {
"ranges_q",
"indexed.run_number:" + run}};
148 auto defaultOncat = ONCat::fromMantidSettings();
151 const auto datafiles = [&]() {
153 return oncat->list(
"api",
"datafiles", params);
154 }
catch (CatalogError &ce) {
155 g_log.
debug() <<
"Error while calling ONCat:" << std::endl << ce.what() << std::endl;
156 return std::vector<ONCatEntity>();
160 if (datafiles.size() == 0) {
161 g_log.
debug() <<
"ONCat does not know the location of run \"" << run <<
"\" for \"" << instrument <<
"\"."
166 g_log.
debug() <<
"All datafiles returned from ONCat:" << std::endl;
167 for (
const auto &datafile : datafiles) {
168 g_log.
debug() << datafile.toString() << std::endl;
178 const auto location = *datafiles.cbegin()->get<std::string>(
"location");
182 for (
const auto &suffix : suffixes) {
183 const std::string fullSuffix = basename + suffix;
184 if (toUpperCase(location).ends_with(toUpperCase(fullSuffix))) {
189 if (toUpperCase(location).ends_with(toUpperCase(basename))) {