-
Notifications
You must be signed in to change notification settings - Fork 122
/
ICat4Catalog.h
120 lines (109 loc) · 5.3 KB
/
ICat4Catalog.h
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
#ifndef MANTID_ICAT_ICAT4CATALOG_H_
#define MANTID_ICAT_ICAT4CATALOG_H_
#include "MantidAPI/ICatalog.h"
#include "MantidAPI/TableRow.h"
#include "MantidKernel/Logger.h"
#include "MantidICat/CatalogSearchParam.h"
namespace Mantid
{
namespace ICat
{
/**
This class is responsible for the implementation of ICat4 version based information catalogs
@author Jay Rainey, ISIS Rutherford Appleton Laboratory
@date 12/08/2013
Copyright © 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class ICat4Catalog : public Mantid::API::ICatalog
{
public:
/// Constructor
ICat4Catalog():g_log(Kernel::Logger::get("ICat4Catalog")) {}
/// Destructor
virtual ~ICat4Catalog();
/// Log the user into the catalog system.
virtual void login(const std::string& username,const std::string& password,const std::string& url);
/// Log the user out of the catalog system.
virtual void logout();
/// Search the catalog for data.
virtual void search(const CatalogSearchParam& inputs, Mantid::API::ITableWorkspace_sptr& outputws,
const int &offset, const int &limit);
/// Obtain the number of results returned by the search method.
virtual int64_t getNumberOfSearchResults(const CatalogSearchParam& inputs);
/// Show the logged in user's investigations search results.
virtual void myData(Mantid::API::ITableWorkspace_sptr& outputws);
/// Get datasets.
virtual void getDataSets(const long long&investigationId,Mantid::API::ITableWorkspace_sptr& outputws);
/// Get datafiles
virtual void getDataFiles(const long long&investigationId,Mantid::API::ITableWorkspace_sptr& outputws);
/// Get instruments list
virtual void listInstruments(std::vector<std::string>& instruments);
/// Get investigationtypes list
virtual void listInvestigationTypes(std::vector<std::string>& invstTypes);
/// Get the file location string(s) from archive.
virtual void getFileLocation(const long long&fileID,std::string& fileLocation);
/// Get the url(s) based on the fileID.
virtual void getDownloadURL(const long long& fileID,std::string & url);
/// get URL of where to PUT (publish) files.
virtual std::string getUploadURL(std::string &dataFileName, std::string &createFileName);
/// Keep current session alive
virtual void keepAlive();
/// Keep alive in minutes
virtual int keepAliveinminutes();
private:
// Ensures human friendly error messages are provided to the user.
void throwErrorMessage(ICat4::ICATPortBindingProxy& icat);
// Defines the SSL authentication scheme.
void setSSLContext(ICat4::ICATPortBindingProxy& icat);
// Saves "MyData" query result to output workspace.
void saveInvestigations(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
// Creates a search query string based on inputs provided by the user.
std::string buildSearchQuery(const CatalogSearchParam& inputs);
// Saves "DataFiles" result to output workspace.
void saveDataFiles(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
// Saves "DataSets" information to the output workspace.
void saveDataSets(std::vector<ICat4::xsd__anyType*> response, API::ITableWorkspace_sptr& outputws);
// Convert a file size to human readable file format.
std::string bytesToString(int64_t &fileSize);
// Helper method that formats a given timestamp.
std::string formatDateTime(const time_t ×tamp, const std::string &format);
// Sets the soap-endpoint & SSL context for the proxy being returned.
ICat4::ICATPortBindingProxy getICATProxy();
// Search the archive & obtain the dataset ID based on the filename
int64_t getDatasetIdFromFileName(std::string &fileName);
// Reference to the logger class.
Kernel::Logger& g_log;
/**
* Template method to save data to table workspace
* @param input :: Pointer to input value.
* @param table :: Table row reference.
*/
template<class T>
void savetoTableWorkspace(T* input,Mantid::API::TableRow &table)
{
if(input != 0)
{
table << *input;
}
else
{
table << "";
}
}
};
}
}
#endif