Mantid
Loading...
Searching...
No Matches
ICat4Catalog.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2013 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 +
7#pragma once
8
11#include "MantidAPI/TableRow.h"
14
15namespace Mantid {
16namespace ICat {
24public:
28 API::CatalogSession_sptr login(const std::string &username, const std::string &password, const std::string &endpoint,
29 const std::string &facility) override;
31 void logout() override;
33 void search(const CatalogSearchParam &inputs, Mantid::API::ITableWorkspace_sptr &outputws, const int &offset,
34 const int &limit) override;
36 int64_t getNumberOfSearchResults(const CatalogSearchParam &inputs) override;
38 void myData(Mantid::API::ITableWorkspace_sptr &outputws) override;
40 void getDataSets(const std::string &investigationId, Mantid::API::ITableWorkspace_sptr &outputws) override;
42 void getDataFiles(const std::string &investigationId, Mantid::API::ITableWorkspace_sptr &outputws) override;
44 void listInstruments(std::vector<std::string> &instruments) override;
46 void listInvestigationTypes(std::vector<std::string> &invstTypes) override;
48 const std::string getFileLocation(const long long &fileID) override;
50 const std::string getDownloadURL(const long long &fileID) override;
52 const std::string getUploadURL(const std::string &investigationID, const std::string &createFileName,
53 const std::string &dataFileDescription) override;
58 void keepAlive() override;
59
60private:
61 // Ensures human friendly error messages are provided to the user.
63 // Defines the SSL authentication scheme.
65 // Saves "MyData" query result to output workspace.
66 void saveInvestigations(std::vector<ICat4::xsd__anyType *> response, API::ITableWorkspace_sptr &outputws);
67 // Creates a search query string based on inputs provided by the user.
68 std::string buildSearchQuery(const CatalogSearchParam &inputs);
69 // Saves "DataFiles" result to output workspace.
70 void saveDataFiles(std::vector<ICat4::xsd__anyType *> response, API::ITableWorkspace_sptr &outputws);
71 // Saves "DataSets" information to the output workspace.
72 void saveDataSets(const std::vector<ICat4::xsd__anyType *> &response, API::ITableWorkspace_sptr &outputws);
73 // Convert a file size to human readable file format.
74 std::string bytesToString(int64_t &fileSize);
75 // Helper method that formats a given timestamp.
76 std::string formatDateTime(const time_t &timestamp, const std::string &format);
77 // Search the archive & obtain the dataset ID based on the investigationID.
78 int64_t getMantidDatasetId(const std::string &investigationID);
79 // Creates a dataset for an investigation (based on ID) named 'mantid' if it
80 // does not already exist.
81 int64_t createMantidDataset(const std::string &investigationID);
82 // Sets the soap-endpoint & SSL context for the given ICAT proxy.
84 // Returns the results of a search against ICAT for a given query.
85 std::vector<ICat4::xsd__anyType *> performSearch(ICat4::ICATPortBindingProxy &icat, std::string query);
86
87 // Is the desired accessType allowed for a specific bean?
88 template <class T> bool isAccessAllowed(ICat4::ns1__accessType accessType, T &bean);
89
90 // Stores the session details for a specific catalog.
92
98 template <class T> void savetoTableWorkspace(T *input, Mantid::API::TableRow &table) {
99 if (input) {
100 table << *input;
101 } else {
102 table << "";
103 }
104 }
105};
106} // namespace ICat
107} // namespace Mantid
This class is responsible for interfacing with the Information Data Service (IDS) to upload and downl...
This class creates an interface for information catalogs to support multiple facilities.
Definition: ICatalog.h:28
TableRow represents a row in a TableWorkspace.
Definition: TableRow.h:39
This class is used in Catalog Search service to set/get all the inputs to search for.
This class is responsible for the implementation of ICat4 version based information catalogs.
Definition: ICat4Catalog.h:23
const std::string getFileLocation(const long long &fileID) override
Get the file location string(s) from archive.
std::string buildSearchQuery(const CatalogSearchParam &inputs)
Creates a search query string based on inputs provided by the user.
void listInvestigationTypes(std::vector< std::string > &invstTypes) override
Get investigationtypes list.
std::vector< ICat4::xsd__anyType * > performSearch(ICat4::ICATPortBindingProxy &icat, std::string query)
Returns the results of a search against ICAT for a given query.
int64_t getNumberOfSearchResults(const CatalogSearchParam &inputs) override
Obtain the number of results returned by the search method.
void saveInvestigations(std::vector< ICat4::xsd__anyType * > response, API::ITableWorkspace_sptr &outputws)
Saves investigations to a table workspace.
void setSSLContext(ICat4::ICATPortBindingProxy &icat)
Defines the SSL authentication scheme.
bool isAccessAllowed(ICat4::ns1__accessType accessType, T &bean)
Is the specified access type allowed for a specific bean?
void keepAlive() override
Keep current session alive.
void getDataFiles(const std::string &investigationId, Mantid::API::ITableWorkspace_sptr &outputws) override
Get datafiles.
void logout() override
Log the user out of the catalog system.
void savetoTableWorkspace(T *input, Mantid::API::TableRow &table)
Template method to save data to table workspace.
Definition: ICat4Catalog.h:98
void saveDataFiles(std::vector< ICat4::xsd__anyType * > response, API::ITableWorkspace_sptr &outputws)
Saves result from "getDataFiles" to workspace.
void saveDataSets(const std::vector< ICat4::xsd__anyType * > &response, API::ITableWorkspace_sptr &outputws)
Loops through the response vector and saves the datasets details to a table workspace.
std::string bytesToString(int64_t &fileSize)
Convert a file size to human readable file format.
API::CatalogSession_sptr m_session
Definition: ICat4Catalog.h:91
void myData(Mantid::API::ITableWorkspace_sptr &outputws) override
Show the logged in user's investigations search results.
int64_t createMantidDataset(const std::string &investigationID)
Creates a dataset for an investigation (based on ID) named 'mantid' if it does not already exist.
std::string formatDateTime(const time_t &timestamp, const std::string &format)
Formats a given timestamp to human readable datetime.
void listInstruments(std::vector< std::string > &instruments) override
Get instruments list.
void setICATProxySettings(ICat4::ICATPortBindingProxy &icat)
Sets the soap-endpoint & SSL context for the given ICAT proxy.
void search(const CatalogSearchParam &inputs, Mantid::API::ITableWorkspace_sptr &outputws, const int &offset, const int &limit) override
Search the catalog for data.
const std::string getDownloadURL(const long long &fileID) override
Get the url(s) based on the fileID.
void getDataSets(const std::string &investigationId, Mantid::API::ITableWorkspace_sptr &outputws) override
Get datasets.
API::ITableWorkspace_sptr getPublishInvestigations() override
Obtains the investigations that the user can publish to and saves related information to a workspace.
API::CatalogSession_sptr login(const std::string &username, const std::string &password, const std::string &endpoint, const std::string &facility) override
Log the user into the catalog system.
const std::string getUploadURL(const std::string &investigationID, const std::string &createFileName, const std::string &dataFileDescription) override
get URL of where to PUT (publish) files.
void throwErrorMessage(ICat4::ICATPortBindingProxy &icat)
Throws an error message (returned by gsoap) to Mantid upper layer.
int64_t getMantidDatasetId(const std::string &investigationID)
Search the archive & obtain the "mantid" dataset ID for a specific investigation if it exists.
ns1__accessType
Definition: ICat4Stub.h:75
std::shared_ptr< CatalogSession > CatalogSession_sptr
std::shared_ptr< ITableWorkspace > ITableWorkspace_sptr
shared pointer to Mantid::API::ITableWorkspace
Helper class which provides the Collimation Length for SANS instruments.