78 if (connDb ==
nullptr)
83 TString sql =
TString::Format(
"insert into simulation_file(generator_name, file_type, file_path, beam_particle, "
84 "target_particle, energy, centrality, event_count, file_size, file_hash, file_desc) "
85 "values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)");
90 stmt->
SetInt(1, file_type);
94 if (energy ==
nullptr)
99 if (event_count ==
nullptr)
102 stmt->
SetInt(7, *event_count);
103 if (file_size ==
nullptr)
107 if (file_hash ==
nullptr)
111 if (file_desc ==
nullptr)
118 cout <<
"ERROR: inserting new simulation file to the Database has been failed" << endl;
129 db_server->
Statement(
"SELECT currval(pg_get_serial_sequence('simulation_file','file_id'))");
138 cout <<
"ERROR: no last ID in DB!" << endl;
142 file_id = stmt_last->
GetInt(0);
146 cout <<
"ERROR: getting last ID has been failed!" << endl;
152 tmp_file_id = file_id;
154 tmp_generator_name = generator_name;
156 tmp_file_type = file_type;
158 tmp_file_path = file_path;
160 tmp_beam_particle = beam_particle;
162 tmp_target_particle = target_particle;
164 if (energy ==
nullptr)
165 tmp_energy =
nullptr;
167 tmp_energy =
new double(*energy);
169 tmp_centrality = centrality;
170 int* tmp_event_count;
171 if (event_count ==
nullptr)
172 tmp_event_count =
nullptr;
174 tmp_event_count =
new int(*event_count);
175 int64_t* tmp_file_size;
176 if (file_size ==
nullptr)
177 tmp_file_size =
nullptr;
179 tmp_file_size =
new int64_t(*file_size);
181 if (file_hash ==
nullptr)
182 tmp_file_hash =
nullptr;
184 tmp_file_hash =
new TString(*file_hash);
186 if (file_desc ==
nullptr)
187 tmp_file_desc =
nullptr;
189 tmp_file_desc =
new TString(*file_desc);
191 return new UniSimulationFile(connDb, tmp_file_id, tmp_generator_name, tmp_file_type, tmp_file_path,
192 tmp_beam_particle, tmp_target_particle, tmp_energy, tmp_centrality, tmp_event_count,
193 tmp_file_size, tmp_file_hash, tmp_file_desc);
200 if (connDb ==
nullptr)
206 "target_particle, energy, centrality, event_count, file_size, file_hash, file_desc "
207 "from simulation_file "
208 "where file_id = %d",
214 cout <<
"ERROR: getting simulation file from the database has been failed" << endl;
226 cout <<
"ERROR: simulation file was not found in the database" << endl;
234 tmp_file_id = stmt->
GetInt(0);
238 tmp_file_type = stmt->
GetInt(2);
244 tmp_target_particle = stmt->
GetString(5);
247 tmp_energy =
nullptr;
249 tmp_energy =
new double(stmt->
GetDouble(6));
252 int* tmp_event_count;
254 tmp_event_count =
nullptr;
256 tmp_event_count =
new int(stmt->
GetInt(8));
257 int64_t* tmp_file_size;
259 tmp_file_size =
nullptr;
261 tmp_file_size =
new int64_t(stmt->
GetLong64(9));
264 tmp_file_hash =
nullptr;
269 tmp_file_desc =
nullptr;
275 return new UniSimulationFile(connDb, tmp_file_id, tmp_generator_name, tmp_file_type, tmp_file_path,
276 tmp_beam_particle, tmp_target_particle, tmp_energy, tmp_centrality, tmp_event_count,
277 tmp_file_size, tmp_file_hash, tmp_file_desc);
284 if (connDb ==
nullptr)
290 "target_particle, energy, centrality, event_count, file_size, file_hash, file_desc "
291 "from simulation_file "
292 "where lower(file_path) = lower('%s')",
298 cout <<
"ERROR: getting simulation file from the database has been failed" << endl;
310 cout <<
"ERROR: simulation file was not found in the database" << endl;
318 tmp_file_id = stmt->
GetInt(0);
322 tmp_file_type = stmt->
GetInt(2);
328 tmp_target_particle = stmt->
GetString(5);
331 tmp_energy =
nullptr;
333 tmp_energy =
new double(stmt->
GetDouble(6));
336 int* tmp_event_count;
338 tmp_event_count =
nullptr;
340 tmp_event_count =
new int(stmt->
GetInt(8));
341 int64_t* tmp_file_size;
343 tmp_file_size =
nullptr;
345 tmp_file_size =
new int64_t(stmt->
GetLong64(9));
348 tmp_file_hash =
nullptr;
353 tmp_file_desc =
nullptr;
359 return new UniSimulationFile(connDb, tmp_file_id, tmp_generator_name, tmp_file_type, tmp_file_path,
360 tmp_beam_particle, tmp_target_particle, tmp_energy, tmp_centrality, tmp_event_count,
361 tmp_file_size, tmp_file_hash, tmp_file_desc);
368 if (connDb ==
nullptr)
374 "from simulation_file "
375 "where file_id = %d",
381 cout <<
"ERROR: getting simulation file from the database has been failed" << endl;
408 if (connDb ==
nullptr)
414 "from simulation_file "
415 "where lower(file_path) = lower('%s')",
421 cout <<
"ERROR: getting simulation file from the database has been failed" << endl;
448 if (connDb ==
nullptr)
454 "where file_id = $1");
462 cout <<
"ERROR: deleting simulation file from the dataBase has been failed" << endl;
478 if (connDb ==
nullptr)
484 "where lower(file_path) = lower($1)");
492 cout <<
"ERROR: deleting simulation file from the DataBase has been failed" << endl;
508 if (connDb ==
nullptr)
514 "target_particle, energy, centrality, event_count, file_size, file_hash, file_desc "
515 "from simulation_file");
520 cout <<
"ERROR: getting all 'simulation files' from the dataBase has been failed" << endl;
531 cout <<
"Table 'simulation_file':" << endl;
534 cout << (stmt->
GetInt(0));
535 cout <<
", generator_name: ";
537 cout <<
", file_type: ";
538 cout << (stmt->
GetInt(2));
539 cout <<
", file_path: ";
541 cout <<
", beam_particle: ";
543 cout <<
", target_particle: ";
545 cout <<
", energy: ";
550 cout <<
", centrality: ";
552 cout <<
", event_count: ";
557 cout <<
", file_size: ";
562 cout <<
", file_hash: ";
567 cout <<
", file_desc: ";
585 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
592 "set generator_name = $1 "
593 "where file_id = $2");
602 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
617 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
624 "set file_type = $1 "
625 "where file_id = $2");
629 stmt->
SetInt(0, file_type);
634 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
649 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
656 "set file_path = $1 "
657 "where file_id = $2");
666 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
681 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
688 "set beam_particle = $1 "
689 "where file_id = $2");
698 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
713 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
720 "set target_particle = $1 "
721 "where file_id = $2");
730 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
745 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
753 "where file_id = $2");
757 if (energy ==
nullptr)
765 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
773 if (energy ==
nullptr)
785 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
792 "set centrality = $1 "
793 "where file_id = $2");
802 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
817 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
824 "set event_count = $1 "
825 "where file_id = $2");
829 if (event_count ==
nullptr)
832 stmt->
SetInt(0, *event_count);
837 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
845 if (event_count ==
nullptr)
857 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
864 "set file_size = $1 "
865 "where file_id = $2");
869 if (file_size ==
nullptr)
877 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
885 if (file_size ==
nullptr)
897 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
904 "set file_hash = $1 "
905 "where file_id = $2");
909 if (file_hash ==
nullptr)
917 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
925 if (file_hash ==
nullptr)
937 cout <<
"CRITICAL ERROR: Connection object is null" << endl;
944 "set file_desc = $1 "
945 "where file_id = $2");
949 if (file_desc ==
nullptr)
957 cout <<
"ERROR: updating information about simulation file has been failed" << endl;
965 if (file_desc ==
nullptr)
977 cout <<
"Table 'simulation_file'";
997 if (connDb ==
nullptr) {
998 cout <<
"ERROR: connection to the Unified Condition Database was failed" << endl;
1005 "target_particle, energy, centrality, event_count, file_size, file_hash, file_desc "
1006 "from simulation_file");
1012 cout <<
"ERROR: getting record from the database has been failed" << endl;
1028 if (connRun ==
nullptr) {
1030 <<
"ERROR: the connection to the Unified Condition Database for the selected simulation file was failed"
1037 tmp_file_id = stmt->
GetInt(0);
1039 tmp_generator_name = stmt->
GetString(1);
1041 tmp_file_type = stmt->
GetInt(2);
1047 tmp_target_particle = stmt->
GetString(5);
1050 tmp_energy =
nullptr;
1052 tmp_energy =
new double(stmt->
GetDouble(6));
1055 int* tmp_event_count;
1057 tmp_event_count =
nullptr;
1059 tmp_event_count =
new int(stmt->
GetInt(8));
1060 int64_t* tmp_file_size;
1062 tmp_file_size =
nullptr;
1064 tmp_file_size =
new int64_t(stmt->
GetLong64(9));
1067 tmp_file_hash =
nullptr;
1072 tmp_file_desc =
nullptr;
1077 tmp_file_path, tmp_beam_particle, tmp_target_particle,
1078 tmp_energy, tmp_centrality, tmp_event_count, tmp_file_size,
1079 tmp_file_hash, tmp_file_desc));
1093 if (connDb ==
nullptr) {
1094 cout <<
"ERROR: connection to the Unified Condition Database was failed" << endl;
1101 "target_particle, energy, centrality, event_count, file_size, file_hash, file_desc "
1102 "from simulation_file");
1105 bool isFirst =
true;
1106 TIter next(&search_conditions);
1113 strCondition +=
"lower(file_path) ";
1116 strCondition +=
"lower(generator_name) ";
1119 strCondition +=
"lower(beam_particle) ";
1122 strCondition +=
"lower(target_particle) ";
1125 strCondition +=
"energy ";
1128 strCondition +=
"lower(centrality) ";
1131 strCondition +=
"event_count ";
1134 strCondition +=
"lower(file_desc) ";
1137 strCondition +=
"file_size ";
1140 cout <<
"ERROR: the column in the search condition was not defined, the condition is skipped" << endl;
1146 strCondition +=
"< ";
1149 strCondition +=
"<= ";
1152 strCondition +=
"= ";
1155 strCondition +=
"<> ";
1158 strCondition +=
"> ";
1161 strCondition +=
">= ";
1164 strCondition +=
"like ";
1167 strCondition +=
"is null ";
1170 strCondition +=
"is not null ";
1173 cout <<
"ERROR: the comparison operator in the search condition was not defined, the condition is "
1201 cout <<
"ERROR: the value type in the search condition was not found, the condition is skipped" << endl;
1211 sql += strCondition;
1213 sql +=
" order by generator_name";
1220 cout <<
"ERROR: getting simulation files from the Unified Condition Database has been failed" << endl;
1235 if (connRun ==
nullptr) {
1237 <<
"ERROR: the connection to the Unified Condition Database for the selected simulation file was failed"
1243 tmp_file_id = stmt->
GetInt(0);
1245 tmp_generator_name = stmt->
GetString(1);
1247 tmp_file_type = stmt->
GetInt(2);
1253 tmp_target_particle = stmt->
GetString(5);
1256 tmp_energy =
nullptr;
1258 tmp_energy =
new double(stmt->
GetDouble(6));
1261 int* tmp_event_count;
1263 tmp_event_count =
nullptr;
1265 tmp_event_count =
new int(stmt->
GetInt(8));
1266 int64_t* tmp_file_size;
1268 tmp_file_size =
nullptr;
1270 tmp_file_size =
new int64_t(stmt->
GetLong64(9));
1273 tmp_file_hash =
nullptr;
1278 tmp_file_desc =
nullptr;
1283 tmp_file_path, tmp_beam_particle, tmp_target_particle,
1284 tmp_energy, tmp_centrality, tmp_event_count, tmp_file_size,
1285 tmp_file_hash, tmp_file_desc));
1296 search_conditions.
Add((
TObject*)&search_condition);
1298 return Search(search_conditions);
char * Form(const char *fmt,...)
virtual void SetOwner(Bool_t enable=kTRUE)
const char * AsSQLString() const
void Add(TObject *obj) override
virtual TSQLStatement * Statement(const char *, Int_t=100)
virtual const char * GetString(Int_t)
virtual Bool_t NextIteration()=0
virtual Bool_t NextResultRow()=0
virtual Bool_t SetString(Int_t, const char *, Int_t=256)
virtual Int_t GetInt(Int_t)
virtual Bool_t IsNull(Int_t)
virtual Long64_t GetLong64(Int_t)
virtual Bool_t SetDouble(Int_t, Double_t)
virtual Bool_t Process()=0
virtual Bool_t SetInt(Int_t, Int_t)
virtual Bool_t SetNull(Int_t)
virtual Double_t GetDouble(Int_t)
virtual Bool_t StoreResult()=0
virtual Bool_t SetLong64(Int_t, Long64_t)
const char * Data() const
static TString Format(const char *fmt,...)
static UniConnection * Open()
TSQLServer * GetSQLServer()
enumConditions GetCondition()
@ conditionGreaterOrEqual
unsigned int GetUIntValue()
static int DeleteSimulationFile(int file_id)
delete simulation file from the database
int SetEnergy(double *energy)
set energy of the current simulation file
UniSimulationFile(UniConnection *db_connect, int file_id, TString generator_name, int file_type, TString file_path, TString beam_particle, TString target_particle, double *energy, TString centrality, int *event_count, int64_t *file_size, TString *file_hash, TString *file_desc)
void Print()
print information about current simulation file
int SetEventCount(int *event_count)
set event count of the current simulation file
int SetFileHash(TString *file_hash)
set file hash of the current simulation file
int SetCentrality(TString centrality)
set centrality of the current simulation file
TString str_centrality
centrality
virtual ~UniSimulationFile()
int64_t * i64_file_size
file size
TString str_generator_name
generator name
static UniSimulationFile * GetSimulationFile(int file_id)
get simulation file from the database
int SetFileType(int file_type)
set file type of the current simulation file
static int PrintAll()
print all simulation files
int * i_event_count
event count
int SetFileDesc(TString *file_desc)
set file desc of the current simulation file
TString str_file_path
file path
TString * str_file_desc
file desc
TString * str_file_hash
file hash
static TObjArray * GetSimulationFiles()
get array of all UniSimulationFile-s from the database
int SetBeamParticle(TString beam_particle)
set beam particle of the current simulation file
TString str_beam_particle
beam particle
static int CheckSimulationFileExists(int file_id)
check simulation file exists in the database: 1- true, 0 - false, <0 - database operation error
UniConnection * connectionDB
connection to the database
TString str_target_particle
target particle
int SetGeneratorName(TString generator_name)
set generator name of the current simulation file
int SetFilePath(TString file_path)
set file path of the current simulation file
int SetTargetParticle(TString target_particle)
set target particle of the current simulation file
static TObjArray * Search(UniSearchCondition &search_condition)
get simulation files corresponding to the specified single condition and set owner for search_conditi...
static UniSimulationFile * CreateSimulationFile(TString generator_name, int file_type, TString file_path, TString beam_particle, TString target_particle, double *energy, TString centrality, int *event_count, int64_t *file_size, TString *file_hash, TString *file_desc)
add new simulation file to the database
int SetFileSize(int64_t *file_size)
set file size of the current simulation file