#include <Metadata.h>
Public Types | |
enum | eLevel { LEVELProd = 1, LEVELDev = 2, LEVELTest = 4, LEVELSuperseded = 8 } |
Used to form bit masks for dbs queries. More... | |
enum | eLevel { LEVELProd = 1, LEVELDev = 2, LEVELTest = 4, LEVELSuperseded = 8 } |
Used to form bit masks for dbs queries. More... | |
enum | eRet { RETOk = 0, RETBadCnfFile = 1, RETBadHost = 2, RETNoConnect = 3, RETWrongState = 4, RETBadValue = 5, RETMySQLError = 6, RETNoSchemaMatch = 7 } |
enum | eRet { RETOk = 0, RETBadCnfFile = 1, RETBadHost = 2, RETNoConnect = 3, RETWrongState = 4, RETBadValue = 5, RETMySQLError = 6, RETNoSchemaMatch = 7 } |
Public Member Functions | |
bool | checkNulls (const rdbModel::StringVector &cols) const |
bool | checkNulls (const rdbModel::StringVector &cols) const |
bool | checkValues (const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const |
bool | checkValues (const rdbModel::StringVector &cols, const rdbModel::StringVector &vals) const |
bool | connectRead (eRet &err) |
bool | connectRead (eRet &err) |
void | disconnectRead () |
void | disconnectRead () |
void | disconnectWrite () |
void | disconnectWrite () |
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") |
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") |
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") |
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") |
eRet | getInterval (unsigned int serialNo, facilities::Timestamp *&since, facilities::Timestamp *&till) |
Get validity interval for a particular calibration. | |
eRet | getInterval (unsigned int serialNo, facilities::Timestamp *&since, facilities::Timestamp *&till) |
Get validity interval for a particular calibration. | |
rdbModel::Rdb * | getRdb () |
rdbModel::Rdb * | getRdb () |
rdbModel::Connection * | getReadConnection () |
rdbModel::Connection * | getReadConnection () |
eRet | getReadDedxInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadDedxInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadDedxSimInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadDedxSimInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadEMCInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadEMCInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadEsTimeInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadEsTimeInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadEstTofInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadEstTofInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &dataFmt, std::string &dataIdent) |
eRet | getReadInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &dataFmt, std::string &dataIdent) |
eRet | getReadMdcAlignInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadMdcAlignInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadMDCInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadMDCInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadMUCInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadMUCInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadTOFInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadTOFInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadTofQElecInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadTofQElecInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadTofSimInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
eRet | getReadTofSimInfo (unsigned int serialNo, unsigned int *runFrm, unsigned int *runTo, std::string &calParVer, DatabaseRecordVector &res, int runNo, std::string &sftver) |
const std::string & | getTable () |
const std::string & | getTable () |
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. | |
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. | |
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 ¬es, const std::string &proc_level, const std::string &locale, const std::string &fmt_version="", const std::string &completion="OK") |
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 ¬es, const std::string &proc_level, const std::string &locale, const std::string &fmt_version="", const std::string &completion="OK") |
~Metadata () | |
~Metadata () | |
Private Member Functions | |
unsigned | adjustVend (int newSer) |
unsigned | adjustVend (int newSer) |
eRet | compareSchema (rdbModel::Connection *conn, const std::string &schema) |
eRet | compareSchema (rdbModel::Connection *conn, const std::string &schema) |
bool | connectWrite (eRet &err) |
bool | connectWrite (eRet &err) |
eRet | doSelect (std::vector< rdbModel::Assertion::Operator * > &conditions, rdbModel::StringVector &orderBy, unsigned *&ser) |
eRet | doSelect (std::vector< rdbModel::Assertion::Operator * > &conditions, rdbModel::StringVector &orderBy, unsigned *&ser) |
bool | fetchLevel (std::string &val, unsigned int *levelMask) |
bool | fetchLevel (std::string &val, unsigned int *levelMask) |
eRet | fetchUser (std::string &user) |
Discover username and store in caller-supplied string. | |
eRet | fetchUser (std::string &user) |
Discover username and store in caller-supplied string. | |
Static Private Member Functions | |
bool | connect (rdbModel::Connection *conn, std::string &host, const std::string &user, const std::string &pw, eRet &err, const std::string &dbName) |
bool | connect (rdbModel::Connection *conn, std::string &host, const std::string &user, const std::string &pw, eRet &err, const std::string &dbName) |
Private Attributes | |
std::string | m_dbName |
IDatabaseSvc * | m_dbsvc |
IDatabaseSvc * | m_dbsvc |
rdbModel::Assertion * | m_findBest |
rdbModel::Assertion * | m_findBest |
rdbModel::Assertion * | m_findSoonest |
rdbModel::Assertion * | m_findSoonest |
std::string | m_host |
Constant bit mask indicating all necessary fields have been set. | |
rdbModel::Manager * | m_man |
rdbModel::Manager * | m_man |
bool | m_match |
rdbModel::Rdb * | m_rdb |
rdbModel::Rdb * | m_rdb |
rdbModel::Connection * | m_readCxt |
rdbModel::Connection * | m_readCxt |
std::string | m_table |
rdbModel::Connection * | m_writeCxt |
rdbModel::Connection * | m_writeCxt |
The class contains definitions for several enumerated types, corresponding to possible entries for columns in a metadata record. Within the MySQL database the values are kept as strings. The enumerated types are provided to insulate clients from these details; enumerations are easier to document and to check for validity.
|
Used to form bit masks for dbs queries.
00046 { 00047 LEVELProd = 1, 00048 LEVELDev = 2, 00049 LEVELTest = 4, 00050 LEVELSuperseded = 8 00051 };
|
|
Used to form bit masks for dbs queries.
00046 { 00047 LEVELProd = 1, 00048 LEVELDev = 2, 00049 LEVELTest = 4, 00050 LEVELSuperseded = 8 00051 };
|
|
00035 { 00036 RETOk = 0, 00037 RETBadCnfFile = 1, 00038 RETBadHost = 2, 00039 RETNoConnect = 3, 00040 RETWrongState = 4, 00041 RETBadValue = 5, 00042 RETMySQLError = 6, 00043 RETNoSchemaMatch = 7 00044 };
|
|
00035 { 00036 RETOk = 0, 00037 RETBadCnfFile = 1, 00038 RETBadHost = 2, 00039 RETNoConnect = 3, 00040 RETWrongState = 4, 00041 RETBadValue = 5, 00042 RETMySQLError = 6, 00043 RETNoSchemaMatch = 7 00044 };
|
|
Constructor keeps track of table of interest.
00041 : m_readCxt(0), m_writeCxt(0), // m_row(""), m_rowStatus(0), 00042 m_host(host), m_table(table), m_dbName(dbName), m_man(0), m_rdb(0), 00043 m_match(false) { 00044 if (table.compare("*") == 0) m_table = std::string("$(MYSQL_METATABLE)"); 00045 if (host.compare("*") == 0) m_host = std::string("$(MYSQL_HOST)"); 00046 00047 int nsub = facilities::Util::expandEnvVar(&m_table); 00048 // If this doesn't work, use default 00049 if (nsub < 0) m_table = std::string("metadata"); 00050 StatusCode sc=Gaudi::svcLocator()->service("DatabaseSvc", m_dbsvc, true); 00051 if ( !sc.isSuccess() ) { 00052 std::cout <<"Metadata ERROR ::Could not retrieve the DataBaseSvc" << std::endl;; 00053 exit(1); 00054 } 00055 }
|
|
00057 { 00058 disconnectRead(); 00059 disconnectWrite(); 00060 if (m_man) delete m_man; 00061 }
|
|
Constructor keeps track of table of interest.
|
|
|
|
|
|
01002 { 01003 using namespace rdbModel; 01004 01005 StringVector getCols; 01006 StringVector orderBy; 01007 01008 orderBy.clear(); 01009 getCols.reserve(7); 01010 01011 std::string serString; 01012 facilities::Util::itoa(newSer, serString); 01013 01014 getCols.push_back("flavor"); 01015 getCols.push_back("calib_type"); 01016 getCols.push_back("completion"); 01017 01018 ResultHandle* results = 0; 01019 eRet err; 01020 Assertion* where = 0; 01021 try { 01022 if (!m_writeCxt) { 01023 if (!connectWrite(err)) return 0; 01024 } 01025 01026 Assertion::Operator* serOp = 01027 new Assertion::Operator(OPTYPEequal, "ser_no", serString, 01028 FIELDTYPEold, FIELDTYPElit); 01029 //false, true); 01030 01031 where = new Assertion(serOp); 01032 01033 // Fetch information for new row: vstart, flavor, completion, 01034 // proc_level, calib_type, flavor 01035 results = m_writeCxt->select(m_table, getCols, orderBy, where); 01036 // results = m_writeCxt->select("metadata_v0", getCols, orderBy, where); 01037 delete where; 01038 where = 0; 01039 } 01040 catch (RdbException ex) { 01041 std::cout << ex.getMsg(); 01042 delete where; // return heap memory 01043 return 0; 01044 } 01045 if (!results) { // This is an error. Should be non-null even if no rows 01046 std::cout << "MySQL failure in SELECT" << std::endl; 01047 return 0; // nothing to fix 01048 } 01049 if (results->getNRows() != 1) { // also a problem 01050 std::cout << "Look-up of serial# " << serString << " failed" 01051 << std::endl; 01052 return 0; 01053 } 01054 std::vector<std::string> fields; 01055 results->getRow(fields); 01056 if (fields[2] != "OK") return 0; // don't bother fixing in this case 01057 01058 // Now do an update on rows satisfying 01059 // ((flavor="f") && (calib_type = "c") && (completion= "OK") && 01060 // (instrument = "i") && (proc_level = "p") && 01061 // (vstart < "new-start" (vend > "new-vstart") ); 01062 std::vector<Assertion::Operator *> conditions; 01063 conditions.reserve(7); 01064 for (unsigned ix = 0; ix < 5; ix++) { 01065 conditions.push_back(new Assertion::Operator(OPTYPEequal, getCols[ix], 01066 fields[ix], 01067 FIELDTYPEold, FIELDTYPElit)); 01068 // false, true)); 01069 } 01070 conditions.push_back(new Assertion::Operator(OPTYPElessThan, "vstart", 01071 fields[5], 01072 FIELDTYPEold, FIELDTYPElit)); 01073 //false, true)); 01074 conditions.push_back(new Assertion::Operator(OPTYPEgreaterThan, "vend", 01075 fields[5], 01076 FIELDTYPEold, FIELDTYPElit)); 01077 // false, true)); 01078 01079 Assertion::Operator* andOp = 01080 new Assertion::Operator(OPTYPEand, conditions); 01081 where = new Assertion(andOp); 01082 01083 StringVector toUpdate; 01084 toUpdate.push_back("vend"); 01085 StringVector newVal; 01086 newVal.push_back(fields[5]); 01087 // also update update_time. If we leave it to MySQL, won't be GMT 01088 facilities::Timestamp curTime; 01089 toUpdate.push_back("update_time");newVal.push_back(curTime.getString()); 01090 01091 unsigned nModified = m_writeCxt->update(m_table, toUpdate, newVal, where); 01092 delete where; 01093 return nModified; 01094 }
|
|
|
|
00984 { 00985 unsigned nCol = cols.size(); 00986 rdbModel::Table* table = m_rdb->getTable(m_table); 00987 00988 00989 for (unsigned iCol = 0; iCol < nCol; iCol++) { 00990 rdbModel::Column* col = table->getColumnByName(cols[iCol]); 00991 if (!col->nullAllowed()) { 00992 std::cerr << "Column " 00993 << cols[iCol] << " in table " << m_table 00994 << " is not nullable" << std::endl; 00995 return false; 00996 } 00997 } 00998 return true; 00999 }
|
|
|
|
00968 { 00969 unsigned nCol = cols.size(); 00970 rdbModel::Table* table = m_rdb->getTable(m_table); 00971 00972 00973 for (unsigned iCol = 0; iCol < nCol; iCol++) { 00974 rdbModel::Column* col = table->getColumnByName(cols[iCol]); 00975 if (!col->okValue(vals[iCol])) { 00976 std::cerr << "Value " << vals[iCol] << " not allowed for column " 00977 << cols[iCol] << " in table " << m_table << std::endl; 00978 return false; 00979 } 00980 } 00981 return true; 00982 }
|
|
|
|
00924 { 00925 using namespace rdbModel; 00926 00927 00928 if (m_man) { // already did this 00929 return (m_match) ? RETOk : RETNoSchemaMatch; 00930 } 00931 m_man = rdbModel::Manager::getManager(); 00932 00933 m_man->setBuilder(new rdbModel::XercesBuilder); 00934 m_man->setInputSource(schema); 00935 00936 // Maybe first check if file exists? E.g., try opening for read 00937 00938 // good errcode is 0 00939 int errcode = m_man->build(); 00940 00941 if (errcode) { 00942 std::cerr << "Error in database description file " << schema 00943 << std::endl; 00944 std::cerr << "Parse failed with error " << errcode << std::endl; 00945 return RETBadCnfFile; 00946 } 00947 m_rdb = m_man->getRdb(); 00948 00949 rdbModel::MATCH match = conn->matchSchema(m_rdb, false); 00950 00951 switch (match) { 00952 case rdbModel::MATCHequivalent: 00953 case rdbModel::MATCHcompatible: 00954 m_match = true; 00955 return RETOk; 00956 case rdbModel::MATCHfail: 00957 std::cout << "XML schema and MySQL database are NOT compatible" 00958 << std::endl; 00959 return RETBadCnfFile; 00960 case rdbModel::MATCHnoConnection: 00961 std::cout << "Connection failed while attempting match" << std::endl; 00962 return RETNoConnect; 00963 } 00964 return RETBadValue; 00965 }
|
|
|
|
00088 { 00089 00090 int nSub = facilities::Util::expandEnvVar(&host); 00091 if (nSub < 0) { 00092 err = RETBadHost; 00093 return false; 00094 } 00095 00096 bool connected = cxt->open(host, user, pw, dbName); 00097 if (connected) { 00098 err = RETOk; 00099 return true; 00100 } 00101 else { 00102 err = RETNoConnect; 00103 return false; 00104 } 00105 }
|
|
|
|
00107 { 00108 if (m_readCxt == 0) { 00109 // for now use std::cout, std::cerr 00110 m_readCxt = new rdbModel::MysqlConnection(); 00111 // bool ok = connect(m_readCxt, m_host, std::string("maqm"), 00112 // std::string("maqm_offline"), err, m_dbName); 00113 bool ok = connect(m_readCxt, m_host, std::string("guest"), 00114 std::string("guestpass"), err, m_dbName); 00115 if (!ok) { 00116 delete m_readCxt; 00117 m_readCxt = 0; 00118 } /* else { // look for compatible schema 00119 std::string schema = 00120 std::string("$(RDBMODELROOT)/xml/")+ m_dbName + ".xml"; 00121 err = compareSchema(m_readCxt, schema); 00122 }*/ 00123 return ok; 00124 } 00125 00126 else return true; 00127 }
|
|
|
|
00129 { 00130 if (m_writeCxt == 0) { 00131 m_writeCxt = new rdbModel::MysqlConnection(); 00132 bool ok; 00133 if (m_dbName == std::string("calib_test") ) { 00134 ok = connect(m_writeCxt, m_host, std::string("calib_tester"), 00135 std::string("udine"), err, m_dbName); 00136 } 00137 else { 00138 ok = connect(m_writeCxt, m_host, std::string("calibrator"), 00139 std::string("calibrator"), err, m_dbName); 00140 } 00141 if (!ok) { 00142 delete m_readCxt; 00143 m_readCxt = 0; 00144 } else { // look for compatible schema 00145 std::string schema = 00146 std::string("$(RDBMODELROOT)/xml/")+ m_dbName + ".xml"; 00147 err = compareSchema(m_writeCxt, schema); 00148 } 00149 00150 return ok; 00151 } 00152 else return true; 00153 }
|
|
|
|
00155 { 00156 if (m_readCxt) { 00157 m_readCxt->close(); 00158 delete m_readCxt; 00159 m_readCxt = 0; 00160 } 00161 }
|
|
|
|
00163 { 00164 if (m_writeCxt) { 00165 m_writeCxt->close(); 00166 delete m_writeCxt; 00167 m_writeCxt = 0; 00168 } 00169 }
|
|
|
|
00780 { 00781 using namespace rdbModel; 00782 *ser = 0; 00783 00784 StringVector colNames(1); 00785 colNames[0] = "ser_no"; 00786 00787 // make the combined operator 00788 Assertion::Operator andOp(OPTYPEand, conditions, true); 00789 00790 //Following creates an assertion such that creator (us) continues 00791 // to own the associated operator. 00792 Assertion whereClause(&andOp, 0, true); 00793 ResultHandle* results = 0; 00794 00795 if(results){ 00796 delete results; 00797 } 00798 00799 try { // make the query 00800 results = m_readCxt->select(m_table, colNames, orderBy, &whereClause); 00801 00802 } 00803 catch (RdbException ex) { 00804 std::cout << ex.getMsg(); 00805 } 00806 00807 if (!results) { // Error. Should have ResultHandle even if 0 rows. 00808 std::cout<<"no results"<<std::endl; 00809 return RETMySQLError; 00810 } 00811 00812 00813 00814 std::cout<<"There are results"<<std::endl; 00815 // handle result. 00816 if (results->getNRows() == 0) { 00817 conditions.pop_back(); 00818 std::cout<<"no results"<<std::endl; 00819 } 00820 else{ 00821 std::vector<std::string> fields; 00822 results->getRow(fields); 00823 00824 if(results){ 00825 delete results; 00826 } 00827 *ser = facilities::Util::stringToInt(fields[0]); 00828 return RETOk; 00829 } 00830 00831 }
|
|
|
|
|
|
Discover username and store in caller-supplied string.
|
|
Discover username and store in caller-supplied string.
00064 { 00065 // WARNING: Windows and Linux/Solaris use different standard variables 00066 // for login name. The test used below isn't quite right 00067 // since one could conceivably compile with gcc on cygwin/Windows. 00068 #ifdef __GNUG__ 00069 user = std::string("$(USER)"); 00070 #else 00071 user = std::string("$(USERNAME)"); 00072 #endif 00073 00074 int nsub = facilities::Util::expandEnvVar(&user); 00075 if (nsub == 1) { 00076 return RETOk; 00077 } 00078 else { 00079 user = std::string(""); 00080 return RETBadValue; 00081 } 00082 }
|
|
Return serial number for calibration which is best match to criteria, using strings for calibType and instrument arguments. This method may be useful for development when a particular instrument or calibration type is not officially supported.
|
|
Return serial number for calibration which is best match to criteria, using strings for calibType and instrument arguments. This method may be useful for development when a particular instrument or calibration type is not officially supported.
00252 { 00253 using namespace rdbModel; 00254 00255 eRet ret; 00256 *ser = 0; 00257 if (!m_readCxt) { 00258 connectRead(ret); 00259 if (ret != RETOk) return ret; 00260 } 00261 00262 // Sort rows by timestamp. Would like most recent first 00263 StringVector orderBy; 00264 00265 std::vector<Assertion::Operator *> conditions; 00266 conditions.reserve(8); 00267 Assertion::Operator completeOp(OPTYPEequal, "status", "OK", 00268 FIELDTYPEold, FIELDTYPElit); 00269 // false, true); 00270 00271 Assertion::Operator calibTypeOp(OPTYPEequal, "calib_type", calibType, 00272 FIELDTYPEold, FIELDTYPElit); 00273 // false, true); 00274 // Assertion::Operator flavorOp(OPTYPEequal, "flavor", flavor, 00275 // FIELDTYPEold, FIELDTYPElit); 00276 // false, true); 00277 Assertion::Operator sftverOp(OPTYPEequal, "SftVer",SftVer, 00278 FIELDTYPEold, FIELDTYPElit); 00279 Assertion::Operator calverOp(OPTYPEequal, "cal_ver",cal_ver, 00280 FIELDTYPEold, FIELDTYPElit); 00281 Assertion::Operator calparOp(OPTYPEequal, "cal_par",cal_par, 00282 FIELDTYPEold, FIELDTYPElit); 00283 Assertion::Operator recalgOp(OPTYPEequal, "rec_alg",rec_alg, 00284 FIELDTYPEold, FIELDTYPElit); 00285 Assertion::Operator recparOp(OPTYPEequal, "rec_par",rec_par, 00286 FIELDTYPEold, FIELDTYPElit); 00287 Assertion::Operator machineOp(OPTYPEequal, "machine",machine, 00288 FIELDTYPEold, FIELDTYPElit); 00289 int run=10005; 00290 std::string s_run; 00291 facilities::Util::itoa(run,s_run); 00292 Assertion::Operator runfrmOp(OPTYPElessOrEqual,"RunFrom",s_run, 00293 FIELDTYPEold, FIELDTYPElit); 00294 00295 Assertion::Operator runtoOp(OPTYPEgreaterOrEqual,"RunTo",s_run, 00296 FIELDTYPEold, FIELDTYPElit); 00297 00298 conditions.push_back(&completeOp); 00299 conditions.push_back(&calibTypeOp); 00300 // conditions.push_back(&flavorOp); 00301 conditions.push_back(&sftverOp); 00302 conditions.push_back(&calverOp); 00303 conditions.push_back(&calparOp); 00304 conditions.push_back(&recalgOp); 00305 conditions.push_back(&recparOp); 00306 conditions.push_back(&machineOp); 00307 conditions.push_back(&runfrmOp); 00308 conditions.push_back(&runtoOp); 00309 // Finally, set a value for PROC_LEVEL and make the query (ies) 00310 return doSelect(conditions, orderBy, ser); 00311 }
|
|
Similar to findBest above, but here caller constrains the update_time of the calibration by specifying an earliest and (optional) latest time for it. The serial number of the calibration meeting all other conditions, and with the earliest update_time, will be returned.
|
|
Similar to findBest above, but here caller constrains the update_time of the calibration by specifying an earliest and (optional) latest time for it. The serial number of the calibration meeting all other conditions, and with the earliest update_time, will be returned.
00180 { 00181 using namespace rdbModel; 00182 00183 eRet ret; 00184 *ser = 0; 00185 if (!m_readCxt) { 00186 connectRead(ret); 00187 if (ret != RETOk) return ret; 00188 } 00189 00190 StringVector orderBy; 00191 00192 std::vector<Assertion::Operator *> conditions; 00193 conditions.reserve(8); 00194 00195 Assertion::Operator completeOp(OPTYPEequal, "status", "OK", 00196 FIELDTYPEold, FIELDTYPElit); 00197 // false, true); 00198 Assertion::Operator calibTypeOp(OPTYPEequal, "calib_type", calibType, 00199 FIELDTYPEold, FIELDTYPElit); 00200 // false, true); 00201 // Assertion::Operator flavorOp(OPTYPEequal, "flavor", flavor, 00202 // FIELDTYPEold, FIELDTYPElit); 00203 //false, true); 00204 Assertion::Operator sftverOp(OPTYPEequal, "SftVer",SftVer, 00205 FIELDTYPEold, FIELDTYPElit); 00206 Assertion::Operator calverOp(OPTYPEequal, "cal_ver",cal_ver, 00207 FIELDTYPEold, FIELDTYPElit); 00208 Assertion::Operator calparOp(OPTYPEequal, "cal_par",cal_par, 00209 FIELDTYPEold, FIELDTYPElit); 00210 Assertion::Operator recalgOp(OPTYPEequal, "rec_alg",rec_alg, 00211 FIELDTYPEold, FIELDTYPElit); 00212 Assertion::Operator recparOp(OPTYPEequal, "rec_par",rec_par, 00213 FIELDTYPEold, FIELDTYPElit); 00214 Assertion::Operator machineOp(OPTYPEequal, "machine",machine, 00215 FIELDTYPEold, FIELDTYPElit); 00216 00217 int run=10005; 00218 std::string s_run; 00219 std::cout<<"run no is::"<<s_run<<std::endl; 00220 facilities::Util::itoa(run,s_run); 00221 Assertion::Operator runfrmOp(OPTYPElessOrEqual,"RunFrom",s_run, 00222 FIELDTYPEold, FIELDTYPElit); 00223 00224 Assertion::Operator runtoOp(OPTYPEgreaterOrEqual,"RunTo",s_run, 00225 FIELDTYPEold, FIELDTYPElit); 00226 00227 conditions.push_back(&completeOp); 00228 conditions.push_back(&calibTypeOp); 00229 // conditions.push_back(&flavorOp); 00230 conditions.push_back(&sftverOp); 00231 conditions.push_back(&calverOp); 00232 conditions.push_back(&calparOp); 00233 conditions.push_back(&recalgOp); 00234 conditions.push_back(&recparOp); 00235 conditions.push_back(&machineOp); 00236 conditions.push_back(&runfrmOp); 00237 conditions.push_back(&runtoOp); 00238 ret = doSelect(conditions, orderBy, ser); 00239 00240 return ret; 00241 }
|
|
Get validity interval for a particular calibration.
|
|
Get validity interval for a particular calibration.
|
|
00278 {return m_rdb;}
|
|
00278 {return m_rdb;}
|
|
00275 {return m_readCxt;}
|
|
00275 {return m_readCxt;}
|
|
|
|
00522 { 00523 using namespace rdbModel; 00524 eRet ret; 00525 char stmt1[400]; 00526 int run_No =runNo; 00527 if(sftver=="default") 00528 sftver = getenv("BES_RELEASE"); 00529 const char* SftVer = sftver.c_str(); 00530 00531 if(calParVer!="default"){ 00532 const char* calpar = calParVer.c_str(); 00533 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00534 00535 } 00536 if(calParVer=="default"){ 00537 // 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); 00538 sprintf(stmt1,"select DriftDist,EntranceAng,MeanGain,GasGain,LayerGain,Resolution,WireGain,ZDep,RunGain,RunFrom,RunTo,CalParVer,FileName,Status from DedxCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00539 } 00540 00541 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00542 if(row_no<1){ 00543 std::cout<<"ERROR:error searching Dedx calibration Data in the database, check your selection criterions"<<std::endl; 00544 return RETMySQLError; 00545 } 00546 return RETOk; 00547 }
|
|
|
|
00658 { 00659 using namespace rdbModel; 00660 eRet ret; 00661 char stmt1[200]; 00662 int run_No =runNo; 00663 if(sftver=="default") 00664 sftver = getenv("BES_RELEASE"); 00665 const char* SftVer = sftver.c_str(); 00666 00667 if(calParVer!="default"){ 00668 const char* calpar = calParVer.c_str(); 00669 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00670 } 00671 if(calParVer=="default"){ 00672 sprintf(stmt1,"select TH1F_Col,bin,RunFrom,RunTo,CalParVer,FileName,Status from DedxSim where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00673 } 00674 00675 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00676 if(row_no<1){ 00677 std::cout<<"ERROR:error searching DedxSim calibration Data in the database, check your selection criterions"<<std::endl; 00678 return RETMySQLError; 00679 } 00680 return RETOk; 00681 }
|
|
|
|
00488 { 00489 using namespace rdbModel; 00490 eRet ret; 00491 char stmt1[300]; 00492 int run_No =runNo; 00493 if(sftver=="default") 00494 sftver = getenv("BES_RELEASE"); 00495 const char* SftVer = sftver.c_str(); 00496 00497 if(calParVer!="default"){ 00498 const char* calpar = calParVer.c_str(); 00499 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00500 } 00501 00502 if(calParVer=="default"){ 00503 //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); 00504 sprintf(stmt1,"select DigiCalibConst,RunFrom,RunTo,CalParVer,FileName,Status from EmcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00505 } 00506 00507 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00508 if(row_no<1){ 00509 std::cout<<"ERROR:error searching EMC calibration Data in the database, check your selection criterions"<<std::endl; 00510 return RETMySQLError; 00511 } 00512 return RETOk; 00513 }
|
|
|
|
00556 { 00557 using namespace rdbModel; 00558 eRet ret; 00559 char stmt1[400]; 00560 int run_No =runNo; 00561 if(sftver=="default") 00562 sftver = getenv("BES_RELEASE"); 00563 const char* SftVer = sftver.c_str(); 00564 00565 if(calParVer!="default"){ 00566 const char* calpar = calParVer.c_str(); 00567 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00568 } 00569 00570 if(calParVer=="default"){ 00571 sprintf(stmt1,"select EsTimeH2,EsTimeH9,RunFrom,RunTo,CalParVer,FileName,Status from EsTimeCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00572 } 00573 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00574 if(row_no<1){ 00575 std::cout<<"ERROR:error searching EsTime calibration Data in the database, check your selection criterions"<<std::endl; 00576 return RETMySQLError; 00577 } 00578 00579 return RETOk; 00580 }
|
|
|
|
00590 { 00591 using namespace rdbModel; 00592 eRet ret; 00593 char stmt1[200]; 00594 int run_No =runNo; 00595 if(sftver=="default") 00596 sftver = getenv("BES_RELEASE"); 00597 const char* SftVer = sftver.c_str(); 00598 00599 if(calParVer!="default"){ 00600 const char* calpar = calParVer.c_str(); 00601 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00602 } 00603 if(calParVer=="default"){ 00604 // 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); 00605 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status from EstTofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00606 } 00607 00608 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00609 if(row_no<1){ 00610 std::cout<<"ERROR:error searching EstTOF calibration Data in the database, check your selection criterions"<<std::endl; 00611 return RETMySQLError; 00612 } 00613 return RETOk; 00614 }
|
|
Given a calibration serial number, return information needed for caller to read in the data.
|
|
Given a calibration serial number, return information needed for caller to read in the data.
00318 { 00319 using namespace rdbModel; 00320 eRet ret; 00321 if (!m_readCxt) { 00322 connectRead(ret); 00323 if (ret != RETOk) { 00324 return ret; 00325 } 00326 } 00327 StringVector colNames(4); 00328 colNames[0] = "data_fmt"; 00329 colNames[1] = "data_ident"; 00330 colNames[2] = "RunFrom"; 00331 colNames[3] = "RunTo"; 00332 00333 std::string serNoVal; 00334 facilities::Util::itoa(serialNo, serNoVal); 00335 Assertion::Operator* serOp = 00336 new Assertion::Operator(OPTYPEequal, "ser_no", serNoVal, 00337 FIELDTYPEold, FIELDTYPElit); 00338 //false, true); 00339 Assertion whereClause(serOp); 00340 StringVector orderBy; 00341 orderBy.clear(); 00342 00343 // make the query 00344 ResultHandle* results = 0; 00345 try { 00346 00347 results = m_readCxt->select(m_table, colNames, orderBy, &whereClause); 00348 00349 } 00350 catch (RdbException ex) { 00351 std::cout << ex.getMsg(); 00352 return RETMySQLError; 00353 } 00354 00355 if (!results) return RETMySQLError; 00356 if (!results->getNRows() ) return RETBadValue; 00357 00358 std::vector<std::string> fields; 00359 std::cout<<"test id \\"<<std::endl; 00360 results->getRow(fields); 00361 dataFmt = fields[0]; 00362 filename = fields[1]; 00363 std::string runfrm,runto; 00364 runfrm=fields[2]; 00365 runto=fields[3]; 00366 *runFrm=facilities::Util::atoi(runfrm); 00367 *runTo=facilities::Util::atoi(runto); 00368 delete results; 00369 //runFrm=fields[2]; 00370 //runTo=fields[3]; 00371 // std::cout<<"runfrm is:"<<runFrm<<"runto is:"<<runTo<<std::endl; 00372 if ((dataFmt == "") || (filename == "")) return RETBadValue; 00373 return RETOk; 00374 }
|
|
|
|
00691 { 00692 using namespace rdbModel; 00693 eRet ret; 00694 char stmt1[200]; 00695 int run_No =runNo; 00696 if(sftver=="default") 00697 sftver = getenv("BES_RELEASE"); 00698 const char* SftVer = sftver.c_str(); 00699 00700 if(calParVer!="default"){ 00701 const char* calpar = calParVer.c_str(); 00702 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and MdcAlignVer = %s",SftVer,run_No,run_No,calpar); 00703 } 00704 if(calParVer=="default"){ 00705 // 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); 00706 sprintf(stmt1,"select AlignEndPlate,WirePos,WireTension,RunFrom,RunTo,MdcAlignVer,AlignEPFileName,Status from MdcAlignment where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by MdcAlignVer desc",SftVer,run_No,run_No); 00707 } 00708 00709 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00710 if(row_no<1){ 00711 std::cout<<"ERROR:error searching MdcAlignment calibration Data in the database, check your selection criterions"<<std::endl; 00712 return RETMySQLError; 00713 } 00714 00715 return RETOk; 00716 }
|
|
|
|
00451 { 00452 using namespace rdbModel; 00453 eRet ret; 00454 char stmt1[200]; 00455 int run_No =runNo; 00456 00457 if(sftver=="default") 00458 sftver = getenv("BES_RELEASE"); 00459 const char* SftVer = sftver.c_str(); 00460 00461 00462 if(calParVer!="default"){ 00463 const char* calpar = calParVer.c_str(); 00464 sprintf(stmt1,"select XtTree,QtTree,T0Tree,SdTree,RunFrom,RunTo,CalParVer,FileName,Status from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = '%s'",SftVer,run_No,run_No,calpar);} 00465 00466 if(calParVer=="default"){ 00467 //sprintf(stmt1,"select XtTree,QtTree,T0Tree,SdTree,RunFrom,RunTo,max(CalParVer),FileName from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No);} 00468 sprintf(stmt1,"select XtTree,QtTree,T0Tree,SdTree,RunFrom,RunTo,CalParVer,FileName,Status from MdcCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No);} 00469 00470 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00471 if(row_no<1){ 00472 std::cout<<"ERROR:error searching Mdc calibration Data in the database, check your selection criterions"<<std::endl; 00473 return RETMySQLError; 00474 } 00475 00476 00477 return RETOk; 00478 }
|
|
|
|
00415 { 00416 using namespace rdbModel; 00417 eRet ret; 00418 char stmt1[300]; 00419 int run_No =runNo; 00420 //char* SftVer = getenv("BES_RELEASE"); 00421 if(sftver=="default") 00422 sftver = getenv("BES_RELEASE"); 00423 const char* SftVer = sftver.c_str(); 00424 00425 if(calParVer!="default"){ 00426 const char* calpar = calParVer.c_str(); 00427 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = '%s'",SftVer,run_No,run_No,calpar); 00428 } 00429 00430 if(calParVer=="default"){ 00431 // sprintf(stmt1,"select 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); 00432 sprintf(stmt1,"select LayTree,BoxTree,StrTree,ResTree,ClsTree,RunFrom,RunTo,CalParVer,FileName,Status from MucCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00433 } 00434 00435 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00436 if(row_no<1){ 00437 std::cout<<"ERROR:error searching MUC calibration Data in the database, check your selection criterions"<<std::endl; 00438 return RETMySQLError; 00439 } 00440 00441 00442 return RETOk; 00443 }
|
|
|
|
00382 { 00383 using namespace rdbModel; 00384 eRet ret; 00385 char stmt1[300]; 00386 int run_No =runNo; 00387 if(sftver=="default") 00388 sftver = getenv("BES_RELEASE"); 00389 const char* SftVer = sftver.c_str(); 00390 00391 if(calParVer!="default"){ 00392 const char* calpar = calParVer.c_str(); 00393 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00394 } 00395 if(calParVer=="default"){ 00396 // sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,max(CalParVer),FileName from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d group by CalParVer",SftVer,run_No,run_No); 00397 sprintf(stmt1,"select BarTofPar,EndTofPar,TofConPar,BarTof,RunFrom,RunTo,CalParVer,FileName,Status from TofCalConst where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00398 } 00399 00400 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00401 if(row_no<1){ 00402 std::cout<<"ERROR:error searching TOF calibration Data in the database, check your selection criterions"<<std::endl; 00403 return RETMySQLError; 00404 } 00405 00406 return RETOk; 00407 }
|
|
|
|
00724 { 00725 using namespace rdbModel; 00726 eRet ret; 00727 char stmt1[400]; 00728 int run_No =runNo; 00729 if(sftver=="default") 00730 sftver = getenv("BES_RELEASE"); 00731 const char* SftVer = sftver.c_str(); 00732 00733 if(calParVer!="default"){ 00734 const char* calpar = calParVer.c_str(); 00735 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and CalParVer = %s",SftVer,run_No,run_No,calpar); 00736 } 00737 if(calParVer=="default"){ 00738 sprintf(stmt1,"select BarBoardNum,EndBoardNum,QELecBarParEast,QELecBarParWest,QELecEndPar,SimQELecBarParEast,SimQELecBarParWest,SimQELecEndPar,RunFrom,RunTo,CalParVer,FileName,Status from TofQELec where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by CalParVer desc",SftVer,run_No,run_No); 00739 } 00740 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00741 if(row_no<1){ 00742 std::cout<<"ERROR:error searching TofQElec calibration Data in the database, check your selection criterions"<<std::endl; 00743 return RETMySQLError; 00744 } 00745 std::cout<<"metadata ok"<<std::endl; 00746 return RETOk; 00747 }
|
|
|
|
00623 { 00624 using namespace rdbModel; 00625 eRet ret; 00626 char stmt1[200]; 00627 int run_No =runNo; 00628 if(sftver=="default") 00629 sftver = getenv("BES_RELEASE"); 00630 const char* SftVer = sftver.c_str(); 00631 00632 if(calParVer!="default"){ 00633 const char* calpar = calParVer.c_str(); 00634 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d and TofSimParVer = %s",SftVer,run_No,run_No,calpar); 00635 } 00636 if(calParVer=="default"){ 00637 // 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); 00638 sprintf(stmt1,"select BTofSim,ETofSim,SimConstants,RunFrom,RunTo,TofSimParVer,FileName,Status from TofSimSvc where SftVer = '%s' and RunFrom <= %d and RunTo >= %d order by TofSimParVer desc",SftVer,run_No,run_No); 00639 } 00640 00641 00642 int row_no = m_dbsvc->query("offlinedb", stmt1, res); 00643 if(row_no<1){ 00644 std::cout<<"ERROR:error searching TOFSim calibration Data in the database, check your selection criterions"<<std::endl; 00645 return RETMySQLError; 00646 } 00647 00648 return RETOk; 00649 }
|
|
00279 {return m_table;}
|
|
00279 {return m_table;}
|
|
|
|
00846 { 00847 00848 using namespace rdbModel; 00849 00850 eRet ret; 00851 00852 if (!m_writeCxt) { 00853 connectWrite(ret); 00854 if (ret != RETOk) return 0; // we or connectWrite should throw exception 00855 } 00856 StringVector cols; 00857 StringVector vals; 00858 StringVector nullCols; 00859 00860 cols.reserve(24); 00861 vals.reserve(24); 00862 nullCols.reserve(16); 00863 00864 if (inst.size() * calib_type.size() * flavor.size() * data_fmt.size() 00865 * data_ident.size() * proc_level.size() * completion.size() 00866 * locale.size() == 0) { // something is null that shouldn't be 00867 return 0; // should perhaps throw exception 00868 } 00869 cols.push_back("calib_type"); vals.push_back(calib_type); 00870 // cols.push_back("flavor"); vals.push_back(flavor); 00871 cols.push_back("data_fmt"); vals.push_back(data_fmt); 00872 cols.push_back("data_ident"); vals.push_back(data_ident); 00873 cols.push_back("status"); vals.push_back(completion); 00874 std::string s_runfrm,s_runto; 00875 facilities::Util::itoa(runfrm,s_runfrm); 00876 facilities::Util::itoa(runto,s_runto); 00877 cols.push_back("RunFrom"); vals.push_back(s_runfrm); 00878 cols.push_back("RunTo"); vals.push_back(s_runto); 00879 00880 // These, however, may be null 00881 if (input_desc.size() > 0 ) { 00882 cols.push_back("input_desc"); vals.push_back(input_desc); 00883 } else nullCols.push_back("input_desc"); 00884 00885 if (notes.size() > 0 ) { 00886 cols.push_back("notes"); vals.push_back(notes); 00887 } else nullCols.push_back("notes"); 00888 00889 if (fmt_version.size() > 0 ) 00890 { 00891 cols.push_back("fmt_version"); 00892 vals.push_back(fmt_version); 00893 } 00894 00895 // The service -- that's us -- is responsible for creator, uid, enter_time 00896 cols.push_back("creator"); vals.push_back("Metadata::registerCalib"); 00897 std::string uid; 00898 fetchUser(uid); 00899 cols.push_back("uid"); vals.push_back(uid); 00900 facilities::Timestamp curTime; 00901 cols.push_back("enter_time");vals.push_back(curTime.getString()); 00902 // update_time is set automatically by MySQL, but MySQL uses 00903 // local timezone rather than gmt, so we have set it explicitly 00904 cols.push_back("update_time");vals.push_back(curTime.getString()); 00905 00906 00907 if (m_rdb) { 00908 bool ok = checkValues(cols, vals); 00909 if (ok) checkNulls(nullCols); 00910 if (!ok) return 0; 00911 } 00912 00913 // ser_no gets set automatically by MySQL 00914 int ser_no; 00915 if (!(m_writeCxt->insertRow(m_table, cols, vals, &ser_no, &nullCols)) ) { 00916 return 0; 00917 } else { 00918 adjustVend(ser_no); 00919 return ser_no; 00920 } 00921 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Constant bit mask indicating all necessary fields have been set. Keep track of which columns in row have been initialized with bit mask |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|