diff --git a/Framework/DataHandling/CMakeLists.txt b/Framework/DataHandling/CMakeLists.txt index 3482694e01f61bd9f5e999c17576ceb7151c330d..a98c182bb788f91fab377124470df242c084ed02 100644 --- a/Framework/DataHandling/CMakeLists.txt +++ b/Framework/DataHandling/CMakeLists.txt @@ -141,7 +141,6 @@ src/RenameLog.cpp src/RotateInstrumentComponent.cpp src/RotateSource.cpp - src/SNSDataArchive.cpp src/SaveANSTOAscii.cpp src/SaveAscii.cpp src/SaveAscii2.cpp @@ -335,7 +334,6 @@ set ( INC_FILES inc/MantidDataHandling/RenameLog.h inc/MantidDataHandling/RotateInstrumentComponent.h inc/MantidDataHandling/RotateSource.h - inc/MantidDataHandling/SNSDataArchive.h inc/MantidDataHandling/SaveANSTOAscii.h inc/MantidDataHandling/SaveAscii.h inc/MantidDataHandling/SaveAscii2.h @@ -518,7 +516,6 @@ set ( TEST_FILES RenameLogTest.h RotateInstrumentComponentTest.h RotateSourceTest.h - SNSDataArchiveTest.h SaveANSTOAsciiTest.h SaveAscii2Test.h SaveAsciiTest.h diff --git a/Framework/DataHandling/inc/MantidDataHandling/SNSDataArchive.h b/Framework/DataHandling/inc/MantidDataHandling/SNSDataArchive.h deleted file mode 100644 index d31f5a113f1e2058b035b5c9ed659863e8ba12cf..0000000000000000000000000000000000000000 --- a/Framework/DataHandling/inc/MantidDataHandling/SNSDataArchive.h +++ /dev/null @@ -1,35 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2010 ISIS Rutherford Appleton Laboratory UKRI, -// NScD Oak Ridge National Laboratory, European Spallation Source -// & Institut Laue - Langevin -// SPDX - License - Identifier: GPL - 3.0 + -#ifndef MANTID_DATAHANDLING_SNSDATAARCHIVE_H_ -#define MANTID_DATAHANDLING_SNSDATAARCHIVE_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/IArchiveSearch.h" -#include "MantidKernel/System.h" - -#include <string> - -namespace Mantid { -namespace DataHandling { -/** - This class is for searching the SNS data archive - @date 02/22/2012 - */ - -class DLLExport SNSDataArchive : public API::IArchiveSearch { -public: - /// Find the archive location of a set of files. - std::string - getArchivePath(const std::set<std::string> &filenames, - const std::vector<std::string> &exts) const override; -}; -} // namespace DataHandling -} // namespace Mantid - -#endif /* MANTID_DATAHANDLING_SNSDATAARCHIVE_H_ */ diff --git a/Framework/DataHandling/src/ORNLDataArchive.cpp b/Framework/DataHandling/src/ORNLDataArchive.cpp index c3ec9081bb3543a801f757d18aa4862aaccaca5f..8eadaf1ceb8c66824fe8cc32caae83c2f9a787cb 100644 --- a/Framework/DataHandling/src/ORNLDataArchive.cpp +++ b/Framework/DataHandling/src/ORNLDataArchive.cpp @@ -48,6 +48,7 @@ namespace Mantid { namespace DataHandling { DECLARE_ARCHIVESEARCH(ORNLDataArchive, ORNLDataSearch) +DECLARE_ARCHIVESEARCH(ORNLDataArchive, SNSDataSearch) /** * **************** diff --git a/Framework/DataHandling/src/SNSDataArchive.cpp b/Framework/DataHandling/src/SNSDataArchive.cpp deleted file mode 100644 index af276e1d0bed47629c23c5f54701eb371428fb7f..0000000000000000000000000000000000000000 --- a/Framework/DataHandling/src/SNSDataArchive.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, -// NScD Oak Ridge National Laboratory, European Spallation Source -// & Institut Laue - Langevin -// SPDX - License - Identifier: GPL - 3.0 + -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include <sstream> - -#include "MantidAPI/ArchiveSearchFactory.h" -#include "MantidDataHandling/SNSDataArchive.h" -#include "MantidKernel/Exception.h" -#include "MantidKernel/InternetHelper.h" -#include "MantidKernel/Logger.h" - -#include <boost/algorithm/string.hpp> -#include <boost/algorithm/string/predicate.hpp> - -#include <Poco/AutoPtr.h> -#include <Poco/DOM/DOMParser.h> -#include <Poco/DOM/Document.h> -#include <Poco/DOM/Element.h> -#include <Poco/DOM/NodeList.h> -#include <Poco/SAX/InputSource.h> - -namespace Mantid { -namespace DataHandling { -namespace { -// Get a reference to the logger -Kernel::Logger g_log("SNSDataArchive"); -/// Base url for restful web survice -const std::string - BASE_URL("http://icat.sns.gov:2080/icat-rest-ws/datafile/filename/"); -} // namespace - -DECLARE_ARCHIVESEARCH(SNSDataArchive, SNSDataSearch) - -/** - * @param filenames : List of files to search - * @param exts : List of extensions to check against - * @return list of archive locations - */ -std::string -SNSDataArchive::getArchivePath(const std::set<std::string> &filenames, - const std::vector<std::string> &exts) const { - g_log.debug() << "getArchivePath([ "; - for (const auto &iter : filenames) - g_log.debug() << iter << " "; - g_log.information() << "], [ "; - for (const auto &iter : exts) - g_log.debug() << iter << " "; - g_log.debug() << "])\n"; - - auto iter = filenames.cbegin(); - std::string filename = *iter; - - // ICAT4 web service take upper case filename such as HYSA_2662 - std::transform(filename.begin(), filename.end(), filename.begin(), toupper); - - for (const auto &ext : exts) { - g_log.debug() << ext << ";"; - } - g_log.debug() << "\n"; - - const std::string URL(BASE_URL + filename); - g_log.debug() << "URL: " << URL << "\n"; - - Kernel::InternetHelper inetHelper; - std::ostringstream rs; - - int status = inetHelper.sendRequest(URL, rs); - - // Create a DOM document from the response. - Poco::XML::DOMParser parser; - std::istringstream istrsource(rs.str()); - Poco::XML::InputSource source(istrsource); - Poco::AutoPtr<Poco::XML::Document> pDoc = parser.parse(&source); - - std::vector<std::string> locations; - - // Everything went fine, return the XML document. - // Otherwise look for an error message in the XML document. - if (status == Kernel::InternetHelper::HTTP_OK) { - std::string location; - Poco::AutoPtr<Poco::XML::NodeList> pList = - pDoc->getElementsByTagName("location"); - for (unsigned long i = 0; i < pList->length(); i++) { - location = pList->item(i)->innerText(); - g_log.debug() << "location: " << location << "\n"; - locations.push_back(location); - } - } - - for (const auto &ext : exts) { - std::string datafile = filename + ext; - std::vector<std::string>::const_iterator iter = locations.begin(); - for (; iter != locations.end(); ++iter) { - if (boost::algorithm::ends_with((*iter), datafile)) { - return *iter; - } // end if - } // end for iter - - } // end for ext - return ""; -} - -} // namespace DataHandling -} // namespace Mantid diff --git a/Framework/DataHandling/test/SNSDataArchiveTest.h b/Framework/DataHandling/test/SNSDataArchiveTest.h deleted file mode 100644 index 3d8d7d588b44351e168cbd82760b51852ebcf6e4..0000000000000000000000000000000000000000 --- a/Framework/DataHandling/test/SNSDataArchiveTest.h +++ /dev/null @@ -1,61 +0,0 @@ -// Mantid Repository : https://github.com/mantidproject/mantid -// -// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, -// NScD Oak Ridge National Laboratory, European Spallation Source -// & Institut Laue - Langevin -// SPDX - License - Identifier: GPL - 3.0 + -#ifndef SNSDATAARCHIVETEST_H_ -#define SNSDATAARCHIVETEST_H_ - -#include <cxxtest/TestSuite.h> - -#include "MantidAPI/ArchiveSearchFactory.h" -#include "MantidDataHandling/SNSDataArchive.h" - -using namespace Mantid::DataHandling; -using namespace Mantid::API; - -class SNSDataArchiveTest : public CxxTest::TestSuite { -public: - void xtestSearch() { - SNSDataArchive arch; - - // PG3 Test case - std::set<std::string> filename; - filename.insert("PG3_7390"); - std::vector<std::string> extension = - std::vector<std::string>(1, "_event.nxs"); - std::string path = arch.getArchivePath(filename, extension); - TS_ASSERT_EQUALS(path, - "/SNS/PG3/IPTS-2767/0/7390/NeXus/PG3_7390_histo.nxs"); - - // BSS Test case - filename.clear(); - filename.insert("BSS_18339"); - path = arch.getArchivePath(filename, extension); - TS_ASSERT_EQUALS(path, - "/SNS/BSS/IPTS-6817/0/18339/NeXus/BSS_18339_event.nxs"); - - // HYSA Test case - filename.clear(); - filename.insert("HYSA_2411"); - extension = std::vector<std::string>(1, ".nxs.h5"); - path = arch.getArchivePath(filename, extension); - TS_ASSERT_EQUALS(path, "/SNS/HYSA/IPTS-8004/nexus/HYSA_2411.nxs.h5"); - - // Test a non-existent file - filename.clear(); - filename.insert("mybeamline_666"); - extension = std::vector<std::string>(1, ".nxs"); - path = arch.getArchivePath(filename, extension); - TS_ASSERT(path.empty()); - } - - void testFactory() { - boost::shared_ptr<IArchiveSearch> arch = - ArchiveSearchFactory::Instance().create("SNSDataSearch"); - TS_ASSERT(arch); - } -}; - -#endif /*SNSDATAARCHIVETEST_H_*/ diff --git a/docs/source/release/v3.14.0/framework.rst b/docs/source/release/v3.14.0/framework.rst index cc3a7c20a7e4f56fa389fd545e4f30ad84ee84ca..f65c53c5eec7e82ffb5376d95687819b943deb0b 100644 --- a/docs/source/release/v3.14.0/framework.rst +++ b/docs/source/release/v3.14.0/framework.rst @@ -38,7 +38,7 @@ Archive Searching SNS / ONCat ########### -- SNS file searching has been moved to `ONCAT <https://oncat.ornl.gov/>`_ +- SNS file searching has been moved to `ONCAT <https://oncat.ornl.gov/>`_. Due to auto-updating of the ``Facilities.xml``, this was done by directing ``SNSDataSearch`` and ``ORNLDataSearch`` to both use ONCAT. - For HFIR instruments that write out raw files with run numbers, we have enabled functionality that allows for the searching of file locations by making calls to ONCat. To use this, make sure that the "Search Data Archive" option is checked in your "Manage User Directories" settings. The ``FileFinder`` and algorithms such as :ref:`Load <algm-Load>` will then accept inputs such as "``HB2C_143210``". ISIS / ICat