Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::ICat::ICat4Catalog Class Reference

This class is responsible for the implementation of ICat4 version based information catalogs. More...

#include <ICat4Catalog.h>

Inheritance diagram for Mantid::ICat::ICat4Catalog:
Mantid::API::ICatalog Mantid::API::ICatalogInfoService

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 &timestamp, 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
 

Detailed Description

This class is responsible for the implementation of ICat4 version based information catalogs.

Author
Jay Rainey, ISIS Rutherford Appleton Laboratory
Date
12/08/2013

Definition at line 23 of file ICat4Catalog.h.

Constructor & Destructor Documentation

◆ ICat4Catalog()

Mantid::ICat::ICat4Catalog::ICat4Catalog ( )

Constructor.

Definition at line 30 of file ICat4Catalog.cpp.

Member Function Documentation

◆ buildSearchQuery()

std::string Mantid::ICat::ICat4Catalog::buildSearchQuery ( const CatalogSearchParam inputs)
private

◆ bytesToString()

std::string Mantid::ICat::ICat4Catalog::bytesToString ( int64_t &  fileSize)
private

Convert a file size to human readable file format.

Parameters
fileSize:: The size in bytes of the file.

Definition at line 713 of file ICat4Catalog.cpp.

References std::to_string().

Referenced by saveDataFiles().

◆ createMantidDataset()

int64_t Mantid::ICat::ICat4Catalog::createMantidDataset ( const std::string &  investigationID)
private

Creates a dataset for an investigation (based on ID) named 'mantid' if it does not already exist.

Parameters
investigationID:: The investigation to create a dataset for.
Returns
The ID of the mantid dataset.

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().

◆ formatDateTime()

std::string Mantid::ICat::ICat4Catalog::formatDateTime ( const time_t &  timestamp,
const std::string &  format 
)
private

Formats a given timestamp to human readable datetime.

Parameters
timestamp:: Unix timestamp.
format:: The desired format to output.
Returns
string :: Formatted Unix timestamp.

Definition at line 733 of file ICat4Catalog.cpp.

Referenced by buildSearchQuery(), saveDataFiles(), and saveInvestigations().

◆ getDataFiles()

void Mantid::ICat::ICat4Catalog::getDataFiles ( const std::string &  investigationId,
Mantid::API::ITableWorkspace_sptr outputws 
)
overridevirtual

Get datafiles.

Returns the datafiles associated to the given investigation id.

Parameters
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().

◆ getDataSets()

void Mantid::ICat::ICat4Catalog::getDataSets ( const std::string &  investigationId,
Mantid::API::ITableWorkspace_sptr outputws 
)
overridevirtual

Get datasets.

Returns the datasets associated to the given investigation id.

Parameters
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().

◆ getDownloadURL()

const std::string Mantid::ICat::ICat4Catalog::getDownloadURL ( const long long &  fileID)
overridevirtual

Get the url(s) based on the fileID.

Downloads a file from the given url if not downloaded from archive.

Parameters
fileID:: The id of the file to search for.
Returns
A URL to download the datafile from.

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().

◆ getFileLocation()

const std::string Mantid::ICat::ICat4Catalog::getFileLocation ( const long long &  fileID)
overridevirtual

Get the file location string(s) from archive.

Gets the file location string from the archives.

Parameters
fileID:: The id of the file to search for.
Returns
The location of the datafile stored on the archives.

Implements Mantid::API::ICatalogInfoService.

Definition at line 551 of file ICat4Catalog.cpp.

References performSearch(), setICATProxySettings(), and std::to_string().

◆ getMantidDatasetId()

int64_t Mantid::ICat::ICat4Catalog::getMantidDatasetId ( const std::string &  investigationID)
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.

Parameters
investigationID:: Used to obtain the related dataset ID.
Returns
Dataset ID of the provided investigation.

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().

◆ getNumberOfSearchResults()

int64_t Mantid::ICat::ICat4Catalog::getNumberOfSearchResults ( const CatalogSearchParam inputs)
overridevirtual

Obtain the number of results returned by the search method.

Obtain the number of investigations to be returned by the catalog.

Returns
The number of investigations returned by the search performed.

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().

◆ getPublishInvestigations()

API::ITableWorkspace_sptr Mantid::ICat::ICat4Catalog::getPublishInvestigations ( )
overridevirtual

Obtains the investigations that the user can publish to and saves related information to a workspace.

Returns
A workspace containing investigation information the user can publish to.

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().

◆ getUploadURL()

const std::string Mantid::ICat::ICat4Catalog::getUploadURL ( const std::string &  investigationID,
const std::string &  createFileName,
const std::string &  dataFileDescription 
)
overridevirtual

get URL of where to PUT (publish) files.

Get the URL where the datafiles will be uploaded to.

Parameters
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.
Returns
URL to PUT datafiles to.

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().

◆ isAccessAllowed()

template<class T >
bool Mantid::ICat::ICat4Catalog::isAccessAllowed ( ICat4::ns1__accessType  accessType,
T &  bean 
)
private

Is the specified access type allowed for a specific bean?

Parameters
accessType:: The access type to check against the bean.
bean:: The bean to check access type against. E.g. CREATE,READ,UPDATE,DELETE.
Returns
True if access is allowed, otherwise false.

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().

◆ keepAlive()

void Mantid::ICat::ICat4Catalog::keepAlive ( )
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().

◆ listInstruments()

void Mantid::ICat::ICat4Catalog::listInstruments ( std::vector< std::string > &  instruments)
overridevirtual

Get instruments list.

Returns the list of instruments.

Parameters
instruments:: instruments list

Implements Mantid::API::ICatalog.

Definition at line 516 of file ICat4Catalog.cpp.

References performSearch(), and setICATProxySettings().

◆ listInvestigationTypes()

void Mantid::ICat::ICat4Catalog::listInvestigationTypes ( std::vector< std::string > &  invstTypes)
overridevirtual

Get investigationtypes list.

Returns the list of investigation types.

Parameters
invstTypes:: investigation types list

Implements Mantid::API::ICatalog.

Definition at line 533 of file ICat4Catalog.cpp.

References performSearch(), and setICATProxySettings().

◆ login()

API::CatalogSession_sptr Mantid::ICat::ICat4Catalog::login ( const std::string &  username,
const std::string &  password,
const std::string &  endpoint,
const std::string &  facility 
)
overridevirtual

Log the user into the catalog system.

Authenticate the user against all catalogues in the container.

Parameters
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().

◆ logout()

void Mantid::ICat::ICat4Catalog::logout ( )
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().

◆ myData()

void Mantid::ICat::ICat4Catalog::myData ( Mantid::API::ITableWorkspace_sptr outputws)
overridevirtual

Show the logged in user's investigations search results.

Returns the logged in user's investigations data.

Parameters
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().

◆ performSearch()

std::vector< xsd__anyType * > Mantid::ICat::ICat4Catalog::performSearch ( ICat4::ICATPortBindingProxy icat,
std::string  query 
)
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.

Parameters
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().

◆ saveDataFiles()

void Mantid::ICat::ICat4Catalog::saveDataFiles ( std::vector< ICat4::xsd__anyType * >  response,
API::ITableWorkspace_sptr outputws 
)
private

Saves result from "getDataFiles" to workspace.

Parameters
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().

◆ saveDataSets()

void Mantid::ICat::ICat4Catalog::saveDataSets ( const std::vector< ICat4::xsd__anyType * > &  response,
API::ITableWorkspace_sptr outputws 
)
private

Loops through the response vector and saves the datasets details to a table workspace.

Parameters
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().

◆ saveInvestigations()

void Mantid::ICat::ICat4Catalog::saveInvestigations ( std::vector< ICat4::xsd__anyType * >  response,
API::ITableWorkspace_sptr outputws 
)
private

Saves investigations to a table workspace.

Parameters
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().

Referenced by myData(), and search().

◆ savetoTableWorkspace()

template<class T >
void Mantid::ICat::ICat4Catalog::savetoTableWorkspace ( T *  input,
Mantid::API::TableRow table 
)
inlineprivate

Template method to save data to table workspace.

Parameters
input:: Pointer to input value.
table:: Table row reference.

Definition at line 98 of file ICat4Catalog.h.

Referenced by saveDataFiles(), saveDataSets(), and saveInvestigations().

◆ search()

void Mantid::ICat::ICat4Catalog::search ( const CatalogSearchParam inputs,
Mantid::API::ITableWorkspace_sptr outputws,
const int &  offset,
const int &  limit 
)
overridevirtual

Search the catalog for data.

Searches for the relevant data based on user input.

Parameters
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().

◆ setICATProxySettings()

void Mantid::ICat::ICat4Catalog::setICATProxySettings ( ICat4::ICATPortBindingProxy icat)
private

◆ setSSLContext()

void Mantid::ICat::ICat4Catalog::setSSLContext ( ICat4::ICATPortBindingProxy icat)
private

Defines the SSL authentication scheme.

Parameters
icat:: ICATPortBindingProxy object.

Definition at line 668 of file ICat4Catalog.cpp.

References throwErrorMessage().

Referenced by setICATProxySettings().

◆ throwErrorMessage()

void Mantid::ICat::ICat4Catalog::throwErrorMessage ( ICat4::ICATPortBindingProxy icat)
private

Throws an error message (returned by gsoap) to Mantid upper layer.

Parameters
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().

Member Data Documentation

◆ m_session

API::CatalogSession_sptr Mantid::ICat::ICat4Catalog::m_session
private

The documentation for this class was generated from the following files: