Mantid
|
This class is responsible for the implementation of ICat4 version based information catalogs. More...
#include <ICat4Catalog.h>
Public Member Functions | |
void | getDataFiles (const std::string &investigationId, Mantid::API::ITableWorkspace_sptr &outputws) override |
Get datafiles. More... | |
void | getDataSets (const std::string &investigationId, Mantid::API::ITableWorkspace_sptr &outputws) override |
Get datasets. More... | |
const std::string | getDownloadURL (const long long &fileID) override |
Get the url(s) based on the fileID. More... | |
const std::string | getFileLocation (const long long &fileID) override |
Get the file location string(s) from archive. More... | |
int64_t | getNumberOfSearchResults (const CatalogSearchParam &inputs) override |
Obtain the number of results returned by the search method. More... | |
API::ITableWorkspace_sptr | getPublishInvestigations () override |
Obtains the investigations that the user can publish to and saves related information to a workspace. More... | |
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. More... | |
ICat4Catalog () | |
Constructor. More... | |
void | keepAlive () override |
Keep current session alive. More... | |
void | listInstruments (std::vector< std::string > &instruments) override |
Get instruments list. More... | |
void | listInvestigationTypes (std::vector< std::string > &invstTypes) override |
Get investigationtypes list. More... | |
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. More... | |
void | logout () override |
Log the user out of the catalog system. More... | |
void | myData (Mantid::API::ITableWorkspace_sptr &outputws) override |
Show the logged in user's investigations search results. More... | |
void | search (const CatalogSearchParam &inputs, Mantid::API::ITableWorkspace_sptr &outputws, const int &offset, const int &limit) override |
Search the catalog for data. More... | |
Public Member Functions inherited from Mantid::API::ICatalog | |
virtual void | getDataFiles (const std::string &, ITableWorkspace_sptr &)=0 |
get datafiles More... | |
virtual void | getDataSets (const std::string &, ITableWorkspace_sptr &)=0 |
get datasets. More... | |
virtual int64_t | getNumberOfSearchResults (const ICat::CatalogSearchParam &)=0 |
Obtain the number of results returned by the search method. More... | |
virtual void | keepAlive ()=0 |
keep alive More... | |
virtual void | listInstruments (std::vector< std::string > &)=0 |
instrument list More... | |
virtual void | listInvestigationTypes (std::vector< std::string > &)=0 |
get investigationtype lists More... | |
virtual CatalogSession_sptr | login (const std::string &, const std::string &, const std::string &, const std::string &)=0 |
method to login to a catalog More... | |
virtual void | logout ()=0 |
logout from catalog More... | |
virtual void | myData (ITableWorkspace_sptr &)=0 |
search logged in users data More... | |
virtual void | search (const ICat::CatalogSearchParam &, ITableWorkspace_sptr &, const int &, const int &)=0 |
Search investigations. More... | |
virtual | ~ICatalog ()=default |
Virtual destructor. More... | |
Public Member Functions inherited from Mantid::API::ICatalogInfoService | |
virtual const std::string | getDownloadURL (const long long &)=0 |
Obtain url to download a file from. More... | |
virtual const std::string | getFileLocation (const long long &)=0 |
Obtain the datafile location string from the archives. More... | |
virtual ITableWorkspace_sptr | getPublishInvestigations ()=0 |
Obtains the investigations that the user can publish to and saves related information to a workspace. More... | |
virtual const std::string | getUploadURL (const std::string &, const std::string &, const std::string &)=0 |
Obtain the url to upload a file to. More... | |
virtual | ~ICatalogInfoService ()=default |
Private Member Functions | |
std::string | buildSearchQuery (const CatalogSearchParam &inputs) |
Creates a search query string based on inputs provided by the user. More... | |
std::string | bytesToString (int64_t &fileSize) |
Convert a file size to human readable file format. More... | |
int64_t | createMantidDataset (const std::string &investigationID) |
Creates a dataset for an investigation (based on ID) named 'mantid' if it does not already exist. More... | |
std::string | formatDateTime (const time_t ×tamp, const std::string &format) |
Formats a given timestamp to human readable datetime. More... | |
int64_t | getMantidDatasetId (const std::string &investigationID) |
Search the archive & obtain the "mantid" dataset ID for a specific investigation if it exists. More... | |
template<class T > | |
bool | isAccessAllowed (ICat4::ns1__accessType accessType, T &bean) |
Is the specified access type allowed for a specific bean? More... | |
std::vector< ICat4::xsd__anyType * > | performSearch (ICat4::ICATPortBindingProxy &icat, std::string query) |
Returns the results of a search against ICAT for a given query. More... | |
void | saveDataFiles (std::vector< ICat4::xsd__anyType * > response, API::ITableWorkspace_sptr &outputws) |
Saves result from "getDataFiles" to workspace. More... | |
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. More... | |
void | saveInvestigations (std::vector< ICat4::xsd__anyType * > response, API::ITableWorkspace_sptr &outputws) |
Saves investigations to a table workspace. More... | |
template<class T > | |
void | savetoTableWorkspace (T *input, Mantid::API::TableRow &table) |
Template method to save data to table workspace. More... | |
void | setICATProxySettings (ICat4::ICATPortBindingProxy &icat) |
Sets the soap-endpoint & SSL context for the given ICAT proxy. More... | |
void | setSSLContext (ICat4::ICATPortBindingProxy &icat) |
Defines the SSL authentication scheme. More... | |
void | throwErrorMessage (ICat4::ICATPortBindingProxy &icat) |
Throws an error message (returned by gsoap) to Mantid upper layer. More... | |
Private Attributes | |
API::CatalogSession_sptr | m_session |
This class is responsible for the implementation of ICat4 version based information catalogs.
Definition at line 23 of file ICat4Catalog.h.
Mantid::ICat::ICat4Catalog::ICat4Catalog | ( | ) |
Constructor.
Definition at line 30 of file ICat4Catalog.cpp.
|
private |
Creates a search query string based on inputs provided by the user.
inputs | :: reference to a class contains search inputs. |
Definition at line 126 of file ICat4Catalog.cpp.
References formatDateTime(), Mantid::ICat::CatalogSearchParam::getDatafileName(), Mantid::ICat::CatalogSearchParam::getEndDate(), Mantid::ICat::CatalogSearchParam::getInstrument(), Mantid::ICat::CatalogSearchParam::getInvestigationId(), Mantid::ICat::CatalogSearchParam::getInvestigationName(), Mantid::ICat::CatalogSearchParam::getInvestigationType(), Mantid::ICat::CatalogSearchParam::getInvestigatorSurName(), Mantid::ICat::CatalogSearchParam::getKeywords(), Mantid::ICat::CatalogSearchParam::getMyData(), Mantid::ICat::CatalogSearchParam::getRunEnd(), Mantid::ICat::CatalogSearchParam::getRunStart(), Mantid::ICat::CatalogSearchParam::getSampleName(), Mantid::ICat::CatalogSearchParam::getStartDate(), Mantid::Kernel::Strings::join(), and Mantid::Kernel::Strings::toString().
Referenced by getNumberOfSearchResults(), and search().
|
private |
Convert a file size to human readable file format.
fileSize | :: The size in bytes of the file. |
Definition at line 713 of file ICat4Catalog.cpp.
References std::to_string().
Referenced by saveDataFiles().
|
private |
Creates a dataset for an investigation (based on ID) named 'mantid' if it does not already exist.
investigationID | :: The investigation to create a dataset for. |
Definition at line 771 of file ICat4Catalog.cpp.
References ICat4::ns1__create::bean, ICat4::ns1__dataset::complete, ICat4::ICATPortBindingProxy::create(), Mantid::Kernel::Logger::debug(), Mantid::API::g_log, ICat4::ns1__dataset::investigation, isAccessAllowed(), m_session, ICat4::ns1__dataset::name, ICat4::ns1__accessType__CREATE, performSearch(), ICat4::ns1__createResponse::return_, ICat4::ns1__create::sessionId, setICATProxySettings(), and ICat4::ns1__dataset::type.
Referenced by getMantidDatasetId().
|
private |
Formats a given timestamp to human readable datetime.
timestamp | :: Unix timestamp. |
format | :: The desired format to output. |
Definition at line 733 of file ICat4Catalog.cpp.
Referenced by buildSearchQuery(), saveDataFiles(), and saveInvestigations().
|
overridevirtual |
Get datafiles.
Returns the datafiles associated to the given investigation id.
investigationId | :: unique identifier of the investigation |
outputws | :: shared pointer to datasets |
Implements Mantid::API::ICatalog.
Definition at line 459 of file ICat4Catalog.cpp.
References performSearch(), saveDataFiles(), and setICATProxySettings().
|
overridevirtual |
Get datasets.
Returns the datasets associated to the given investigation id.
investigationId | :: unique identifier of the investigation |
outputws | :: shared pointer to datasets |
Implements Mantid::API::ICatalog.
Definition at line 394 of file ICat4Catalog.cpp.
References performSearch(), saveDataSets(), and setICATProxySettings().
|
overridevirtual |
Get the url(s) based on the fileID.
Downloads a file from the given url if not downloaded from archive.
fileID | :: The id of the file to search for. |
Implements Mantid::API::ICatalogInfoService.
Definition at line 569 of file ICat4Catalog.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::Kernel::SingletonHolder< T >::Instance(), m_session, and std::to_string().
|
overridevirtual |
Get the file location string(s) from archive.
Gets the file location string from the archives.
fileID | :: The id of the file to search for. |
Implements Mantid::API::ICatalogInfoService.
Definition at line 551 of file ICat4Catalog.cpp.
References performSearch(), setICATProxySettings(), and std::to_string().
|
private |
Search the archive & obtain the "mantid" dataset ID for a specific investigation if it exists.
If it does not exist, we will attempt to create it.
investigationID | :: Used to obtain the related dataset ID. |
Definition at line 745 of file ICat4Catalog.cpp.
References createMantidDataset(), Mantid::Kernel::Logger::debug(), Mantid::API::g_log, performSearch(), and setICATProxySettings().
Referenced by getPublishInvestigations(), and getUploadURL().
|
overridevirtual |
Obtain the number of results returned by the search method.
Obtain the number of investigations to be returned by the catalog.
Implements Mantid::API::ICatalog.
Definition at line 277 of file ICat4Catalog.cpp.
References buildSearchQuery(), Mantid::Kernel::Logger::debug(), Mantid::API::g_log, performSearch(), and setICATProxySettings().
|
overridevirtual |
Obtains the investigations that the user can publish to and saves related information to a workspace.
Implements Mantid::API::ICatalogInfoService.
Definition at line 615 of file ICat4Catalog.cpp.
References ICat4::ns1__datafile::dataset, getMantidDatasetId(), ICat4::ns1__entityBaseBean::id, Mantid::Kernel::SingletonHolder< T >::Instance(), isAccessAllowed(), myData(), ICat4::ns1__datafile::name, ICat4::ns1__accessType__CREATE, and setICATProxySettings().
|
overridevirtual |
get URL of where to PUT (publish) files.
Get the URL where the datafiles will be uploaded to.
investigationID | :: The investigation used to obtain the related dataset ID. |
createFileName | :: The name to give to the file being saved. |
dataFileDescription | :: The description of the data file being saved. |
Implements Mantid::API::ICatalogInfoService.
Definition at line 592 of file ICat4Catalog.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, getMantidDatasetId(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_session, and std::to_string().
|
private |
Is the specified access type allowed for a specific bean?
accessType | :: The access type to check against the bean. |
bean | :: The bean to check access type against. E.g. CREATE,READ,UPDATE,DELETE. |
Definition at line 871 of file ICat4Catalog.cpp.
References ICat4::ns1__accessType_::__item, ICat4::ns1__isAccessAllowed::accessType, ICat4::ns1__isAccessAllowed::bean, ICat4::ICATPortBindingProxy::isAccessAllowed(), m_session, ICat4::ns1__isAccessAllowedResponse::return_, ICat4::ns1__isAccessAllowed::sessionId, setICATProxySettings(), and throwErrorMessage().
Referenced by createMantidDataset(), and getPublishInvestigations().
|
overridevirtual |
Keep current session alive.
Keep the current session alive.
Implements Mantid::API::ICatalog.
Definition at line 648 of file ICat4Catalog.cpp.
References m_session, ICat4::ICATPortBindingProxy::refresh(), ICat4::ns1__refresh::sessionId, setICATProxySettings(), and throwErrorMessage().
|
overridevirtual |
Get instruments list.
Returns the list of instruments.
instruments | :: instruments list |
Implements Mantid::API::ICatalog.
Definition at line 516 of file ICat4Catalog.cpp.
References performSearch(), and setICATProxySettings().
|
overridevirtual |
Get investigationtypes list.
Returns the list of investigation types.
invstTypes | :: investigation types list |
Implements Mantid::API::ICatalog.
Definition at line 533 of file ICat4Catalog.cpp.
References performSearch(), and setICATProxySettings().
|
overridevirtual |
Log the user into the catalog system.
Authenticate the user against all catalogues in the container.
username | :: The login name of the user. |
password | :: The password of the user. |
endpoint | :: The endpoint url of the catalog to log in to. |
facility | :: The facility of the catalog to log in to. |
Implements Mantid::API::ICatalog.
Definition at line 39 of file ICat4Catalog.cpp.
References ICat4::_ns1__login_credentials_entry::key, login(), ICat4::ICATPortBindingProxy::login(), m_session, ICat4::ns1__loginResponse::return_, setICATProxySettings(), throwErrorMessage(), and ICat4::_ns1__login_credentials_entry::value.
Referenced by login().
|
overridevirtual |
Log the user out of the catalog system.
Disconnects the client application from ICat4 based catalog services.
Implements Mantid::API::ICatalog.
Definition at line 102 of file ICat4Catalog.cpp.
References ICat4::ICATPortBindingProxy::logout(), m_session, ICat4::ns1__logout::sessionId, setICATProxySettings(), and throwErrorMessage().
|
overridevirtual |
Show the logged in user's investigations search results.
Returns the logged in user's investigations data.
outputws | :: Pointer to table workspace that stores the data. |
Implements Mantid::API::ICatalog.
Definition at line 302 of file ICat4Catalog.cpp.
References performSearch(), saveInvestigations(), and setICATProxySettings().
Referenced by getPublishInvestigations().
|
private |
Returns the results of a search against ICAT for a given query.
Note: The ICatProxy object takes care of the deletion of the response object.
icat | :: The proxy object used to interact with gSOAP. |
query | :: The query to send to ICAT. |
Definition at line 843 of file ICat4Catalog.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_session, ICat4::ns1__search::query, ICat4::ns1__searchResponse::return_, ICat4::ICATPortBindingProxy::search(), ICat4::ns1__search::sessionId, and throwErrorMessage().
Referenced by createMantidDataset(), getDataFiles(), getDataSets(), getFileLocation(), getMantidDatasetId(), getNumberOfSearchResults(), listInstruments(), listInvestigationTypes(), myData(), and search().
|
private |
Saves result from "getDataFiles" to workspace.
response | :: result response from the catalog. |
outputws | :: shared pointer to datasets |
Definition at line 472 of file ICat4Catalog.cpp.
References bytesToString(), formatDateTime(), and savetoTableWorkspace().
Referenced by getDataFiles().
|
private |
Loops through the response vector and saves the datasets details to a table workspace.
response | :: A vector containing the results of the search query. |
outputws | :: Shared pointer to output workspace. |
Definition at line 410 of file ICat4Catalog.cpp.
References savetoTableWorkspace().
Referenced by getDataSets().
|
private |
Saves investigations to a table workspace.
response | :: A vector containing the results of the search query. |
outputws | :: Shared pointer to output workspace. |
Definition at line 324 of file ICat4Catalog.cpp.
References formatDateTime(), m_session, and savetoTableWorkspace().
|
inlineprivate |
Template method to save data to table workspace.
input | :: Pointer to input value. |
table | :: Table row reference. |
Definition at line 98 of file ICat4Catalog.h.
Referenced by saveDataFiles(), saveDataSets(), and saveInvestigations().
|
overridevirtual |
Search the catalog for data.
Searches for the relevant data based on user input.
inputs | :: reference to a class contains search inputs |
outputws | :: shared pointer to search results workspace |
offset | :: skip this many rows and start returning rows from this point. |
limit | :: limit the number of rows returned by the query. |
Implements Mantid::API::ICatalog.
Definition at line 254 of file ICat4Catalog.cpp.
References buildSearchQuery(), performSearch(), saveInvestigations(), setICATProxySettings(), and std::to_string().
|
private |
Sets the soap-endpoint & SSL context for the given ICAT proxy.
Definition at line 823 of file ICat4Catalog.cpp.
References Mantid::Kernel::SingletonHolder< T >::Instance(), m_session, setSSLContext(), and ICat4::ICATPortBindingProxy::soap_endpoint.
Referenced by createMantidDataset(), getDataFiles(), getDataSets(), getFileLocation(), getMantidDatasetId(), getNumberOfSearchResults(), getPublishInvestigations(), isAccessAllowed(), keepAlive(), listInstruments(), listInvestigationTypes(), login(), logout(), myData(), and search().
|
private |
Defines the SSL authentication scheme.
icat | :: ICATPortBindingProxy object. |
Definition at line 668 of file ICat4Catalog.cpp.
References throwErrorMessage().
Referenced by setICATProxySettings().
|
private |
Throws an error message (returned by gsoap) to Mantid upper layer.
icat | :: ICATPortBindingProxy object. |
Definition at line 686 of file ICat4Catalog.cpp.
References error, and ICat4::ICATPortBindingProxy::soap_sprint_fault().
Referenced by isAccessAllowed(), keepAlive(), login(), logout(), performSearch(), and setSSLContext().
|
private |
Definition at line 91 of file ICat4Catalog.h.
Referenced by createMantidDataset(), getDownloadURL(), getUploadURL(), isAccessAllowed(), keepAlive(), login(), logout(), performSearch(), saveInvestigations(), and setICATProxySettings().