-
Notifications
You must be signed in to change notification settings - Fork 122
/
ICat3Catalog.cpp
157 lines (138 loc) · 5.77 KB
/
ICat3Catalog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "MantidICat/ICat3/ICat3Catalog.h"
#include "MantidAPI/CatalogFactory.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/AnalysisDataService.h"
namespace Mantid
{
namespace ICat
{
DECLARE_CATALOG(ICat3Catalog)
/// constructor
ICat3Catalog::ICat3Catalog() : m_helper(new CICatHelper()) {}
/// destructor
ICat3Catalog::~ICat3Catalog() {}
/**
* Authenticate the user against all catalogues in the container.
* @param username :: The login name of the user.
* @param password :: The password of the user.
* @param endpoint :: The endpoint url of the catalog to log in to.
* @param facility :: The facility of the catalog to log in to.
*/
API::CatalogSession_sptr ICat3Catalog::login(const std::string& username,const std::string& password,
const std::string& endpoint, const std::string& facility)
{
return m_helper->doLogin(username,password,endpoint,facility);
}
/// This method disconnects the client application from ICat3 based catalog services
void ICat3Catalog::logout()
{
m_helper->doLogout();
}
/*This method returns the logged in user's investigations data .
*@param mydataws_sptr :: pointer to table workspace which stores the data
*/
void ICat3Catalog::myData(Mantid::API::ITableWorkspace_sptr& mydataws_sptr)
{
m_helper->doMyDataSearch(mydataws_sptr);
}
/*This method returns the datasets associated to the given investigationid .
*@param investigationId :: unique identifier of the investigation
*@param datasetsws_sptr :: shared pointer to datasets
*/
void ICat3Catalog::getDataSets(const std::string& investigationId,Mantid::API::ITableWorkspace_sptr& datasetsws_sptr)
{
//search datasets for a given investigation id using ICat api.
m_helper->doDataSetsSearch(boost::lexical_cast<int64_t>(investigationId),
ICat3::ns1__investigationInclude__DATASETS_USCOREAND_USCOREDATASET_USCOREPARAMETERS_USCOREONLY,datasetsws_sptr);
}
/*This method returns the datafiles associated to the given investigationid .
*@param investigationId :: unique identifier of the investigation
*@param datafilesws_sptr :: shared pointer to datasets
*/
void ICat3Catalog::getDataFiles(const std::string& investigationId,Mantid::API::ITableWorkspace_sptr& datafilesws_sptr)
{
m_helper->getDataFiles(boost::lexical_cast<int64_t>(investigationId),
ICat3::ns1__investigationInclude__DATASETS_USCOREAND_USCOREDATAFILES,datafilesws_sptr);
}
/**This method returns the list of instruments
*@param instruments :: instruments list
*/
void ICat3Catalog::listInstruments(std::vector<std::string>& instruments)
{
m_helper->listInstruments(instruments);
}
/**This method returns the list of investigationtypes
*@param invstTypes :: investigation types list
*/
void ICat3Catalog::listInvestigationTypes(std::vector<std::string>& invstTypes)
{
m_helper->listInvestigationTypes(invstTypes);
}
/**
* Gets the file location string from the archives.
* @param fileID :: The id of the file to search for.
* @return The location of the datafile stored on the archives.
*/
const std::string ICat3Catalog::getFileLocation(const long long &fileID)
{
return m_helper->getlocationString(fileID);
}
/**
* Downloads a file from the given url if not downloaded from archive.
* @param fileID :: The id of the file to search for.
* @return A URL to download the datafile from.
*/
const std::string ICat3Catalog::getDownloadURL(const long long &fileID)
{
return m_helper->getdownloadURL(fileID);
}
/**
* Get the URL where the datafiles will be uploaded to.
* @param investigationID :: The investigation used to obtain the related dataset ID.
* @param createFileName :: The name to give to the file being saved.
* @param dataFileDescription :: The description of the data file being saved.
* @return URL to PUT datafiles to.
*/
const std::string ICat3Catalog::getUploadURL(
const std::string &investigationID, const std::string &createFileName, const std::string &dataFileDescription)
{
UNUSED_ARG(investigationID);
UNUSED_ARG(createFileName);
UNUSED_ARG(dataFileDescription);
throw std::runtime_error("ICat3Catalog does not support publishing.");
}
/**This method method does the search for investigations
*@param inputs :: reference to a class conatains search inputs
*@param ws_sptr :: -shared pointer to search results workspace
*@param offset :: skip this many rows and start returning rows from this point.
*@param limit :: limit the number of rows returned by the query.
*/
void ICat3Catalog::search(const CatalogSearchParam& inputs, Mantid::API::ITableWorkspace_sptr& ws_sptr,
const int &offset, const int &limit)
{
m_helper->doAdvancedSearch(inputs,ws_sptr, offset, limit);
}
/**
* Modifies the search query to obtain the number
* of investigations to be returned by the catalog.
* @return The number of investigations returned by the search performed.
*/
int64_t ICat3Catalog::getNumberOfSearchResults(const CatalogSearchParam& inputs)
{
return m_helper->getNumberOfSearchResults(inputs);
}
/// keep alive
void ICat3Catalog::keepAlive()
{
}
/**
* Obtains the investigations that the user can publish
* to and saves related information to a workspace.
* @return A workspace containing investigation information the user can publish to.
*/
API::ITableWorkspace_sptr ICat3Catalog::getPublishInvestigations()
{
throw std::runtime_error("Publishing is not supported in ICat3Catalog.");
}
}
}