CGEM BOSS 6.6.5.h
BESIII Offline Software System
Loading...
Searching...
No Matches
Metadata.cxx
Go to the documentation of this file.
1// $Header: /bes/bes/BossCvs/Calibration/calibUtil/src/Metadata.cxx,v 1.38 2012/05/10 04:04:10 maqm Exp $
2
3/*
4#ifdef WIN32
5#include <windows.h>
6#endif
7*/
8
10#include "facilities/Util.h"
14#include "GaudiKernel/Bootstrap.h"
15#include "GaudiKernel/ISvcLocator.h"
16
17
18
21#include "rdbModel/Rdb.h"
26#include <iostream>
27#include <cstdio>
28#include <mysql.h>
29#include "TTree.h"
30#include "TBuffer.h"
31
32
33namespace calibUtil {
34
35 // Might be getting rid of this
36 // const unsigned int Metadata::s_rowReady = Metadata::eOpened
37 // | Metadata::eValid | Metadata::eInputDesc | Metadata::eComment;
38
39 Metadata::Metadata(const std::string& host, const std::string& table,
40 const std::string& dbName)
41 : m_readCxt(0), m_writeCxt(0), // m_row(""), m_rowStatus(0),
42 m_host(host), m_table(table), m_dbName(dbName), m_man(0), m_rdb(0),
43 m_match(false) {
44 if (table.compare("*") == 0) m_table = std::string("$(MYSQL_METATABLE)");
45 if (host.compare("*") == 0) m_host = std::string("$(MYSQL_HOST)");
46
47 int nsub = facilities::Util::expandEnvVar(&m_table);
48 // If this doesn't work, use default
49 if (nsub < 0) m_table = std::string("metadata");
50 StatusCode sc=Gaudi::svcLocator()->service("DatabaseSvc", m_dbsvc, true);
51 if ( !sc.isSuccess() ) {
52 std::cout <<"Metadata ERROR ::Could not retrieve the DataBaseSvc" << std::endl;;
53 exit(1);
54 }
55 }
56
60 if (m_man) delete m_man;
61 }
62
63
64 Metadata::eRet Metadata::fetchUser(std::string& user) {
65 // WARNING: Windows and Linux/Solaris use different standard variables
66 // for login name. The test used below isn't quite right
67 // since one could conceivably compile with gcc on cygwin/Windows.
68#ifdef __GNUG__
69 user = std::string("$(USER)");
70#else
71 user = std::string("$(USERNAME)");
72#endif
73
74 int nsub = facilities::Util::expandEnvVar(&user);
75 if (nsub == 1) {
76 return RETOk;
77 }
78 else {
79 user = std::string("");
80 return RETBadValue;
81 }
82 }
83
84 // The next 5 methods concern connection to the server
85 bool Metadata::connect(rdbModel::Connection* cxt, std::string& host,
86 const std::string& user,
87 const std::string& pw, eRet& err,
88 const std::string& dbName) {
89
90 int nSub = facilities::Util::expandEnvVar(&host);
91 if (nSub < 0) {
92 err = RETBadHost;
93 return false;
94 }
95
96 bool connected = cxt->open(host, user, pw, dbName);
97 if (connected) {
98 err = RETOk;
99 return true;
100 }
101 else {
102 err = RETNoConnect;
103 return false;
104 }
105 }
106
108 if (m_readCxt == 0) {
109 // for now use std::cout, std::cerr
110 m_readCxt = new rdbModel::MysqlConnection();
111 // bool ok = connect(m_readCxt, m_host, std::string("maqm"),
112 // std::string("maqm_offline"), err, m_dbName);
113 bool ok = connect(m_readCxt, m_host, std::string("guest"),
114 std::string("guestpass"), err, m_dbName);
115 if (!ok) {
116 delete m_readCxt;
117 m_readCxt = 0;
118 } /* else { // look for compatible schema
119 std::string schema =
120 std::string("$(RDBMODELROOT)/xml/")+ m_dbName + ".xml";
121 err = compareSchema(m_readCxt, schema);
122 }*/
123 return ok;
124 }
125
126 else return true;
127 }
128
129 bool Metadata::connectWrite(eRet& err) {
130 if (m_writeCxt == 0) {
131 m_writeCxt = new rdbModel::MysqlConnection();
132 bool ok;
133 if (m_dbName == std::string("calib_test") ) {
134 ok = connect(m_writeCxt, m_host, std::string("calib_tester"),
135 std::string("udine"), err, m_dbName);
136 }
137 else {
138 ok = connect(m_writeCxt, m_host, std::string("calibrator"),
139 std::string("calibrator"), err, m_dbName);
140 }
141 if (!ok) {
142 delete m_readCxt;
143 m_readCxt = 0;
144 } else { // look for compatible schema
145 std::string schema =
146 std::string("$(RDBMODELROOT)/xml/")+ m_dbName + ".xml";
147 err = compareSchema(m_writeCxt, schema);
148 }
149
150 return ok;
151 }
152 else return true;
153 }
154
156 if (m_readCxt) {
157 m_readCxt->close();
158 delete m_readCxt;
159 m_readCxt = 0;
160 }
161 }
162
164 if (m_writeCxt) {
165 m_writeCxt->close();
166 delete m_writeCxt;
167 m_writeCxt = 0;
168 }
169 }
170
172 Metadata::findSoonAfter(unsigned int *ser,
173 const std::string& calibType,
174 const std::string& SftVer,
175 const std::string& cal_ver,
176 const std::string& cal_par,
177 const std::string& rec_alg,
178 const std::string& rec_par,
179 const std::string& machine,
180 const std::string& flavor) {
181 using namespace rdbModel;
182
183 eRet ret;
184 *ser = 0;
185 if (!m_readCxt) {
186 connectRead(ret);
187 if (ret != RETOk) return ret;
188 }
189
190 StringVector orderBy;
191
192 std::vector<Assertion::Operator *> conditions;
193 conditions.reserve(8);
194
195 Assertion::Operator completeOp(OPTYPEequal, "status", "OK",
196 FIELDTYPEold, FIELDTYPElit);
197 // false, true);
198 Assertion::Operator calibTypeOp(OPTYPEequal, "calib_type", calibType,
199 FIELDTYPEold, FIELDTYPElit);
200 // false, true);
201 // Assertion::Operator flavorOp(OPTYPEequal, "flavor", flavor,
202 // FIELDTYPEold, FIELDTYPElit);
203 //false, true);
204 Assertion::Operator sftverOp(OPTYPEequal, "SftVer",SftVer,
205 FIELDTYPEold, FIELDTYPElit);
206 Assertion::Operator calverOp(OPTYPEequal, "cal_ver",cal_ver,
207 FIELDTYPEold, FIELDTYPElit);
208 Assertion::Operator calparOp(OPTYPEequal, "cal_par",cal_par,
209 FIELDTYPEold, FIELDTYPElit);
210 Assertion::Operator recalgOp(OPTYPEequal, "rec_alg",rec_alg,
211 FIELDTYPEold, FIELDTYPElit);
212 Assertion::Operator recparOp(OPTYPEequal, "rec_par",rec_par,
213 FIELDTYPEold, FIELDTYPElit);
214 Assertion::Operator machineOp(OPTYPEequal, "machine",machine,
215 FIELDTYPEold, FIELDTYPElit);
216
217 int run=10005;
218 std::string s_run;
219 std::cout<<"run no is::"<<s_run<<std::endl;
220 facilities::Util::itoa(run,s_run);
221 Assertion::Operator runfrmOp(OPTYPElessOrEqual,"RunFrom",s_run,
222 FIELDTYPEold, FIELDTYPElit);
223
224 Assertion::Operator runtoOp(OPTYPEgreaterOrEqual,"RunTo",s_run,
225 FIELDTYPEold, FIELDTYPElit);
226
227 conditions.push_back(&completeOp);
228 conditions.push_back(&calibTypeOp);
229 // conditions.push_back(&flavorOp);
230 conditions.push_back(&sftverOp);
231 conditions.push_back(&calverOp);
232 conditions.push_back(&calparOp);
233 conditions.push_back(&recalgOp);
234 conditions.push_back(&recparOp);
235 conditions.push_back(&machineOp);
236 conditions.push_back(&runfrmOp);
237 conditions.push_back(&runtoOp);
238 ret = doSelect(conditions, orderBy, ser);
239
240 return ret;
241 }
242
244 const std::string& calibType,
245 const std::string& SftVer,
246 const std::string& cal_ver,
247 const std::string& cal_par,
248 const std::string& rec_alg,
249 const std::string& rec_par,
250 const std::string& machine,
251 const std::string& flavor)
252 {
253 using namespace rdbModel;
254
255 eRet ret;
256 *ser = 0;
257 if (!m_readCxt) {
258 connectRead(ret);
259 if (ret != RETOk) return ret;
260 }
261
262 // Sort rows by timestamp. Would like most recent first
263 StringVector orderBy;
264
265 std::vector<Assertion::Operator *> conditions;
266 conditions.reserve(8);
267 Assertion::Operator completeOp(OPTYPEequal, "status", "OK",
268 FIELDTYPEold, FIELDTYPElit);
269 // false, true);
270
271 Assertion::Operator calibTypeOp(OPTYPEequal, "calib_type", calibType,
272 FIELDTYPEold, FIELDTYPElit);
273 // false, true);
274 // Assertion::Operator flavorOp(OPTYPEequal, "flavor", flavor,
275 // FIELDTYPEold, FIELDTYPElit);
276 // false, true);
277 Assertion::Operator sftverOp(OPTYPEequal, "SftVer",SftVer,
278 FIELDTYPEold, FIELDTYPElit);
279 Assertion::Operator calverOp(OPTYPEequal, "cal_ver",cal_ver,
280 FIELDTYPEold, FIELDTYPElit);
281 Assertion::Operator calparOp(OPTYPEequal, "cal_par",cal_par,
282 FIELDTYPEold, FIELDTYPElit);
283 Assertion::Operator recalgOp(OPTYPEequal, "rec_alg",rec_alg,
284 FIELDTYPEold, FIELDTYPElit);
285 Assertion::Operator recparOp(OPTYPEequal, "rec_par",rec_par,
286 FIELDTYPEold, FIELDTYPElit);
287 Assertion::Operator machineOp(OPTYPEequal, "machine",machine,
288 FIELDTYPEold, FIELDTYPElit);
289 int run=10005;
290 std::string s_run;
291 facilities::Util::itoa(run,s_run);
292 Assertion::Operator runfrmOp(OPTYPElessOrEqual,"RunFrom",s_run,
293 FIELDTYPEold, FIELDTYPElit);
294
295 Assertion::Operator runtoOp(OPTYPEgreaterOrEqual,"RunTo",s_run,
296 FIELDTYPEold, FIELDTYPElit);
297
298 conditions.push_back(&completeOp);
299 conditions.push_back(&calibTypeOp);
300 // conditions.push_back(&flavorOp);
301 conditions.push_back(&sftverOp);
302 conditions.push_back(&calverOp);
303 conditions.push_back(&calparOp);
304 conditions.push_back(&recalgOp);
305 conditions.push_back(&recparOp);
306 conditions.push_back(&machineOp);
307 conditions.push_back(&runfrmOp);
308 conditions.push_back(&runtoOp);
309 // Finally, set a value for PROC_LEVEL and make the query (ies)
310 return doSelect(conditions, orderBy, ser);
311 }
312
313
314 Metadata::eRet Metadata::getReadInfo(unsigned int serialNo,
315 int *runFrm,
316 int *runTo,
317 std::string& dataFmt,
318 std::string& filename) {
319 using namespace rdbModel;
320 eRet ret;
321 if (!m_readCxt) {
322 connectRead(ret);
323 if (ret != RETOk) {
324 return ret;
325 }
326 }
327 StringVector colNames(4);
328 colNames[0] = "data_fmt";
329 colNames[1] = "data_ident";
330 colNames[2] = "RunFrom";
331 colNames[3] = "RunTo";
332
333 std::string serNoVal;
334 facilities::Util::itoa(serialNo, serNoVal);
335 Assertion::Operator* serOp =
336 new Assertion::Operator(OPTYPEequal, "ser_no", serNoVal,
337 FIELDTYPEold, FIELDTYPElit);
338 //false, true);
339 Assertion whereClause(serOp);
340 StringVector orderBy;
341 orderBy.clear();
342
343 // make the query
344 ResultHandle* results = 0;
345 try {
346
347 results = m_readCxt->select(m_table, colNames, orderBy, &whereClause);
348
349 }
350 catch (RdbException ex) {
351 std::cout << ex.getMsg();
352 return RETMySQLError;
353 }
354
355 if (!results) return RETMySQLError;
356 if (!results->getNRows() ) return RETBadValue;
357
358 std::vector<std::string> fields;
359 std::cout<<"test id \\"<<std::endl;
360 results->getRow(fields);
361 dataFmt = fields[0];
362 filename = fields[1];
363 std::string runfrm,runto;
364 runfrm=fields[2];
365 runto=fields[3];
366 *runFrm=facilities::Util::atoi(runfrm);
367 *runTo=facilities::Util::atoi(runto);
368 delete results;
369 //runFrm=fields[2];
370 //runTo=fields[3];
371 // std::cout<<"runfrm is:"<<runFrm<<"runto is:"<<runTo<<std::endl;
372 if ((dataFmt == "") || (filename == "")) return RETBadValue;
373 return RETOk;
374 }
375
377 int *runFrm,
378 int *runTo,
379 std::string& calParVer,
381 int runNo,
382 std::string& sftver) {
383 using namespace rdbModel;
384 eRet ret;
385 char stmt1[300];
386 int run_No =runNo;
387 if(sftver=="default")
388 sftver = getenv("BES_RELEASE");
389 const char* SftVer = sftver.c_str();
390
391 if(calParVer!="default"){
392 const char* calpar = calParVer.c_str();
393 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
394 }
395 if(calParVer=="default"){
396 // sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,max(CalParVer),FileName,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
397 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
398 }
399
400 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
401 if(row_no<1){
402 std::cout<<"ERROR:error searching TOF calibration Data in the database with: "<<stmt1<<std::endl;
403 return RETMySQLError;
404 }
405
406 return RETOk;
407 }
408
410 int *runFrm,
411 int *runTo,
412 std::string& calParVer,
414 int runNo,
415 std::string& sftver) {
416 using namespace rdbModel;
417 eRet ret;
418 char stmt1[300];
419 int run_No =runNo;
420 //char* SftVer = getenv("BES_RELEASE");
421 if(sftver=="default")
422 sftver = getenv("BES_RELEASE");
423 const char* SftVer = sftver.c_str();
424
425 if(calParVer!="default"){
426 const char* calpar = calParVer.c_str();
427 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
428 }
429
430 if(calParVer=="default"){
431 // sprintf(stmt1,"select SftVer,LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,max(CalParVer),FileName from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
432 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
433
434 }
435
436 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
437 if(row_no<1){
438 std::cout<<"ERROR:error searching MUC calibration Data in the database with: "<<stmt1<<std::endl;
439 return RETMySQLError;
440 }
441
442
443 return RETOk;
444 }
445
447 int *runFrm,
448 int *runTo,
449 std::string& calParVer,
451 int runNo,
452 std::string& sftver) {
453 using namespace rdbModel;
454 eRet ret;
455 char stmt1[200];
456 int run_No =runNo;
457
458 if(sftver=="default")
459 sftver = getenv("BES_RELEASE");
460 const char* SftVer = sftver.c_str();
461
462
463 if(calParVer!="default"){
464 const char* calpar = calParVer.c_str();
465 sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = '%s'",SftVer,run_No,run_No,calpar);}
466
467 if(calParVer=="default"){
468 //sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,max(CalParVer),FileName from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);}
469 sprintf(stmt1,"select NewXtTrees,XtTree,QtTree,T0Tree,SdTree,R2tTrees,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);}
470
471 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
472 if(row_no<1){
473 std::cout<<"ERROR:error searching Mdc calibration Data in the database with: "<<stmt1<<std::endl;
474 return RETMySQLError;
475 }
476
477
478 return RETOk;
479}
480
481
482
484 int *runFrm,
485 int *runTo,
486 std::string& calParVer,
488 int runNo,
489 std::string& sftver) {
490 using namespace rdbModel;
491 eRet ret;
492 char stmt1[300];
493 int run_No =runNo;
494 if(sftver=="default")
495 sftver = getenv("BES_RELEASE");
496 const char* SftVer = sftver.c_str();
497
498 if(calParVer!="default"){
499 const char* calpar = calParVer.c_str();
500 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
501 }
502
503 if(calParVer=="default"){
504 //sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,max(CalParVer),FileName from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
505 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
506 }
507
508 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
509 if(row_no<1){
510 std::cout<<"ERROR:error searching EMC calibration Data in the database with: "<<stmt1<<std::endl;
511 return RETMySQLError;
512 }
513 return RETOk;
514}
515
516
518 int *runFrm,
519 int *runTo,
520 std::string& calParVer,
522 int runNo,
523 std::string& sftver) {
524 using namespace rdbModel;
525 eRet ret;
526 char stmt1[400];
527 int run_No =runNo;
528 if(sftver=="default")
529 sftver = getenv("BES_RELEASE");
530 const char* SftVer = sftver.c_str();
531
532 if(calParVer!="default"){
533 const char* calpar = calParVer.c_str();
534 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
535
536 }
537 if(calParVer=="default"){
538 // sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,max(CalParVer),FileName from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
539 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
540 }
541
542 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
543 if(row_no<1){
544 std::cout<<"ERROR:error searching Dedx calibration Data in the database with: "<<stmt1<<std::endl;
545 return RETMySQLError;
546 }
547 return RETOk;
548}
549
550
552 int *runFrm,
553 int *runTo,
554 std::string& calParVer,
556 int runNo,
557 std::string& sftver) {
558 using namespace rdbModel;
559 eRet ret;
560 char stmt1[400];
561 int run_No =runNo;
562 if(sftver=="default")
563 sftver = getenv("BES_RELEASE");
564 const char* SftVer = sftver.c_str();
565
566 if(calParVer!="default"){
567 const char* calpar = calParVer.c_str();
568 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
569 }
570
571 if(calParVer=="default"){
572 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
573 }
574 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
575 if(row_no<1){
576 std::cout<<"ERROR:error searching EsTime calibration Data in the database with: "<<stmt1<<std::endl;
577 return RETMySQLError;
578 }
579
580 return RETOk;
581}
582
583
584//get EstTof Information from mysql Database
586 int *runFrm,
587 int *runTo,
588 std::string& calParVer,
590 int runNo,
591 std::string& sftver) {
592 using namespace rdbModel;
593 eRet ret;
594 char stmt1[200];
595 int run_No =runNo;
596 if(sftver=="default")
597 sftver = getenv("BES_RELEASE");
598 const char* SftVer = sftver.c_str();
599
600 if(calParVer!="default"){
601 const char* calpar = calParVer.c_str();
602 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
603 }
604 if(calParVer=="default"){
605 // sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,max(CalParVer),FileName from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);
606 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
607 }
608
609 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
610 if(row_no<1){
611 std::cout<<"ERROR:error searching EstTOF calibration Data in the database with: "<<stmt1<<std::endl;
612 return RETMySQLError;
613 }
614 return RETOk;
615}
616
617
619 int *runFrm,
620 int *runTo,
621 std::string& calParVer,
623 int runNo,
624 std::string& sftver) {
625 using namespace rdbModel;
626 eRet ret;
627 char stmt1[200];
628 int run_No =runNo;
629 if(sftver=="default")
630 sftver = getenv("BES_RELEASE");
631 const char* SftVer = sftver.c_str();
632
633 if(calParVer!="default"){
634 const char* calpar = calParVer.c_str();
635 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status,SftVer from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and TofSimParVer = %s",SftVer,run_No,run_No,calpar);
636 }
637 if(calParVer=="default"){
638 // sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,max(TofSimParVer),FileName from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by TofSimParVer",SftVer,run_No,run_No);
639 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status,SftVer from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by TofSimParVer desc",SftVer,run_No,run_No);
640 }
641
642
643 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
644 if(row_no<1){
645 std::cout<<"ERROR:error searching TOFSim calibration Data in the database with: "<<stmt1<<std::endl;
646 return RETMySQLError;
647 }
648
649 return RETOk;
650}
651
652
654 int *runFrm,
655 int *runTo,
656 std::string& calParVer,
658 int runNo,
659 std::string& sftver) {
660 using namespace rdbModel;
661 eRet ret;
662 char stmt1[200];
663 int run_No =runNo;
664 if(sftver=="default")
665 sftver = getenv("BES_RELEASE");
666 const char* SftVer = sftver.c_str();
667
668 if(calParVer!="default"){
669 const char* calpar = calParVer.c_str();
670 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
671 }
672 if(calParVer=="default"){
673 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
674 }
675
676 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
677 if(row_no<1){
678 std::cout<<"ERROR:error searching DedxSim calibration Data in the database with: "<<stmt1<<std::endl;
679 return RETMySQLError;
680 }
681 return RETOk;
682}
683
684
685
687 int *runFrm,
688 int *runTo,
689 std::string& calParVer,
691 int runNo,
692 std::string& sftver) {
693 using namespace rdbModel;
694 eRet ret;
695 char stmt1[200];
696 int run_No =runNo;
697 if(sftver=="default")
698 sftver = getenv("BES_RELEASE");
699 const char* SftVer = sftver.c_str();
700
701 if(calParVer!="default"){
702 const char* calpar = calParVer.c_str();
703 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status,SftVer from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and MdcAlignVer = %s",SftVer,run_No,run_No,calpar);
704 }
705 if(calParVer=="default"){
706 // sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,max(MdcAlignVer),AlignEPFileName from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by MdcAlignVer",SftVer,run_No,run_No);
707 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status,SftVer from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by MdcAlignVer desc",SftVer,run_No,run_No);
708 }
709
710 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
711 if(row_no<1){
712 std::cout<<"ERROR:error searching MdcAlignment calibration Data in the database with: "<<stmt1<<std::endl;
713 return RETMySQLError;
714 }
715
716 return RETOk;
717}
718
720 int *runFrm,
721 int *runTo,
722 std::string& calParVer,
724 int runNo,
725 std::string& sftver) {
726 using namespace rdbModel;
727 eRet ret;
728 char stmt1[200];
729 int run_No =runNo;
730 if(sftver=="default")
731 sftver = getenv("BES_RELEASE");
732 const char* SftVer = sftver.c_str();
733
734 if(calParVer!="default"){
735 const char* calpar = calParVer.c_str();
736 sprintf(stmt1,"select WireEff,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcDataConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
737 }
738 if(calParVer=="default"){
739 sprintf(stmt1,"select WireEff,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from MdcDataConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
740 }
741
742 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
743 if(row_no<1){
744 std::cout<<"ERROR:error searching MdcDataConst Data in the database with: "<<stmt1<<std::endl;
745 return RETMySQLError;
746 }
747
748 return RETOk;
749}
750
752 int *runFrm,
753 int *runTo,
754 std::string& calParVer,
756 int runNo,
757 std::string& sftver) {
758 using namespace rdbModel;
759 eRet ret;
760 char stmt1[400];
761 int run_No =runNo;
762 if(sftver=="default")
763 sftver = getenv("BES_RELEASE");
764 const char* SftVer = sftver.c_str();
765
766 if(calParVer!="default"){
767 const char* calpar = calParVer.c_str();
768 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar);
769 }
770 if(calParVer=="default"){
771 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status,SftVer from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);
772 }
773 int row_no = m_dbsvc->query("offlinedb", stmt1, res);
774 if(row_no<1){
775 std::cout<<"ERROR:error searching TofQElec calibration Data in the database with: "<<stmt1<<std::endl;
776 return RETMySQLError;
777 }
778 std::cout<<"metadata ok"<<std::endl;
779 return RETOk;
780}
781
782
783/*
784
785 | Field | Type | Null | Key | Default | How set |
786 +-------------+--------------------+------+-----+---------+------------------+
787 | ser_no | mediumint(9) | | PRI | NULL | auto_increment |
788 | instrument | varchar(16) | | | | [openRecord] |
789 | calib_type | varchar(20) | | | | [openRecord |
790 | data_fmt | varchar(10) | | | | [openRecord] |
791 | data_size | int(11) | YES | | NULL | [optional] |
792 | vstart | datetime | YES | | NULL |[addValidInterval]|
793 | vend | datetime | YES | | NULL |[addValidInterval]|
794 | enter_time | timestamp(14) | YES | | NULL | automatic |
795 | fmt_version | varchar(12) | YES | | NULL | [openRecord] |
796 | completion | enum('OK','INC','ABORT')
797 | YES | MUL | NULL | [openRecord] |
798 | proc_level | enum('PROD','TEST','DEV', 'SUPSED')
799 | | | TEST | [openRecord] |
800 | creator | varchar(255) | YES | | NULL | [addCreator] |
801 | uid | varchar(12) | | | |[insertRecord/
802 addUser] |
803 | data_ident | varchar(255) | | | | [openRecord] |
804 | input_desc | varchar(255) | YES | | NULL |[addInputDesc] |
805 | notes | varchar(255) | YES | | NULL | [addNotes] |
806 +-------------+--------------------+------+-----+---------+------------------+
807
808*/
809
811Metadata::doSelect(std::vector<rdbModel::Assertion::Operator *>& conditions,
812 rdbModel::StringVector& orderBy,
813 unsigned*& ser) {
814 using namespace rdbModel;
815 *ser = 0;
816
817 StringVector colNames(1);
818 colNames[0] = "ser_no";
819
820 // make the combined operator
821 Assertion::Operator andOp(OPTYPEand, conditions, true);
822
823 //Following creates an assertion such that creator (us) continues
824 // to own the associated operator.
825 Assertion whereClause(&andOp, 0, true);
826 ResultHandle* results = 0;
827
828 if(results){
829 delete results;
830 }
831
832 try { // make the query
833 results = m_readCxt->select(m_table, colNames, orderBy, &whereClause);
834
835 }
836 catch (RdbException ex) {
837 std::cout << ex.getMsg();
838 }
839
840 if (!results) { // Error. Should have ResultHandle even if 0 rows.
841 std::cout<<"no results"<<std::endl;
842 return RETMySQLError;
843 }
844
845
846
847 std::cout<<"There are results"<<std::endl;
848 // handle result.
849 if (results->getNRows() == 0) {
850 conditions.pop_back();
851 std::cout<<"no results"<<std::endl;
852 }
853 else{
854 std::vector<std::string> fields;
855 results->getRow(fields);
856
857 if(results){
858 delete results;
859 }
860 *ser = facilities::Util::stringToInt(fields[0]);
861 return RETOk;
862 }
863
864}
865
866int Metadata::registerCalib(const std::string& inst,
867 const std::string& flavor,
868 const std::string& calib_type,
869 const std::string& data_ident,
870 const std::string& data_fmt,
871 unsigned int& runfrm,
872 unsigned int& runto,
873 const std::string& input_desc,
874 const std::string& notes,
875 const std::string& proc_level,
876 const std::string& locale,
877 const std::string& fmt_version,
878 const std::string& completion)
879{
880
881 using namespace rdbModel;
882
883 eRet ret;
884
885 if (!m_writeCxt) {
886 connectWrite(ret);
887 if (ret != RETOk) return 0; // we or connectWrite should throw exception
888 }
889 StringVector cols;
890 StringVector vals;
891 StringVector nullCols;
892
893 cols.reserve(24);
894 vals.reserve(24);
895 nullCols.reserve(16);
896
897 if (inst.size() * calib_type.size() * flavor.size() * data_fmt.size()
898 * data_ident.size() * proc_level.size() * completion.size()
899 * locale.size() == 0) { // something is null that shouldn't be
900 return 0; // should perhaps throw exception
901 }
902 cols.push_back("calib_type"); vals.push_back(calib_type);
903 // cols.push_back("flavor"); vals.push_back(flavor);
904 cols.push_back("data_fmt"); vals.push_back(data_fmt);
905 cols.push_back("data_ident"); vals.push_back(data_ident);
906 cols.push_back("status"); vals.push_back(completion);
907 std::string s_runfrm,s_runto;
908 facilities::Util::itoa(runfrm,s_runfrm);
909 facilities::Util::itoa(runto,s_runto);
910 cols.push_back("RunFrom"); vals.push_back(s_runfrm);
911 cols.push_back("RunTo"); vals.push_back(s_runto);
912
913 // These, however, may be null
914 if (input_desc.size() > 0 ) {
915 cols.push_back("input_desc"); vals.push_back(input_desc);
916 } else nullCols.push_back("input_desc");
917
918 if (notes.size() > 0 ) {
919 cols.push_back("notes"); vals.push_back(notes);
920 } else nullCols.push_back("notes");
921
922 if (fmt_version.size() > 0 )
923 {
924 cols.push_back("fmt_version");
925 vals.push_back(fmt_version);
926 }
927
928 // The service -- that's us -- is responsible for creator, uid, enter_time
929 cols.push_back("creator"); vals.push_back("Metadata::registerCalib");
930 std::string uid;
931 fetchUser(uid);
932 cols.push_back("uid"); vals.push_back(uid);
933 facilities::Timestamp curTime;
934 cols.push_back("enter_time");vals.push_back(curTime.getString());
935 // update_time is set automatically by MySQL, but MySQL uses
936 // local timezone rather than gmt, so we have set it explicitly
937 cols.push_back("update_time");vals.push_back(curTime.getString());
938
939
940 if (m_rdb) {
941 bool ok = checkValues(cols, vals);
942 if (ok) checkNulls(nullCols);
943 if (!ok) return 0;
944 }
945
946 // ser_no gets set automatically by MySQL
947 int ser_no;
948 if (!(m_writeCxt->insertRow(m_table, cols, vals, &ser_no, &nullCols)) ) {
949 return 0;
950 } else {
951 adjustVend(ser_no);
952 return ser_no;
953 }
954}
955
956Metadata::eRet Metadata::compareSchema(rdbModel::Connection* conn,
957 const std::string& schema) {
958 using namespace rdbModel;
959
960
961 if (m_man) { // already did this
962 return (m_match) ? RETOk : RETNoSchemaMatch;
963 }
965
967 m_man->setInputSource(schema);
968
969 // Maybe first check if file exists? E.g., try opening for read
970
971 // good errcode is 0
972 int errcode = m_man->build();
973
974 if (errcode) {
975 std::cerr << "Error in database description file " << schema
976 << std::endl;
977 std::cerr << "Parse failed with error " << errcode << std::endl;
978 return RETBadCnfFile;
979 }
980 m_rdb = m_man->getRdb();
981
982 rdbModel::MATCH match = conn->matchSchema(m_rdb, false);
983
984 switch (match) {
987 m_match = true;
988 return RETOk;
990 std::cout << "XML schema and MySQL database are NOT compatible"
991 << std::endl;
992 return RETBadCnfFile;
994 std::cout << "Connection failed while attempting match" << std::endl;
995 return RETNoConnect;
996 }
997 return RETBadValue;
998}
999
1001 const rdbModel::StringVector& vals) const {
1002 unsigned nCol = cols.size();
1003 rdbModel::Table* table = m_rdb->getTable(m_table);
1004
1005
1006 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1007 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1008 if (!col->okValue(vals[iCol])) {
1009 std::cerr << "Value " << vals[iCol] << " not allowed for column "
1010 << cols[iCol] << " in table " << m_table << std::endl;
1011 return false;
1012 }
1013 }
1014 return true;
1015}
1016
1018 unsigned nCol = cols.size();
1019 rdbModel::Table* table = m_rdb->getTable(m_table);
1020
1021
1022 for (unsigned iCol = 0; iCol < nCol; iCol++) {
1023 rdbModel::Column* col = table->getColumnByName(cols[iCol]);
1024 if (!col->nullAllowed()) {
1025 std::cerr << "Column "
1026 << cols[iCol] << " in table " << m_table
1027 << " is not nullable" << std::endl;
1028 return false;
1029 }
1030 }
1031 return true;
1032}
1033
1034
1035unsigned Metadata::adjustVend(int newSer) {
1036 using namespace rdbModel;
1037
1038 StringVector getCols;
1039 StringVector orderBy;
1040
1041 orderBy.clear();
1042 getCols.reserve(7);
1043
1044 std::string serString;
1045 facilities::Util::itoa(newSer, serString);
1046
1047 getCols.push_back("flavor");
1048 getCols.push_back("calib_type");
1049 getCols.push_back("completion");
1050
1051 ResultHandle* results = 0;
1052 eRet err;
1053 Assertion* where = 0;
1054 try {
1055 if (!m_writeCxt) {
1056 if (!connectWrite(err)) return 0;
1057 }
1058
1059 Assertion::Operator* serOp =
1060 new Assertion::Operator(OPTYPEequal, "ser_no", serString,
1061 FIELDTYPEold, FIELDTYPElit);
1062 //false, true);
1063
1064 where = new Assertion(serOp);
1065
1066 // Fetch information for new row: vstart, flavor, completion,
1067 // proc_level, calib_type, flavor
1068 results = m_writeCxt->select(m_table, getCols, orderBy, where);
1069 // results = m_writeCxt->select("metadata_v0", getCols, orderBy, where);
1070 delete where;
1071 where = 0;
1072 }
1073 catch (RdbException ex) {
1074 std::cout << ex.getMsg();
1075 delete where; // return heap memory
1076 return 0;
1077 }
1078 if (!results) { // This is an error. Should be non-null even if no rows
1079 std::cout << "MySQL failure in SELECT" << std::endl;
1080 return 0; // nothing to fix
1081 }
1082 if (results->getNRows() != 1) { // also a problem
1083 std::cout << "Look-up of serial# " << serString << " failed"
1084 << std::endl;
1085 return 0;
1086 }
1087 std::vector<std::string> fields;
1088 results->getRow(fields);
1089 if (fields[2] != "OK") return 0; // don't bother fixing in this case
1090
1091 // Now do an update on rows satisfying
1092 // ((flavor="f") && (calib_type = "c") && (completion= "OK") &&
1093 // (instrument = "i") && (proc_level = "p") &&
1094 // (vstart < "new-start" (vend > "new-vstart") );
1095 std::vector<Assertion::Operator *> conditions;
1096 conditions.reserve(7);
1097 for (unsigned ix = 0; ix < 5; ix++) {
1098 conditions.push_back(new Assertion::Operator(OPTYPEequal, getCols[ix],
1099 fields[ix],
1100 FIELDTYPEold, FIELDTYPElit));
1101 // false, true));
1102 }
1103 conditions.push_back(new Assertion::Operator(OPTYPElessThan, "vstart",
1104 fields[5],
1105 FIELDTYPEold, FIELDTYPElit));
1106 //false, true));
1107 conditions.push_back(new Assertion::Operator(OPTYPEgreaterThan, "vend",
1108 fields[5],
1109 FIELDTYPEold, FIELDTYPElit));
1110 // false, true));
1111
1112 Assertion::Operator* andOp =
1113 new Assertion::Operator(OPTYPEand, conditions);
1114 where = new Assertion(andOp);
1115
1116 StringVector toUpdate;
1117 toUpdate.push_back("vend");
1118 StringVector newVal;
1119 newVal.push_back(fields[5]);
1120 // also update update_time. If we leave it to MySQL, won't be GMT
1121 facilities::Timestamp curTime;
1122 toUpdate.push_back("update_time");newVal.push_back(curTime.getString());
1123
1124 unsigned nModified = m_writeCxt->update(m_table, toUpdate, newVal, where);
1125 delete where;
1126 return nModified;
1127}
1128
1129}
1130
1131
std::vector< std::string > StringVector
Simple algorithm to test functioning of "the other" TDS.
Definition CheckMySQL.h:50
int runNo
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
eRet getReadMdcDataConstInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:719
bool checkValues(const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const
eRet getReadEsTimeInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:551
bool checkNulls(const rdbModel::StringVector &cols) const
eRet findBest(unsigned int *ser, const std::string &calibType, const std::string &sft_ver, const std::string &cal_ver, const std::string &cal_par, const std::string &rec_alg, const std::string &rec_par, const std::string &machine, const std::string &flavor="VANILLA")
Definition Metadata.cxx:243
eRet getReadTOFInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:376
eRet getReadInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &dataFmt, std::string &dataIdent)
Definition Metadata.cxx:314
bool connectRead(eRet &err)
Definition Metadata.cxx:107
eRet getReadDedxSimInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:653
Metadata(const std::string &host="bes3db2.ihep.ac.cn", const std::string &table="*", const std::string &dbName="calib")
Constructor keeps track of table of interest.
Definition Metadata.cxx:39
eRet getReadMUCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:409
eRet getReadEstTofInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:585
eRet getReadTofSimInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:618
eRet getReadDedxInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:517
eRet getReadMdcAlignInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:686
int registerCalib(const std::string &inst, const std::string &flavor, const std::string &calib_type, const std::string &data_ident, const std::string &data_format, unsigned int &runfrm, unsigned int &runto, const std::string &input_desc, const std::string &notes, const std::string &proc_level, const std::string &locale, const std::string &fmt_version="", const std::string &completion="OK")
Definition Metadata.cxx:866
eRet getReadMDCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:446
eRet getReadTofQElecInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:751
eRet findSoonAfter(unsigned int *ser, const std::string &calibType, const std::string &sft_ver, const std::string &cal_ver, const std::string &cal_par, const std::string &rec_alg, const std::string &rec_par, const std::string &machine, const std::string &flavor="VANILLA")
Definition Metadata.cxx:172
eRet getReadEMCInfo(unsigned int serialNo, int *runFrm, int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver)
Definition Metadata.cxx:483
std::string getString() const
Return string representation of time, not including nanoseconds;.
Definition Timestamp.cxx:92
static int expandEnvVar(std::string *toExpand, const std::string &openDel=std::string("$("), const std::string &closeDel=std::string(")"))
static int atoi(const std::string &InStr)
converts an std::string to an integer
static int stringToInt(const std::string &InStr)
static const char * itoa(int val, std::string &outStr)
bool nullAllowed() const
Returns true if column may take on value NULL.
Definition Column.h:80
bool okValue(const std::string &val, bool set=true) const
Definition Column.cxx:21
virtual ResultHandle * select(const std::string &tableName, const StringVector &getCols, const StringVector &orderCols, const Assertion *where=0, int rowLimit=0, int rowOffset=0)=0
virtual MATCH matchSchema(Rdb *rdb, bool matchDbName=true)=0
virtual unsigned int update(const std::string &tableName, const StringVector &colNames, const StringVector &values, const Assertion *where=0, const StringVector *nullCols=0)=0
virtual bool open(const std::string &host, const std::string &userid, const std::string &password, const std::string &dbName)=0
virtual bool insertRow(const std::string &tableName, const StringVector &colNames, const StringVector &values, int *auto_value=0, const StringVector *nullCols=0)=0
virtual bool close()=0
Rdb * getRdb()
Definition Manager.h:48
void setInputSource(std::string pname)
Definition Manager.h:51
void setBuilder(Builder *b)
Definition Manager.cxx:37
static Manager * getManager()
Definition Manager.cxx:24
virtual std::string getMsg()
Table * getTable(const std::string &name) const
Definition Rdb.cxx:16
virtual bool getRow(std::vector< std::string > &fields, unsigned int i=0, bool clear=true)=0
virtual unsigned int getNRows() const =0
Return number of rows in results.
Column * getColumnByName(const std::string &name) const
Definition Table.cxx:56
Module implements methods for clients to get generic services.
@ MATCHequivalent
Definition Connection.h:26
@ MATCHnoConnection
Definition Connection.h:29
@ MATCHcompatible
Definition Connection.h:27
std::vector< std::string > StringVector
Definition Connection.h:52