BmnRoot
Loading...
Searching...
No Matches
ElogRecord.cxx
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2// ElogRecord cxx file
3// Generated 27-11-2017
4// ----------------------------------------------------------------------
5
6#include "ElogRecord.h"
7
8#include "TSQLServer.h"
9#include "TSQLStatement.h"
10
11#include <iostream>
12using namespace std;
13
14/* GENERATED CLASS MEMBERS (SHOULD NOT BE CHANGED MANUALLY) */
15// ----- Constructor with database connection -----------------------
16ElogRecord::ElogRecord(ElogConnection* db_connect,
17 int record_id,
18 TDatime record_date,
19 TString* shift_leader_id,
20 int type_id,
21 int* period_number,
22 int* run_number,
23 int* trigger_id,
24 TString* daq_status,
25 int* sp_41,
26 int* sp_57,
27 int* vkm2,
28 TString beam,
29 double* energy,
30 TString target,
31 double* target_width,
32 TString* record_comment,
33 int* system_status_id)
34{
35 connectionDB = db_connect;
36
37 i_record_id = record_id;
38 dt_record_date = record_date;
39 str_shift_leader_id = shift_leader_id;
40 i_type_id = type_id;
41 i_period_number = period_number;
42 i_run_number = run_number;
43 i_trigger_id = trigger_id;
44 str_daq_status = daq_status;
45 i_sp_41 = sp_41;
46 i_sp_57 = sp_57;
47 i_vkm2 = vkm2;
48 str_beam = beam;
49 d_energy = energy;
50 str_target = target;
51 d_target_width = target_width;
52 str_record_comment = record_comment;
53 i_system_status_id = system_status_id;
54}
55
56// ----- Destructor -------------------------------------------------
58{
59 if (connectionDB)
60 delete connectionDB;
61 if (str_shift_leader_id)
62 delete str_shift_leader_id;
63 if (i_period_number)
64 delete i_period_number;
65 if (i_run_number)
66 delete i_run_number;
67 if (i_trigger_id)
68 delete i_trigger_id;
69 if (str_daq_status)
70 delete str_daq_status;
71 if (i_sp_41)
72 delete i_sp_41;
73 if (i_sp_57)
74 delete i_sp_57;
75 if (i_vkm2)
76 delete i_vkm2;
77 if (d_energy)
78 delete d_energy;
79 if (d_target_width)
80 delete d_target_width;
81 if (str_record_comment)
82 delete str_record_comment;
83 if (i_system_status_id)
84 delete i_system_status_id;
85}
86
87// ----- Creating new record in the database ---------------------------
89 TString* shift_leader_id,
90 int type_id,
91 int* period_number,
92 int* run_number,
93 int* trigger_id,
94 TString* daq_status,
95 int* sp_41,
96 int* sp_57,
97 int* vkm2,
98 TString beam,
99 double* energy,
100 TString target,
101 double* target_width,
102 TString* record_comment,
103 int* system_status_id)
104{
106 if (connDb == nullptr)
107 return nullptr;
108
109 TSQLServer* db_server = connDb->GetSQLServer();
110
111 TString sql = TString::Format(
112 "insert into record_(record_date, shift_leader_id, type_id, period_number, run_number, trigger_id, daq_status, "
113 "sp_41, sp_57, vkm2, beam, energy, target, target_width, record_comment, system_status_id) "
114 "values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)");
115 TSQLStatement* stmt = db_server->Statement(sql);
116
117 stmt->NextIteration();
118 stmt->SetDatime(0, record_date);
119 if (shift_leader_id == nullptr)
120 stmt->SetNull(1);
121 else
122 stmt->SetString(1, *shift_leader_id);
123 stmt->SetInt(2, type_id);
124 if (period_number == nullptr)
125 stmt->SetNull(3);
126 else
127 stmt->SetInt(3, *period_number);
128 if (run_number == nullptr)
129 stmt->SetNull(4);
130 else
131 stmt->SetInt(4, *run_number);
132 if (trigger_id == nullptr)
133 stmt->SetNull(5);
134 else
135 stmt->SetInt(5, *trigger_id);
136 if (daq_status == nullptr)
137 stmt->SetNull(6);
138 else
139 stmt->SetString(6, *daq_status);
140 if (sp_41 == nullptr)
141 stmt->SetNull(7);
142 else
143 stmt->SetInt(7, *sp_41);
144 if (sp_57 == nullptr)
145 stmt->SetNull(8);
146 else
147 stmt->SetInt(8, *sp_57);
148 if (vkm2 == nullptr)
149 stmt->SetNull(9);
150 else
151 stmt->SetInt(9, *vkm2);
152 stmt->SetString(10, beam);
153 if (energy == nullptr)
154 stmt->SetNull(11);
155 else
156 stmt->SetDouble(11, *energy);
157 stmt->SetString(12, target);
158 if (target_width == nullptr)
159 stmt->SetNull(13);
160 else
161 stmt->SetDouble(13, *target_width);
162 if (record_comment == nullptr)
163 stmt->SetNull(14);
164 else
165 stmt->SetString(14, *record_comment);
166 if (system_status_id == nullptr)
167 stmt->SetNull(15);
168 else
169 stmt->SetInt(15, *system_status_id);
170
171 // inserting new record to the Database
172 if (!stmt->Process()) {
173 cout << "ERROR: inserting new record to the Database has been failed" << endl;
174 delete stmt;
175 delete connDb;
176 return nullptr;
177 }
178
179 delete stmt;
180
181 // getting last inserted ID
182 int record_id;
183 TSQLStatement* stmt_last = db_server->Statement("SELECT currval(pg_get_serial_sequence('record_','record_id'))");
184
185 // process getting last id
186 if (stmt_last->Process()) {
187 // store result of statement in buffer
188 stmt_last->StoreResult();
189
190 // if there is no last id then exit with error
191 if (!stmt_last->NextResultRow()) {
192 cout << "ERROR: no last ID in DB!" << endl;
193 delete stmt_last;
194 return nullptr;
195 } else {
196 record_id = stmt_last->GetInt(0);
197 delete stmt_last;
198 }
199 } else {
200 cout << "ERROR: getting last ID has been failed!" << endl;
201 delete stmt_last;
202 return nullptr;
203 }
204
205 int tmp_record_id;
206 tmp_record_id = record_id;
207 TDatime tmp_record_date;
208 tmp_record_date = record_date;
209 TString* tmp_shift_leader_id;
210 if (shift_leader_id == nullptr)
211 tmp_shift_leader_id = nullptr;
212 else
213 tmp_shift_leader_id = new TString(*shift_leader_id);
214 int tmp_type_id;
215 tmp_type_id = type_id;
216 int* tmp_period_number;
217 if (period_number == nullptr)
218 tmp_period_number = nullptr;
219 else
220 tmp_period_number = new int(*period_number);
221 int* tmp_run_number;
222 if (run_number == nullptr)
223 tmp_run_number = nullptr;
224 else
225 tmp_run_number = new int(*run_number);
226 int* tmp_trigger_id;
227 if (trigger_id == nullptr)
228 tmp_trigger_id = nullptr;
229 else
230 tmp_trigger_id = new int(*trigger_id);
231 TString* tmp_daq_status;
232 if (daq_status == nullptr)
233 tmp_daq_status = nullptr;
234 else
235 tmp_daq_status = new TString(*daq_status);
236 int* tmp_sp_41;
237 if (sp_41 == nullptr)
238 tmp_sp_41 = nullptr;
239 else
240 tmp_sp_41 = new int(*sp_41);
241 int* tmp_sp_57;
242 if (sp_57 == nullptr)
243 tmp_sp_57 = nullptr;
244 else
245 tmp_sp_57 = new int(*sp_57);
246 int* tmp_vkm2;
247 if (vkm2 == nullptr)
248 tmp_vkm2 = nullptr;
249 else
250 tmp_vkm2 = new int(*vkm2);
251 TString tmp_beam;
252 tmp_beam = beam;
253 double* tmp_energy;
254 if (energy == nullptr)
255 tmp_energy = nullptr;
256 else
257 tmp_energy = new double(*energy);
258 TString tmp_target;
259 tmp_target = target;
260 double* tmp_target_width;
261 if (target_width == nullptr)
262 tmp_target_width = nullptr;
263 else
264 tmp_target_width = new double(*target_width);
265 TString* tmp_record_comment;
266 if (record_comment == nullptr)
267 tmp_record_comment = nullptr;
268 else
269 tmp_record_comment = new TString(*record_comment);
270 int* tmp_system_status_id;
271 if (system_status_id == nullptr)
272 tmp_system_status_id = nullptr;
273 else
274 tmp_system_status_id = new int(*system_status_id);
275
276 return new ElogRecord(connDb, tmp_record_id, tmp_record_date, tmp_shift_leader_id, tmp_type_id, tmp_period_number,
277 tmp_run_number, tmp_trigger_id, tmp_daq_status, tmp_sp_41, tmp_sp_57, tmp_vkm2, tmp_beam,
278 tmp_energy, tmp_target, tmp_target_width, tmp_record_comment, tmp_system_status_id);
279}
280
281// ----- Get record from the database ---------------------------
283{
285 if (connDb == nullptr)
286 return nullptr;
287
288 TSQLServer* db_server = connDb->GetSQLServer();
289
290 TString sql = TString::Format(
291 "select record_id, record_date, shift_leader_id, type_id, period_number, run_number, trigger_id, daq_status, "
292 "sp_41, sp_57, vkm2, beam, energy, target, target_width, record_comment, system_status_id "
293 "from record_ "
294 "where record_id = %d",
295 record_id);
296 TSQLStatement* stmt = db_server->Statement(sql);
297
298 // get record from the database
299 if (!stmt->Process()) {
300 cout << "ERROR: getting record from the database has been failed" << endl;
301
302 delete stmt;
303 delete connDb;
304 return nullptr;
305 }
306
307 // store result of statement in buffer
308 stmt->StoreResult();
309
310 // extract row
311 if (!stmt->NextResultRow()) {
312 cout << "ERROR: record was not found in the database" << endl;
313
314 delete stmt;
315 delete connDb;
316 return nullptr;
317 }
318
319 int tmp_record_id;
320 tmp_record_id = stmt->GetInt(0);
321 TDatime tmp_record_date;
322 tmp_record_date = stmt->GetDatime(1);
323 TString* tmp_shift_leader_id;
324 if (stmt->IsNull(2))
325 tmp_shift_leader_id = nullptr;
326 else
327 tmp_shift_leader_id = new TString(stmt->GetString(2));
328 int tmp_type_id;
329 tmp_type_id = stmt->GetInt(3);
330 int* tmp_period_number;
331 if (stmt->IsNull(4))
332 tmp_period_number = nullptr;
333 else
334 tmp_period_number = new int(stmt->GetInt(4));
335 int* tmp_run_number;
336 if (stmt->IsNull(5))
337 tmp_run_number = nullptr;
338 else
339 tmp_run_number = new int(stmt->GetInt(5));
340 int* tmp_trigger_id;
341 if (stmt->IsNull(6))
342 tmp_trigger_id = nullptr;
343 else
344 tmp_trigger_id = new int(stmt->GetInt(6));
345 TString* tmp_daq_status;
346 if (stmt->IsNull(7))
347 tmp_daq_status = nullptr;
348 else
349 tmp_daq_status = new TString(stmt->GetString(7));
350 int* tmp_sp_41;
351 if (stmt->IsNull(8))
352 tmp_sp_41 = nullptr;
353 else
354 tmp_sp_41 = new int(stmt->GetInt(8));
355 int* tmp_sp_57;
356 if (stmt->IsNull(9))
357 tmp_sp_57 = nullptr;
358 else
359 tmp_sp_57 = new int(stmt->GetInt(9));
360 int* tmp_vkm2;
361 if (stmt->IsNull(10))
362 tmp_vkm2 = nullptr;
363 else
364 tmp_vkm2 = new int(stmt->GetInt(10));
365 TString tmp_beam;
366 tmp_beam = stmt->GetString(11);
367 double* tmp_energy;
368 if (stmt->IsNull(12))
369 tmp_energy = nullptr;
370 else
371 tmp_energy = new double(stmt->GetDouble(12));
372 TString tmp_target;
373 tmp_target = stmt->GetString(13);
374 double* tmp_target_width;
375 if (stmt->IsNull(14))
376 tmp_target_width = nullptr;
377 else
378 tmp_target_width = new double(stmt->GetDouble(14));
379 TString* tmp_record_comment;
380 if (stmt->IsNull(15))
381 tmp_record_comment = nullptr;
382 else
383 tmp_record_comment = new TString(stmt->GetString(15));
384 int* tmp_system_status_id;
385 if (stmt->IsNull(16))
386 tmp_system_status_id = nullptr;
387 else
388 tmp_system_status_id = new int(stmt->GetInt(16));
389
390 delete stmt;
391
392 return new ElogRecord(connDb, tmp_record_id, tmp_record_date, tmp_shift_leader_id, tmp_type_id, tmp_period_number,
393 tmp_run_number, tmp_trigger_id, tmp_daq_status, tmp_sp_41, tmp_sp_57, tmp_vkm2, tmp_beam,
394 tmp_energy, tmp_target, tmp_target_width, tmp_record_comment, tmp_system_status_id);
395}
396
397// ----- Check record exists in the database ---------------------------
399{
401 if (connDb == nullptr)
402 return -1;
403
404 TSQLServer* db_server = connDb->GetSQLServer();
405
406 TString sql = TString::Format("select 1 "
407 "from record_ "
408 "where record_id = %d",
409 record_id);
410 TSQLStatement* stmt = db_server->Statement(sql);
411
412 // get record from the database
413 if (!stmt->Process()) {
414 cout << "ERROR: getting record from the database has been failed" << endl;
415
416 delete stmt;
417 delete connDb;
418 return -2;
419 }
420
421 // store result of statement in buffer
422 stmt->StoreResult();
423
424 // extract row
425 if (!stmt->NextResultRow()) {
426 delete stmt;
427 delete connDb;
428 return 0;
429 }
430
431 delete stmt;
432 delete connDb;
433
434 return 1;
435}
436
437// ----- Delete record from the database ---------------------------
438int ElogRecord::DeleteRecord(int record_id)
439{
441 if (connDb == nullptr)
442 return -1;
443
444 TSQLServer* db_server = connDb->GetSQLServer();
445
446 TString sql = TString::Format("delete from record_ "
447 "where record_id = $1");
448 TSQLStatement* stmt = db_server->Statement(sql);
449
450 stmt->NextIteration();
451 stmt->SetInt(0, record_id);
452
453 // delete record from the dataBase
454 if (!stmt->Process()) {
455 cout << "ERROR: deleting record from the dataBase has been failed" << endl;
456
457 delete stmt;
458 delete connDb;
459 return -2;
460 }
461
462 delete stmt;
463 delete connDb;
464 return 0;
465}
466
467// ----- Print all 'records' ---------------------------------
469{
471 if (connDb == nullptr)
472 return -1;
473
474 TSQLServer* db_server = connDb->GetSQLServer();
475
476 TString sql = TString::Format(
477 "select record_id, record_date, shift_leader_id, type_id, period_number, run_number, trigger_id, daq_status, "
478 "sp_41, sp_57, vkm2, beam, energy, target, target_width, record_comment, system_status_id "
479 "from record_");
480 TSQLStatement* stmt = db_server->Statement(sql);
481
482 // get all 'records' from the database
483 if (!stmt->Process()) {
484 cout << "ERROR: getting all 'records' from the dataBase has been failed" << endl;
485
486 delete stmt;
487 delete connDb;
488 return -2;
489 }
490
491 // store result of statement in buffer
492 stmt->StoreResult();
493
494 // print rows
495 cout << "Table 'record_':" << endl;
496 while (stmt->NextResultRow()) {
497 cout << "record_id: ";
498 cout << (stmt->GetInt(0));
499 cout << ", record_date: ";
500 cout << (stmt->GetDatime(1)).AsSQLString();
501 cout << ", shift_leader_id: ";
502 if (stmt->IsNull(2))
503 cout << "nullptr";
504 else
505 cout << stmt->GetString(2);
506 cout << ", type_id: ";
507 cout << (stmt->GetInt(3));
508 cout << ", period_number: ";
509 if (stmt->IsNull(4))
510 cout << "nullptr";
511 else
512 cout << stmt->GetInt(4);
513 cout << ", run_number: ";
514 if (stmt->IsNull(5))
515 cout << "nullptr";
516 else
517 cout << stmt->GetInt(5);
518 cout << ", trigger_id: ";
519 if (stmt->IsNull(6))
520 cout << "nullptr";
521 else
522 cout << stmt->GetInt(6);
523 cout << ", daq_status: ";
524 if (stmt->IsNull(7))
525 cout << "nullptr";
526 else
527 cout << stmt->GetString(7);
528 cout << ", sp_41: ";
529 if (stmt->IsNull(8))
530 cout << "nullptr";
531 else
532 cout << stmt->GetInt(8);
533 cout << ", sp_57: ";
534 if (stmt->IsNull(9))
535 cout << "nullptr";
536 else
537 cout << stmt->GetInt(9);
538 cout << ", vkm2: ";
539 if (stmt->IsNull(10))
540 cout << "nullptr";
541 else
542 cout << stmt->GetInt(10);
543 cout << ", beam: ";
544 cout << (stmt->GetString(11));
545 cout << ", energy: ";
546 if (stmt->IsNull(12))
547 cout << "nullptr";
548 else
549 cout << stmt->GetDouble(12);
550 cout << ", target: ";
551 cout << (stmt->GetString(13));
552 cout << ", target_width: ";
553 if (stmt->IsNull(14))
554 cout << "nullptr";
555 else
556 cout << stmt->GetDouble(14);
557 cout << ", record_comment: ";
558 if (stmt->IsNull(15))
559 cout << "nullptr";
560 else
561 cout << stmt->GetString(15);
562 cout << ", system_status_id: ";
563 if (stmt->IsNull(16))
564 cout << "nullptr";
565 else
566 cout << stmt->GetInt(16);
567 cout << "." << endl;
568 }
569
570 delete stmt;
571 delete connDb;
572
573 return 0;
574}
575
576// Setters functions
577int ElogRecord::SetRecordDate(TDatime record_date)
578{
579 if (!connectionDB) {
580 cout << "CRITICAL ERROR: Connection object is null" << endl;
581 return -1;
582 }
583
584 TSQLServer* db_server = connectionDB->GetSQLServer();
585
586 TString sql = TString::Format("update record_ "
587 "set record_date = $1 "
588 "where record_id = $2");
589 TSQLStatement* stmt = db_server->Statement(sql);
590
591 stmt->NextIteration();
592 stmt->SetDatime(0, record_date);
593 stmt->SetInt(1, i_record_id);
594
595 // write new value to the database
596 if (!stmt->Process()) {
597 cout << "ERROR: updating information about record has been failed" << endl;
598
599 delete stmt;
600 return -2;
601 }
602
603 dt_record_date = record_date;
604
605 delete stmt;
606 return 0;
607}
608
609int ElogRecord::SetShiftLeaderId(TString* shift_leader_id)
610{
611 if (!connectionDB) {
612 cout << "CRITICAL ERROR: Connection object is null" << endl;
613 return -1;
614 }
615
616 TSQLServer* db_server = connectionDB->GetSQLServer();
617
618 TString sql = TString::Format("update record_ "
619 "set shift_leader_id = $1 "
620 "where record_id = $2");
621 TSQLStatement* stmt = db_server->Statement(sql);
622
623 stmt->NextIteration();
624 if (shift_leader_id == nullptr)
625 stmt->SetNull(0);
626 else
627 stmt->SetString(0, *shift_leader_id);
628 stmt->SetInt(1, i_record_id);
629
630 // write new value to the database
631 if (!stmt->Process()) {
632 cout << "ERROR: updating information about record has been failed" << endl;
633
634 delete stmt;
635 return -2;
636 }
637
638 if (str_shift_leader_id)
639 delete str_shift_leader_id;
640 if (shift_leader_id == nullptr)
641 str_shift_leader_id = nullptr;
642 else
643 str_shift_leader_id = new TString(*shift_leader_id);
644
645 delete stmt;
646 return 0;
647}
648
649int ElogRecord::SetTypeId(int type_id)
650{
651 if (!connectionDB) {
652 cout << "CRITICAL ERROR: Connection object is null" << endl;
653 return -1;
654 }
655
656 TSQLServer* db_server = connectionDB->GetSQLServer();
657
658 TString sql = TString::Format("update record_ "
659 "set type_id = $1 "
660 "where record_id = $2");
661 TSQLStatement* stmt = db_server->Statement(sql);
662
663 stmt->NextIteration();
664 stmt->SetInt(0, type_id);
665 stmt->SetInt(1, i_record_id);
666
667 // write new value to the database
668 if (!stmt->Process()) {
669 cout << "ERROR: updating information about record has been failed" << endl;
670
671 delete stmt;
672 return -2;
673 }
674
675 i_type_id = type_id;
676
677 delete stmt;
678 return 0;
679}
680
681int ElogRecord::SetPeriodNumber(int* period_number)
682{
683 if (!connectionDB) {
684 cout << "CRITICAL ERROR: Connection object is null" << endl;
685 return -1;
686 }
687
688 TSQLServer* db_server = connectionDB->GetSQLServer();
689
690 TString sql = TString::Format("update record_ "
691 "set period_number = $1 "
692 "where record_id = $2");
693 TSQLStatement* stmt = db_server->Statement(sql);
694
695 stmt->NextIteration();
696 if (period_number == nullptr)
697 stmt->SetNull(0);
698 else
699 stmt->SetInt(0, *period_number);
700 stmt->SetInt(1, i_record_id);
701
702 // write new value to the database
703 if (!stmt->Process()) {
704 cout << "ERROR: updating information about record has been failed" << endl;
705
706 delete stmt;
707 return -2;
708 }
709
710 if (i_period_number)
711 delete i_period_number;
712 if (period_number == nullptr)
713 i_period_number = nullptr;
714 else
715 i_period_number = new int(*period_number);
716
717 delete stmt;
718 return 0;
719}
720
721int ElogRecord::SetRunNumber(int* run_number)
722{
723 if (!connectionDB) {
724 cout << "CRITICAL ERROR: Connection object is null" << endl;
725 return -1;
726 }
727
728 TSQLServer* db_server = connectionDB->GetSQLServer();
729
730 TString sql = TString::Format("update record_ "
731 "set run_number = $1 "
732 "where record_id = $2");
733 TSQLStatement* stmt = db_server->Statement(sql);
734
735 stmt->NextIteration();
736 if (run_number == nullptr)
737 stmt->SetNull(0);
738 else
739 stmt->SetInt(0, *run_number);
740 stmt->SetInt(1, i_record_id);
741
742 // write new value to the database
743 if (!stmt->Process()) {
744 cout << "ERROR: updating information about record has been failed" << endl;
745
746 delete stmt;
747 return -2;
748 }
749
750 if (i_run_number)
751 delete i_run_number;
752 if (run_number == nullptr)
753 i_run_number = nullptr;
754 else
755 i_run_number = new int(*run_number);
756
757 delete stmt;
758 return 0;
759}
760
761int ElogRecord::SetTriggerId(int* trigger_id)
762{
763 if (!connectionDB) {
764 cout << "CRITICAL ERROR: Connection object is null" << endl;
765 return -1;
766 }
767
768 TSQLServer* db_server = connectionDB->GetSQLServer();
769
770 TString sql = TString::Format("update record_ "
771 "set trigger_id = $1 "
772 "where record_id = $2");
773 TSQLStatement* stmt = db_server->Statement(sql);
774
775 stmt->NextIteration();
776 if (trigger_id == nullptr)
777 stmt->SetNull(0);
778 else
779 stmt->SetInt(0, *trigger_id);
780 stmt->SetInt(1, i_record_id);
781
782 // write new value to the database
783 if (!stmt->Process()) {
784 cout << "ERROR: updating information about record has been failed" << endl;
785
786 delete stmt;
787 return -2;
788 }
789
790 if (i_trigger_id)
791 delete i_trigger_id;
792 if (trigger_id == nullptr)
793 i_trigger_id = nullptr;
794 else
795 i_trigger_id = new int(*trigger_id);
796
797 delete stmt;
798 return 0;
799}
800
801int ElogRecord::SetDaqStatus(TString* daq_status)
802{
803 if (!connectionDB) {
804 cout << "CRITICAL ERROR: Connection object is null" << endl;
805 return -1;
806 }
807
808 TSQLServer* db_server = connectionDB->GetSQLServer();
809
810 TString sql = TString::Format("update record_ "
811 "set daq_status = $1 "
812 "where record_id = $2");
813 TSQLStatement* stmt = db_server->Statement(sql);
814
815 stmt->NextIteration();
816 if (daq_status == nullptr)
817 stmt->SetNull(0);
818 else
819 stmt->SetString(0, *daq_status);
820 stmt->SetInt(1, i_record_id);
821
822 // write new value to the database
823 if (!stmt->Process()) {
824 cout << "ERROR: updating information about record has been failed" << endl;
825
826 delete stmt;
827 return -2;
828 }
829
830 if (str_daq_status)
831 delete str_daq_status;
832 if (daq_status == nullptr)
833 str_daq_status = nullptr;
834 else
835 str_daq_status = new TString(*daq_status);
836
837 delete stmt;
838 return 0;
839}
840
841int ElogRecord::SetSp41(int* sp_41)
842{
843 if (!connectionDB) {
844 cout << "CRITICAL ERROR: Connection object is null" << endl;
845 return -1;
846 }
847
848 TSQLServer* db_server = connectionDB->GetSQLServer();
849
850 TString sql = TString::Format("update record_ "
851 "set sp_41 = $1 "
852 "where record_id = $2");
853 TSQLStatement* stmt = db_server->Statement(sql);
854
855 stmt->NextIteration();
856 if (sp_41 == nullptr)
857 stmt->SetNull(0);
858 else
859 stmt->SetInt(0, *sp_41);
860 stmt->SetInt(1, i_record_id);
861
862 // write new value to the database
863 if (!stmt->Process()) {
864 cout << "ERROR: updating information about record has been failed" << endl;
865
866 delete stmt;
867 return -2;
868 }
869
870 if (i_sp_41)
871 delete i_sp_41;
872 if (sp_41 == nullptr)
873 i_sp_41 = nullptr;
874 else
875 i_sp_41 = new int(*sp_41);
876
877 delete stmt;
878 return 0;
879}
880
881int ElogRecord::SetSp57(int* sp_57)
882{
883 if (!connectionDB) {
884 cout << "CRITICAL ERROR: Connection object is null" << endl;
885 return -1;
886 }
887
888 TSQLServer* db_server = connectionDB->GetSQLServer();
889
890 TString sql = TString::Format("update record_ "
891 "set sp_57 = $1 "
892 "where record_id = $2");
893 TSQLStatement* stmt = db_server->Statement(sql);
894
895 stmt->NextIteration();
896 if (sp_57 == nullptr)
897 stmt->SetNull(0);
898 else
899 stmt->SetInt(0, *sp_57);
900 stmt->SetInt(1, i_record_id);
901
902 // write new value to the database
903 if (!stmt->Process()) {
904 cout << "ERROR: updating information about record has been failed" << endl;
905
906 delete stmt;
907 return -2;
908 }
909
910 if (i_sp_57)
911 delete i_sp_57;
912 if (sp_57 == nullptr)
913 i_sp_57 = nullptr;
914 else
915 i_sp_57 = new int(*sp_57);
916
917 delete stmt;
918 return 0;
919}
920
922{
923 if (!connectionDB) {
924 cout << "CRITICAL ERROR: Connection object is null" << endl;
925 return -1;
926 }
927
928 TSQLServer* db_server = connectionDB->GetSQLServer();
929
930 TString sql = TString::Format("update record_ "
931 "set vkm2 = $1 "
932 "where record_id = $2");
933 TSQLStatement* stmt = db_server->Statement(sql);
934
935 stmt->NextIteration();
936 if (vkm2 == nullptr)
937 stmt->SetNull(0);
938 else
939 stmt->SetInt(0, *vkm2);
940 stmt->SetInt(1, i_record_id);
941
942 // write new value to the database
943 if (!stmt->Process()) {
944 cout << "ERROR: updating information about record has been failed" << endl;
945
946 delete stmt;
947 return -2;
948 }
949
950 if (i_vkm2)
951 delete i_vkm2;
952 if (vkm2 == nullptr)
953 i_vkm2 = nullptr;
954 else
955 i_vkm2 = new int(*vkm2);
956
957 delete stmt;
958 return 0;
959}
960
961int ElogRecord::SetBeam(TString beam)
962{
963 if (!connectionDB) {
964 cout << "CRITICAL ERROR: Connection object is null" << endl;
965 return -1;
966 }
967
968 TSQLServer* db_server = connectionDB->GetSQLServer();
969
970 TString sql = TString::Format("update record_ "
971 "set beam = $1 "
972 "where record_id = $2");
973 TSQLStatement* stmt = db_server->Statement(sql);
974
975 stmt->NextIteration();
976 stmt->SetString(0, beam);
977 stmt->SetInt(1, i_record_id);
978
979 // write new value to the database
980 if (!stmt->Process()) {
981 cout << "ERROR: updating information about record has been failed" << endl;
982
983 delete stmt;
984 return -2;
985 }
986
987 str_beam = beam;
988
989 delete stmt;
990 return 0;
991}
992
993int ElogRecord::SetEnergy(double* energy)
994{
995 if (!connectionDB) {
996 cout << "CRITICAL ERROR: Connection object is null" << endl;
997 return -1;
998 }
999
1000 TSQLServer* db_server = connectionDB->GetSQLServer();
1001
1002 TString sql = TString::Format("update record_ "
1003 "set energy = $1 "
1004 "where record_id = $2");
1005 TSQLStatement* stmt = db_server->Statement(sql);
1006
1007 stmt->NextIteration();
1008 if (energy == nullptr)
1009 stmt->SetNull(0);
1010 else
1011 stmt->SetDouble(0, *energy);
1012 stmt->SetInt(1, i_record_id);
1013
1014 // write new value to the database
1015 if (!stmt->Process()) {
1016 cout << "ERROR: updating information about record has been failed" << endl;
1017
1018 delete stmt;
1019 return -2;
1020 }
1021
1022 if (d_energy)
1023 delete d_energy;
1024 if (energy == nullptr)
1025 d_energy = nullptr;
1026 else
1027 d_energy = new double(*energy);
1028
1029 delete stmt;
1030 return 0;
1031}
1032
1033int ElogRecord::SetTarget(TString target)
1034{
1035 if (!connectionDB) {
1036 cout << "CRITICAL ERROR: Connection object is null" << endl;
1037 return -1;
1038 }
1039
1040 TSQLServer* db_server = connectionDB->GetSQLServer();
1041
1042 TString sql = TString::Format("update record_ "
1043 "set target = $1 "
1044 "where record_id = $2");
1045 TSQLStatement* stmt = db_server->Statement(sql);
1046
1047 stmt->NextIteration();
1048 stmt->SetString(0, target);
1049 stmt->SetInt(1, i_record_id);
1050
1051 // write new value to the database
1052 if (!stmt->Process()) {
1053 cout << "ERROR: updating information about record has been failed" << endl;
1054
1055 delete stmt;
1056 return -2;
1057 }
1058
1059 str_target = target;
1060
1061 delete stmt;
1062 return 0;
1063}
1064
1065int ElogRecord::SetTargetWidth(double* target_width)
1066{
1067 if (!connectionDB) {
1068 cout << "CRITICAL ERROR: Connection object is null" << endl;
1069 return -1;
1070 }
1071
1072 TSQLServer* db_server = connectionDB->GetSQLServer();
1073
1074 TString sql = TString::Format("update record_ "
1075 "set target_width = $1 "
1076 "where record_id = $2");
1077 TSQLStatement* stmt = db_server->Statement(sql);
1078
1079 stmt->NextIteration();
1080 if (target_width == nullptr)
1081 stmt->SetNull(0);
1082 else
1083 stmt->SetDouble(0, *target_width);
1084 stmt->SetInt(1, i_record_id);
1085
1086 // write new value to the database
1087 if (!stmt->Process()) {
1088 cout << "ERROR: updating information about record has been failed" << endl;
1089
1090 delete stmt;
1091 return -2;
1092 }
1093
1094 if (d_target_width)
1095 delete d_target_width;
1096 if (target_width == nullptr)
1097 d_target_width = nullptr;
1098 else
1099 d_target_width = new double(*target_width);
1100
1101 delete stmt;
1102 return 0;
1103}
1104
1105int ElogRecord::SetRecordComment(TString* record_comment)
1106{
1107 if (!connectionDB) {
1108 cout << "CRITICAL ERROR: Connection object is null" << endl;
1109 return -1;
1110 }
1111
1112 TSQLServer* db_server = connectionDB->GetSQLServer();
1113
1114 TString sql = TString::Format("update record_ "
1115 "set record_comment = $1 "
1116 "where record_id = $2");
1117 TSQLStatement* stmt = db_server->Statement(sql);
1118
1119 stmt->NextIteration();
1120 if (record_comment == nullptr)
1121 stmt->SetNull(0);
1122 else
1123 stmt->SetString(0, *record_comment);
1124 stmt->SetInt(1, i_record_id);
1125
1126 // write new value to the database
1127 if (!stmt->Process()) {
1128 cout << "ERROR: updating information about record has been failed" << endl;
1129
1130 delete stmt;
1131 return -2;
1132 }
1133
1134 if (str_record_comment)
1135 delete str_record_comment;
1136 if (record_comment == nullptr)
1137 str_record_comment = nullptr;
1138 else
1139 str_record_comment = new TString(*record_comment);
1140
1141 delete stmt;
1142 return 0;
1143}
1144
1145int ElogRecord::SetSystemStatusId(int* system_status_id)
1146{
1147 if (!connectionDB) {
1148 cout << "CRITICAL ERROR: Connection object is null" << endl;
1149 return -1;
1150 }
1151
1152 TSQLServer* db_server = connectionDB->GetSQLServer();
1153
1154 TString sql = TString::Format("update record_ "
1155 "set system_status_id = $1 "
1156 "where record_id = $2");
1157 TSQLStatement* stmt = db_server->Statement(sql);
1158
1159 stmt->NextIteration();
1160 if (system_status_id == nullptr)
1161 stmt->SetNull(0);
1162 else
1163 stmt->SetInt(0, *system_status_id);
1164 stmt->SetInt(1, i_record_id);
1165
1166 // write new value to the database
1167 if (!stmt->Process()) {
1168 cout << "ERROR: updating information about record has been failed" << endl;
1169
1170 delete stmt;
1171 return -2;
1172 }
1173
1174 if (i_system_status_id)
1175 delete i_system_status_id;
1176 if (system_status_id == nullptr)
1177 i_system_status_id = nullptr;
1178 else
1179 i_system_status_id = new int(*system_status_id);
1180
1181 delete stmt;
1182 return 0;
1183}
1184
1185// ----- Print current record ---------------------------------------
1187{
1188 cout << "Table 'record_'";
1189 cout << ". record_id: " << i_record_id << ". record_date: " << dt_record_date.AsSQLString() << ". shift_leader_id: "
1190 << (str_shift_leader_id == nullptr ? "nullptr" : TString::Format("%d", *str_shift_leader_id))
1191 << ". type_id: " << i_type_id
1192 << ". period_number: " << (i_period_number == nullptr ? "nullptr" : TString::Format("%d", *i_period_number))
1193 << ". run_number: " << (i_run_number == nullptr ? "nullptr" : TString::Format("%d", *i_run_number))
1194 << ". trigger_id: " << (i_trigger_id == nullptr ? "nullptr" : TString::Format("%d", *i_trigger_id))
1195 << ". daq_status: " << (str_daq_status == nullptr ? "nullptr" : *str_daq_status)
1196 << ". sp_41: " << (i_sp_41 == nullptr ? "nullptr" : TString::Format("%d", *i_sp_41))
1197 << ". sp_57: " << (i_sp_57 == nullptr ? "nullptr" : TString::Format("%d", *i_sp_57))
1198 << ". vkm2: " << (i_vkm2 == nullptr ? "nullptr" : TString::Format("%d", *i_vkm2)) << ". beam: " << str_beam
1199 << ". energy: " << (d_energy == nullptr ? "nullptr" : TString::Format("%f", *d_energy))
1200 << ". target: " << str_target
1201 << ". target_width: " << (d_target_width == nullptr ? "nullptr" : TString::Format("%f", *d_target_width))
1202 << ". record_comment: " << (str_record_comment == nullptr ? "nullptr" : *str_record_comment)
1203 << ". system_status_id: "
1204 << (i_system_status_id == nullptr ? "nullptr" : TString::Format("%d", *i_system_status_id)) << endl;
1205
1206 return;
1207}
1208/* END OF GENERATED CLASS PART (SHOULD NOT BE CHANGED MANUALLY) */
1209
1210// get array of ElogRecord-s for a given or a previous run from the database
1211TObjArray* ElogRecord::GetRecords(int period_number, int run_number, bool findPreviousRun)
1212{
1213 TObjArray* arrayResult = nullptr;
1214
1216 if (connDb == nullptr) {
1217 cout << "ERROR: connection to the eLog Database was failed" << endl;
1218 return arrayResult;
1219 }
1220
1221 TSQLServer* db_server = connDb->GetSQLServer();
1222
1223 TString sql = "";
1224 if (!findPreviousRun)
1225 sql = TString::Format(
1226 "select record_id, record_date, shift_leader_id, type_id, period_number, run_number, trigger_id, "
1227 "daq_status, sp_41, sp_57, vkm2, beam, energy, target, target_width, record_comment, system_status_id "
1228 "from record_ "
1229 "where period_number = %d and run_number = %d",
1230 period_number, run_number);
1231 else
1232 sql = TString::Format(
1233 "select record_id, record_date, shift_leader_id, type_id, period_number, run_number, trigger_id, "
1234 "daq_status, sp_41, sp_57, vkm2, beam, energy, target, target_width, record_comment, system_status_id "
1235 "from record_ "
1236 "where (period_number < %d) OR ((period_number = %d) AND (run_number < %d)) "
1237 "order by period_number desc, run_number desc "
1238 "limit 1",
1239 period_number, period_number, run_number);
1240 TSQLStatement* stmt = db_server->Statement(sql);
1241 // cout<<"SQL code: "<<sql<<endl;
1242
1243 // get record from the database
1244 if (!stmt->Process()) {
1245 cout << "ERROR: getting record from the database has been failed" << endl;
1246
1247 delete stmt;
1248 delete connDb;
1249
1250 return arrayResult;
1251 }
1252
1253 // store result of statement in buffer
1254 stmt->StoreResult();
1255
1256 // extract rows one after another
1257 arrayResult = new TObjArray();
1258 arrayResult->SetOwner(kTRUE);
1259 while (stmt->NextResultRow()) {
1260 ElogConnection* connRecord = ElogConnection::Open();
1261 if (connRecord == nullptr) {
1262 cout << "ERROR: connection to the eLog database for a record was failed" << endl;
1263 return arrayResult;
1264 }
1265
1266 int tmp_record_id;
1267 tmp_record_id = stmt->GetInt(0);
1268 TDatime tmp_record_date;
1269 tmp_record_date = stmt->GetDatime(1);
1270 TString* tmp_shift_leader_id;
1271 if (stmt->IsNull(2))
1272 tmp_shift_leader_id = nullptr;
1273 else
1274 tmp_shift_leader_id = new TString(stmt->GetString(2));
1275 int tmp_type_id;
1276 tmp_type_id = stmt->GetInt(3);
1277 int* tmp_period_number;
1278 if (stmt->IsNull(4))
1279 tmp_period_number = nullptr;
1280 else
1281 tmp_period_number = new int(stmt->GetInt(4));
1282 int* tmp_run_number;
1283 if (stmt->IsNull(5))
1284 tmp_run_number = nullptr;
1285 else
1286 tmp_run_number = new int(stmt->GetInt(5));
1287 int* tmp_trigger_id;
1288 if (stmt->IsNull(6))
1289 tmp_trigger_id = nullptr;
1290 else
1291 tmp_trigger_id = new int(stmt->GetInt(6));
1292 TString* tmp_daq_status;
1293 if (stmt->IsNull(7))
1294 tmp_daq_status = nullptr;
1295 else
1296 tmp_daq_status = new TString(stmt->GetString(7));
1297 int* tmp_sp_41;
1298 if (stmt->IsNull(8))
1299 tmp_sp_41 = nullptr;
1300 else
1301 tmp_sp_41 = new int(stmt->GetInt(8));
1302 int* tmp_sp_57;
1303 if (stmt->IsNull(9))
1304 tmp_sp_57 = nullptr;
1305 else
1306 tmp_sp_57 = new int(stmt->GetInt(9));
1307 int* tmp_vkm2;
1308 if (stmt->IsNull(10))
1309 tmp_vkm2 = nullptr;
1310 else
1311 tmp_vkm2 = new int(stmt->GetInt(10));
1312 TString tmp_beam;
1313 tmp_beam = stmt->GetString(11);
1314 double* tmp_energy;
1315 if (stmt->IsNull(12))
1316 tmp_energy = nullptr;
1317 else
1318 tmp_energy = new double(stmt->GetDouble(12));
1319 TString tmp_target;
1320 tmp_target = stmt->GetString(13);
1321 double* tmp_target_width;
1322 if (stmt->IsNull(14))
1323 tmp_target_width = nullptr;
1324 else
1325 tmp_target_width = new double(stmt->GetDouble(14));
1326 TString* tmp_record_comment;
1327 if (stmt->IsNull(15))
1328 tmp_record_comment = nullptr;
1329 else
1330 tmp_record_comment = new TString(stmt->GetString(15));
1331 int* tmp_system_status_id;
1332 if (stmt->IsNull(16))
1333 tmp_system_status_id = nullptr;
1334 else
1335 tmp_system_status_id = new int(stmt->GetInt(16));
1336
1337 arrayResult->Add((TObject*)new ElogRecord(
1338 connDb, tmp_record_id, tmp_record_date, tmp_shift_leader_id, tmp_type_id, tmp_period_number, tmp_run_number,
1339 tmp_trigger_id, tmp_daq_status, tmp_sp_41, tmp_sp_57, tmp_vkm2, tmp_beam, tmp_energy, tmp_target,
1340 tmp_target_width, tmp_record_comment, tmp_system_status_id));
1341 }
1342
1343 delete stmt;
1344
1345 return arrayResult;
1346}
1347
1348TObjArray* ElogRecord::Search(const TObjArray& search_conditions)
1349{
1350 TObjArray* arrayResult = nullptr;
1351
1353 if (connDb == nullptr) {
1354 cout << "ERROR: connection to the eLog Database was failed" << endl;
1355 return arrayResult;
1356 }
1357
1358 TSQLServer* db_server = connDb->GetSQLServer();
1359
1360 TString sql = TString::Format(
1361 "select record_id, record_date, shift_leader_id, r.type_id, period_number, run_number, r.trigger_id, "
1362 "daq_status, sp_41, sp_57, vkm2, beam, energy, target, target_width, record_comment, system_status_id "
1363 "from record_ r left join person_ p on r.shift_leader_id = p.person_id "
1364 "left join type_ t on r.type_id = t.type_id "
1365 "left join trigger_ tr on r.trigger_id = tr.trigger_id");
1366
1367 TString strCondition;
1368 bool isFirst = true;
1369 TIter next(&search_conditions);
1370 ElogSearchCondition* curCondition;
1371 while ((curCondition = (ElogSearchCondition*)next()) != nullptr) {
1372 strCondition = "";
1373
1374 switch (curCondition->GetColumn()) {
1376 strCondition += "record_date ";
1377 break;
1379 strCondition += "lower(person_name) ";
1380 break;
1382 strCondition += "lower(type_text) ";
1383 break;
1385 strCondition += "run_number ";
1386 break;
1388 strCondition += "period_number ";
1389 break;
1391 strCondition += "lower(trigger_info) ";
1392 break;
1394 strCondition += "lower(daq_status) ";
1395 break;
1397 strCondition += "sp_41 ";
1398 break;
1400 strCondition += "sp_57 ";
1401 break;
1403 strCondition += "vkm2 ";
1404 break;
1406 strCondition += "lower(beam) ";
1407 break;
1409 strCondition += "energy ";
1410 break;
1412 strCondition += "lower(target) ";
1413 break;
1414 default:
1415 cout << "ERROR: column in the search condition was not defined, condition is skipped" << endl;
1416 continue;
1417 }
1418
1419 switch (curCondition->GetCondition()) {
1421 strCondition += "< ";
1422 break;
1424 strCondition += "<= ";
1425 break;
1427 strCondition += "= ";
1428 break;
1430 strCondition += "<> ";
1431 break;
1433 strCondition += "> ";
1434 break;
1436 strCondition += ">= ";
1437 break;
1439 strCondition += "like ";
1440 break;
1442 strCondition += "is null ";
1443 break;
1445 strCondition += "is not null ";
1446 break;
1447 default:
1448 cout << "ERROR: comparison operator in the search condition was not defined, condition is skipped"
1449 << endl;
1450 continue;
1451 }
1452
1453 switch (curCondition->GetValueType()) {
1454 case 0:
1455 if ((curCondition->GetCondition() != ElogSearchCondition::conditionNull)
1457 continue;
1458 break;
1459 case 1:
1460 strCondition += Form("%d", curCondition->GetIntValue());
1461 break;
1462 case 2:
1463 strCondition += Form("%u", curCondition->GetUIntValue());
1464 break;
1465 case 3:
1466 strCondition += Form("%f", curCondition->GetDoubleValue());
1467 break;
1468 case 4:
1469 strCondition += Form("lower('%s')", curCondition->GetStringValue().Data());
1470 break;
1471 case 5:
1472 strCondition += Form("'%s'", curCondition->GetDatimeValue().AsSQLString());
1473 break;
1474 default:
1475 cout << "ERROR: value type in the search condition was not found, condition is skipped" << endl;
1476 continue;
1477 }
1478
1479 if (isFirst) {
1480 sql += " where ";
1481 isFirst = false;
1482 } else
1483 sql += " and ";
1484
1485 sql += strCondition;
1486 }
1487 sql += " order by record_date";
1488
1489 TSQLStatement* stmt = db_server->Statement(sql);
1490 // cout<<"SQL code: "<<sql<<endl;
1491
1492 // get table record from DB
1493 if (!stmt->Process()) {
1494 cout << "ERROR: getting eLog records from the database has been failed" << endl;
1495 delete stmt;
1496 delete connDb;
1497
1498 return arrayResult;
1499 }
1500
1501 // store result of statement in buffer
1502 stmt->StoreResult();
1503
1504 // extract rows one after another
1505 arrayResult = new TObjArray();
1506 arrayResult->SetOwner(kTRUE);
1507 while (stmt->NextResultRow()) {
1509 if (connRun == nullptr) {
1510 cout << "ERROR: connection to the eLog database for a record was failed" << endl;
1511 return arrayResult;
1512 }
1513
1514 int tmp_record_id;
1515 tmp_record_id = stmt->GetInt(0);
1516 TDatime tmp_record_date;
1517 tmp_record_date = stmt->GetDatime(1);
1518 TString* tmp_shift_leader_id;
1519 if (stmt->IsNull(2))
1520 tmp_shift_leader_id = nullptr;
1521 else
1522 tmp_shift_leader_id = new TString(stmt->GetString(2));
1523 int tmp_type_id;
1524 tmp_type_id = stmt->GetInt(3);
1525 int* tmp_period_number;
1526 if (stmt->IsNull(4))
1527 tmp_period_number = nullptr;
1528 else
1529 tmp_period_number = new int(stmt->GetInt(4));
1530 int* tmp_run_number;
1531 if (stmt->IsNull(5))
1532 tmp_run_number = nullptr;
1533 else
1534 tmp_run_number = new int(stmt->GetInt(5));
1535 int* tmp_trigger_id;
1536 if (stmt->IsNull(6))
1537 tmp_trigger_id = nullptr;
1538 else
1539 tmp_trigger_id = new int(stmt->GetInt(6));
1540 TString* tmp_daq_status;
1541 if (stmt->IsNull(7))
1542 tmp_daq_status = nullptr;
1543 else
1544 tmp_daq_status = new TString(stmt->GetString(7));
1545 int* tmp_sp_41;
1546 if (stmt->IsNull(8))
1547 tmp_sp_41 = nullptr;
1548 else
1549 tmp_sp_41 = new int(stmt->GetInt(8));
1550 int* tmp_sp_57;
1551 if (stmt->IsNull(9))
1552 tmp_sp_57 = nullptr;
1553 else
1554 tmp_sp_57 = new int(stmt->GetInt(9));
1555 int* tmp_vkm2;
1556 if (stmt->IsNull(10))
1557 tmp_vkm2 = nullptr;
1558 else
1559 tmp_vkm2 = new int(stmt->GetInt(10));
1560 TString tmp_beam;
1561 tmp_beam = stmt->GetString(11);
1562 double* tmp_energy;
1563 if (stmt->IsNull(12))
1564 tmp_energy = nullptr;
1565 else
1566 tmp_energy = new double(stmt->GetDouble(12));
1567 TString tmp_target;
1568 tmp_target = stmt->GetString(13);
1569 double* tmp_target_width;
1570 if (stmt->IsNull(14))
1571 tmp_target_width = nullptr;
1572 else
1573 tmp_target_width = new double(stmt->GetDouble(14));
1574 TString* tmp_record_comment;
1575 if (stmt->IsNull(15))
1576 tmp_record_comment = nullptr;
1577 else
1578 tmp_record_comment = new TString(stmt->GetString(15));
1579 int* tmp_system_status_id;
1580 if (stmt->IsNull(16))
1581 tmp_system_status_id = nullptr;
1582 else
1583 tmp_system_status_id = new int(stmt->GetInt(16));
1584
1585 arrayResult->Add((TObject*)new ElogRecord(
1586 connDb, tmp_record_id, tmp_record_date, tmp_shift_leader_id, tmp_type_id, tmp_period_number, tmp_run_number,
1587 tmp_trigger_id, tmp_daq_status, tmp_sp_41, tmp_sp_57, tmp_vkm2, tmp_beam, tmp_energy, tmp_target,
1588 tmp_target_width, tmp_record_comment, tmp_system_status_id));
1589 }
1590
1591 delete stmt;
1592
1593 return arrayResult;
1594}
1595
1596TObjArray* ElogRecord::Search(const ElogSearchCondition& search_condition)
1597{
1598 TObjArray search_conditions;
1599 search_conditions.Add((TObject*)&search_condition);
1600
1601 return Search(search_conditions);
1602}
static ElogConnection * Open()
TSQLServer * GetSQLServer()
virtual ~ElogRecord()
int SetShiftLeaderId(TString *shift_leader_id)
set shift leader id of the current record
int SetSystemStatusId(int *system_status_id)
set system status id of the current record
int SetTypeId(int type_id)
set type id of the current record
int SetVkm2(int *vkm2)
set vkm2 of the current record
static int PrintAll()
print all records
int SetRunNumber(int *run_number)
set run number of the current record
int SetTarget(TString target)
set target of the current record
int SetPeriodNumber(int *period_number)
set period number of the current record
int SetDaqStatus(TString *daq_status)
set daq status of the current record
int SetTriggerId(int *trigger_id)
set trigger id of the current record
static TObjArray * GetRecords(int period_number, int run_number, bool findPreviousRun=false)
get array of ElogRecord-s for a given or a previous run from the database
int SetTargetWidth(double *target_width)
set target width of the current record
int SetSp57(int *sp_57)
set sp 57 of the current record
int SetRecordComment(TString *record_comment)
set record comment of the current record
static int DeleteRecord(int record_id)
delete record from the database
int SetSp41(int *sp_41)
set sp 41 of the current record
int SetBeam(TString beam)
set beam of the current record
int SetEnergy(double *energy)
set energy of the current record
static ElogRecord * GetRecord(int record_id)
get record from the database
static TObjArray * Search(const ElogSearchCondition &search_condition)
get ELOG records corresponding to the specified single condition
static int CheckRecordExists(int record_id)
check record exists in the database: 1- true, 0 - false, <0 - database operation error
void Print()
print information about current record
static ElogRecord * CreateRecord(TDatime record_date, TString *shift_leader_id, int type_id, int *period_number, int *run_number, int *trigger_id, TString *daq_status, int *sp_41, int *sp_57, int *vkm2, TString beam, double *energy, TString target, double *target_width, TString *record_comment, int *system_status_id)
add new record to the database
int SetRecordDate(TDatime record_date)
set record date of the current record
enumConditions GetCondition()
unsigned int GetUIntValue()
STL namespace.