BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
EventCatalogue.h
Go to the documentation of this file.
1/** Interface to the Event Catalogue (through REST API service) to add, update, delete and search for event metadata
2 *
3 * @author K. Gertsenberger
4 * @version 0.2
5 * @since 10.12.24
6 *
7 */
8#ifndef EVENTCATALOGUE_H
9#define EVENTCATALOGUE_H
10
11// #include "TObject.h"
12
13#include <curl/curl.h>
14#include <memory>
15#include <string>
16#include <vector>
17using namespace std;
18
19/// Class presenting Event Info (Metadata) Structure
21{
22 public:
23 static const int Version = 1; ///< structure (API) version
24
25 string StorageName = ""; ///< storage name, where the file with the event is located
26 string FilePath = ""; ///< path of the file containing the event
27 int EventNumber = -1; ///< event number in the file
28
29 string SoftwareVersion = ""; ///< version of the software used for processing the event
30 int PeriodNumber = -1; ///< number of experiment session, when the event was collected
31 int RunNumber = -1; ///< number of experiment run, when the event was collected
32
33 int TrackNumber = -1; ///< number of tracks in the event
34};
35
36/// Class for describing a condition to search for necessary event metadata
38{
39 public:
40 /// enumeration for attributes, which can be used in searching event metadata
52 /// enumeration for conditions, which can be used for matching with a specified value
65
66 /*!
67 * Create condition for searching event metadata
68 * \param[in] attribute Used for searching event metadata
69 * \param[in] condition Defining the operation of comparison with the value
70 */
71 EventCondition(searchAttributes attribute, matchCriteria condition);
72 EventCondition(searchAttributes attribute, matchCriteria condition, int value);
73 EventCondition(searchAttributes attribute, matchCriteria condition, unsigned int value);
74 EventCondition(searchAttributes attribute, matchCriteria condition, double value);
75 EventCondition(searchAttributes attribute, matchCriteria condition, string value);
76 virtual ~EventCondition() {}
77
78 private:
80
83
84 // 1 - int, 2 - unsigned int, 3 - double, 4 - TString, 5 - TDatime
86 int iValue;
87 unsigned int uiValue;
88 double dValue;
89 string strValue;
90};
91
92/// Main Interface Class to work with the Event Catalogue of the experiment
93/// Throws runtime_exception if a critical error occurrs while the constructor
94/// Error Codes: -1 - sending command via CURL failed, -401 - unauthorized request, -403 - token invalid or expired,
95/// -404 - data not found, -409 - incorrect database request (e.g. violating constraints), -422 - incorrect input
96/// request, -500 - internal server error, -503 - service unavaialble, -504 - gateway timeout
98{
99 public:
101 virtual ~EventCatalogue();
102
103 /*!
104 * Function for searching for event metadata in the Event Catalogue using specified conditions
105 * \param[in] event_conditions A set of conditions to specify criteria for event metadata search
106 * \return Array of the 'EventInfo' objects containing selected event metadata (enpty if not found or some errors
107 * occured)
108 */
109 vector<unique_ptr<EventInfo>> GetEventList(vector<unique_ptr<EventCondition>> event_conditions);
110
111 /*!
112 * Function tp get metadata of the event stored at the given location
113 * \param[in] storage_name Storage, where the file with the event is located
114 * \param[in] file_path Path of the file containing the event
115 * \param[in] event_number Number of the event in the file
116 * \return 'EventInfo' object containing event metadata for the event (nullptr if not found or some errors occured)
117 */
118 unique_ptr<EventInfo> GetEventInfo(string storage_name, string file_path, int event_number);
119
120 /*!
121 * Function to add metadata for the event stored at the given location
122 * \param[in] storage_name Storage, where the file with the event is located
123 * \param[in] file_path Path of the file containing the event
124 * \param[in] event_number Number of the event in the file
125 * \param[in] event_metadata 'EventInfo' object containing event metadata for the event
126 * \return 0 - if successfully added, <0 - an error occured
127 */
128 int AddEventInfo(string storage_name, string file_path, int event_number, EventInfo event_metadata);
129
130 /*!
131 * Function to add metadata of events to the Event Catalogue using input JSON file path
132 * \param[in] json_file_path path of the JSON file containing a set of event metadata to be stored
133 * \return number (>=0) of successfully added event metadata records or error_code (<0) in case of failures
134 */
135 int AddEventInfo(string json_file_path);
136
137 /*!
138 * Function to update metadata of the event stored at the given location
139 * \param[in] storage_name Storage, where the file with the event is located
140 * \param[in] file_path Path of the file containing the event
141 * \param[in] event_number Number of the event in the file
142 * \param[in] event_metadata 'EventInfo' object containing event metadata for the event
143 * \return 0 - if successfully updated, <0 - an error occured
144 */
145 int UpdateEventInfo(string storage_name, string file_path, int event_number, EventInfo event_metadata);
146
147 /*!
148 * Function to delete metadata for the event stored at the given location
149 * \param[in] storage_name Storage, where the file with the event is located
150 * \param[in] file_path Path of the file containing the event
151 * \param[in] event_number Number of the event in the file
152 * \return 0 - if successfully deleted, <0 - an error occured
153 */
154 int DeleteEventInfo(string storage_name, string file_path, int event_number);
155
156 /*!
157 * Function to check metadata for the event stored at the given location
158 * \param[in] storage_name Storage, where the file with the event is located
159 * \param[in] file_path Path of the file containing the event
160 * \param[in] event_number Number of the event in the file
161 * \return 0 - if event metadata is avaialble, 1 - if event metadata is not set, <0 - an error occured
162 */
163 int CheckEventInfo(string storage_name, string file_path, int event_number);
164
165 /*!
166 * Function to print metadata for the event stored at the given location
167 * \param[in] storage_name Storage, where the file with the event is located
168 * \param[in] file_path Path of the file containing the event
169 * \param[in] event_number Number of the event in the file
170 * \return 0 - if successfull, <0 - an error occured
171 */
172 int PrintEventInfo(string storage_name, string file_path, int event_number);
173
174 /*!
175 * Function to add storage to the dictionary used by the Event Catalogue
176 * \param[in] storage_name Name of the storage be added to the dictionary
177 * \return 0 - if successfull, <0 - an error occured
178 */
179 int AddStorageInfo(string storage_name);
180
181 /*!
182 * Function to add software version to the dictionary used by the Event Catalogue
183 * \param[in] software_version Version of the software, which was used to obtain processed events
184 * \return 0 - if successfull, <0 - an error occured
185 */
186 int AddSoftwareInfo(string software_version);
187
188 /*!
189 * Function for searching for event metadata in the Event Catalogue using REST API request as an HTTP(s) string
190 * \param[in] rest_api_request String HTTP command representing a request using REST API format
191 * \return Array of the 'EventInfo' objects containing selected event metadata (enpty if not found or some errors
192 * occured)
193 */
194 vector<unique_ptr<EventInfo>> EventCatalogueRequest(string rest_api_request);
195
196 /*!
197 * Function to perform a set of specific checks in the Event Catalogue
198 * \param[out] file_not_found Number of not found files for existing metadata in the Catalogue
199 * \param[out] event_list List of not found files for existing metadata in the Catalogue
200 * \return 0 - if successfull, <0 - an error occured
201 */
202 int EventCatalogueChecks(int& file_not_found, vector<unique_ptr<EventInfo>>& event_list);
203
204 /*!
205 * Function to collect summary statistics on the Event Catalogue
206 * \param[out] record_count Number of records in the Event Catalogue
207 * \return 0 - if successfull, <0 - an error occured
208 */
209 int EventCatalogueStats(int& record_count);
210
211 /*!
212 * Setting Verbose level: 0 - only errors, 1 - normal output, 2 - detailed output, 2- all with debug info
213 * \param[in] verbose_level Verbose level for output information
214 */
215 void SetVerbose(int verbose_level = 2) { VerboseLevel = verbose_level; }
216
217 private:
218 CURL* curlInstance; // CURL instance created while the constructor
219 string ServiceUrl; // common part of the url for REST API request
220 string ServiceAccount; // user account
221
222 int VerboseLevel = 2; // VerboseLevel: 0 - without messages except errors, 1 - normal output, 2 - detailed output,
223 // 3 - debug output
224
225 int PostRequest(string RequestUrl, string json_string, string success_message);
226
227 // ClassDef(EventCatalogue, 1)
228};
229
230#endif /* !EVENTCATALOGUE_H */
virtual ~EventCatalogue()
int DeleteEventInfo(string storage_name, string file_path, int event_number)
Function to delete metadata for the event stored at the given location.
int AddSoftwareInfo(string software_version)
Function to add software version to the dictionary used by the Event Catalogue.
int UpdateEventInfo(string storage_name, string file_path, int event_number, EventInfo event_metadata)
Function to update metadata of the event stored at the given location.
void SetVerbose(int verbose_level=2)
Setting Verbose level: 0 - only errors, 1 - normal output, 2 - detailed output, 2- all with debug inf...
int PostRequest(string RequestUrl, string json_string, string success_message)
vector< unique_ptr< EventInfo > > EventCatalogueRequest(string rest_api_request)
Function for searching for event metadata in the Event Catalogue using REST API request as an HTTP(s)...
int AddEventInfo(string storage_name, string file_path, int event_number, EventInfo event_metadata)
Function to add metadata for the event stored at the given location.
int CheckEventInfo(string storage_name, string file_path, int event_number)
Function to check metadata for the event stored at the given location.
int AddStorageInfo(string storage_name)
Function to add storage to the dictionary used by the Event Catalogue.
int EventCatalogueStats(int &record_count)
Function to collect summary statistics on the Event Catalogue.
int EventCatalogueChecks(int &file_not_found, vector< unique_ptr< EventInfo > > &event_list)
Function to perform a set of specific checks in the Event Catalogue.
vector< unique_ptr< EventInfo > > GetEventList(vector< unique_ptr< EventCondition > > event_conditions)
Function for searching for event metadata in the Event Catalogue using specified conditions.
int PrintEventInfo(string storage_name, string file_path, int event_number)
Function to print metadata for the event stored at the given location.
unique_ptr< EventInfo > GetEventInfo(string storage_name, string file_path, int event_number)
Function tp get metadata of the event stored at the given location.
matchCriteria EventMatchCriteria
searchAttributes
enumeration for attributes, which can be used in searching event metadata
searchAttributes EventAttribute
matchCriteria
enumeration for conditions, which can be used for matching with a specified value
unsigned int uiValue
EventCondition(searchAttributes attribute, matchCriteria condition)
Create condition for searching event metadata.
virtual ~EventCondition()
Class presenting Event Info (Metadata) Structure.
int PeriodNumber
number of experiment session, when the event was collected
string SoftwareVersion
version of the software used for processing the event
string FilePath
path of the file containing the event
static const int Version
structure (API) version
int TrackNumber
number of tracks in the event
int RunNumber
number of experiment run, when the event was collected
int EventNumber
event number in the file
string StorageName
storage name, where the file with the event is located
Definition json.hpp:4446