#include <OnlineDB/EcalCondDB/interface/ODRunConfigInfo.h>
Definition at line 12 of file ODRunConfigInfo.h.
ODRunConfigInfo::ODRunConfigInfo | ( | ) |
Definition at line 12 of file ODRunConfigInfo.cc.
References IDBObject::m_conn, m_defaults, m_ID, m_num_events, m_num_seq, m_runModeDef, m_runTypeDef, m_tag, m_trigger_mode, m_version, and NULL.
00013 { 00014 m_conn = NULL; 00015 m_ID = 0; 00016 // 00017 m_tag =""; 00018 m_version=0; 00019 m_num_seq=0; 00020 m_runTypeDef = RunTypeDef(); 00021 m_runModeDef = RunModeDef(); 00022 m_defaults=0; 00023 m_trigger_mode=""; 00024 m_num_events=0; 00025 }
ODRunConfigInfo::~ODRunConfigInfo | ( | ) |
void ODRunConfigInfo::fetchData | ( | ODRunConfigInfo * | result | ) | throw (std::runtime_error) [private] |
int ODRunConfigInfo::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 74 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, m_ID, m_tag, m_version, and setByID().
Referenced by fetchIDFromTagAndVersion().
00076 { 00077 // Return from memory if available 00078 if (m_ID>0) { 00079 return m_ID; 00080 } 00081 00082 this->checkConnection(); 00083 00084 00085 DateHandler dh(m_env, m_conn); 00086 00087 try { 00088 Statement* stmt = m_conn->createStatement(); 00089 stmt->setSQL("SELECT config_id from ECAL_RUN_CONFIGURATION_DAT " 00090 "WHERE tag = :tag " 00091 " and version = :version " ); 00092 stmt->setString(1, m_tag); 00093 stmt->setInt(2, m_version); 00094 00095 ResultSet* rset = stmt->executeQuery(); 00096 00097 if (rset->next()) { 00098 m_ID = rset->getInt(1); 00099 } else { 00100 m_ID = 0; 00101 } 00102 m_conn->terminateStatement(stmt); 00103 } catch (SQLException &e) { 00104 throw(runtime_error("ODRunConfigInfo::fetchID: "+e.getMessage())); 00105 } 00106 setByID(m_ID); 00107 return m_ID; 00108 }
int ODRunConfigInfo::fetchIDFromTagAndVersion | ( | ) | throw (std::runtime_error) [private] |
int ODRunConfigInfo::fetchIDLast | ( | ) | throw (std::runtime_error) [private] |
Definition at line 112 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, m_ID, and setByID().
00114 { 00115 00116 this->checkConnection(); 00117 00118 DateHandler dh(m_env, m_conn); 00119 00120 try { 00121 Statement* stmt = m_conn->createStatement(); 00122 stmt->setSQL("SELECT max(config_id) FROM ecal_run_configuration_dat " ); 00123 ResultSet* rset = stmt->executeQuery(); 00124 00125 if (rset->next()) { 00126 m_ID = rset->getInt(1); 00127 } else { 00128 m_ID = 0; 00129 } 00130 m_conn->terminateStatement(stmt); 00131 } catch (SQLException &e) { 00132 throw(runtime_error("ODRunConfigInfo::fetchIDLast: "+e.getMessage())); 00133 } 00134 00135 setByID(m_ID); 00136 return m_ID; 00137 }
int ODRunConfigInfo::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 53 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00053 { 00054 00055 int result=0; 00056 try { 00057 this->checkConnection(); 00058 00059 m_readStmt = m_conn->createStatement(); 00060 m_readStmt->setSQL("select ecal_run_sq.NextVal from dual"); 00061 ResultSet* rset = m_readStmt->executeQuery(); 00062 while (rset->next ()){ 00063 result= rset->getInt(1); 00064 } 00065 m_conn->terminateStatement(m_readStmt); 00066 return result; 00067 00068 } catch (SQLException &e) { 00069 throw(runtime_error("ODDCCConfig::fetchNextId(): "+e.getMessage())); 00070 } 00071 00072 }
Tm ODRunConfigInfo::getDBTime | ( | ) | const [inline] |
int ODRunConfigInfo::getDefaults | ( | ) | const [inline] |
std::string ODRunConfigInfo::getDescription | ( | ) | const [inline] |
Definition at line 31 of file ODRunConfigInfo.h.
References m_description.
00031 { return m_description;}
int ODRunConfigInfo::getId | ( | ) | const [inline] |
int ODRunConfigInfo::getNumberOfEvents | ( | ) | const [inline] |
Definition at line 46 of file ODRunConfigInfo.h.
References m_num_events.
00046 { return m_num_events ;}
int ODRunConfigInfo::getNumberOfSequences | ( | ) | const [inline] |
RunModeDef ODRunConfigInfo::getRunModeDef | ( | ) | const |
Definition at line 43 of file ODRunConfigInfo.cc.
References m_runModeDef.
00043 { return m_runModeDef;}
RunTypeDef ODRunConfigInfo::getRunTypeDef | ( | ) | const |
Definition at line 34 of file ODRunConfigInfo.cc.
References m_runTypeDef.
00034 { return m_runTypeDef;}
std::string ODRunConfigInfo::getTable | ( | ) | [inline, virtual] |
std::string ODRunConfigInfo::getTag | ( | void | ) | const [inline] |
std::string ODRunConfigInfo::getTriggerMode | ( | ) | const [inline] |
Definition at line 43 of file ODRunConfigInfo.h.
References m_trigger_mode.
00043 { return m_trigger_mode;}
int ODRunConfigInfo::getVersion | ( | ) | const [inline] |
bool ODRunConfigInfo::operator!= | ( | const ODRunConfigInfo & | r | ) | const [inline] |
bool ODRunConfigInfo::operator== | ( | const ODRunConfigInfo & | r | ) | const [inline] |
void ODRunConfigInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 194 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), e, fetchNextId(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00196 { 00197 this->checkConnection(); 00198 00199 int next_id=fetchNextId(); 00200 00201 00202 00203 00204 try { 00205 m_writeStmt = m_conn->createStatement(); 00206 m_writeStmt->setSQL("INSERT INTO ECAL_RUN_CONFIGURATION_DAT (CONFIG_ID, tag, version, run_type_def_id, " 00207 " run_mode_def_id, num_of_sequences, defaults, trg_mode, num_of_events, description ) " 00208 " VALUES (:1, :2, :3 , :4, :5, :6 ,:7, :8, :9, :10 )"); 00209 00210 m_writeStmt->setInt(1, next_id); 00211 m_ID=next_id; 00212 00213 } catch (SQLException &e) { 00214 throw(runtime_error("ODRunConfigInfo::prepareWrite(): "+e.getMessage())); 00215 } 00216 }
Definition at line 149 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, DateHandler::dateToTm(), e, lat::endl(), id, IDBObject::m_conn, m_db_time, m_defaults, m_description, IDBObject::m_env, m_ID, m_num_events, m_num_seq, m_runModeDef, m_runTypeDef, m_tag, m_trigger_mode, m_version, RunTypeDef::setByID(), RunModeDef::setByID(), and IDBObject::setConnection().
Referenced by fetchID(), fetchIDLast(), and writeDB().
00151 { 00152 this->checkConnection(); 00153 00154 DateHandler dh(m_env, m_conn); 00155 00156 cout<< "ODRunConfigInfo::setByID called for id "<<id<<endl; 00157 00158 try { 00159 Statement* stmt = m_conn->createStatement(); 00160 00161 stmt->setSQL("SELECT tag, version, run_type_def_id, run_mode_def_id, num_of_sequences, description, defaults," 00162 " trg_mode,num_of_events, db_timestamp" 00163 " FROM ECAL_RUN_CONFIGURATION_DAT WHERE config_id = :1"); 00164 stmt->setInt(1, id); 00165 00166 ResultSet* rset = stmt->executeQuery(); 00167 if (rset->next()) { 00168 m_tag= rset->getString(1); 00169 m_version= rset->getInt(2); 00170 int run_type_id=rset->getInt(3); 00171 int run_mode_id=rset->getInt(4); 00172 m_num_seq=rset->getInt(5); 00173 m_description= rset->getString(6); 00174 m_defaults= rset->getInt(7); 00175 m_trigger_mode= rset->getString(8); 00176 m_num_events= rset->getInt(9); 00177 Date dbdate = rset->getDate(10); 00178 m_db_time = dh.dateToTm( dbdate ); 00179 m_ID = id; 00180 m_runModeDef.setConnection(m_env, m_conn); 00181 m_runModeDef.setByID(run_mode_id); 00182 m_runTypeDef.setConnection(m_env, m_conn); 00183 m_runTypeDef.setByID(run_type_id); 00184 00185 } else { 00186 throw(runtime_error("ODRunConfigInfo::setByID: Given config_id is not in the database")); 00187 } 00188 m_conn->terminateStatement(stmt); 00189 } catch (SQLException &e) { 00190 throw(runtime_error("ODRunConfigInfo::setByID: "+e.getMessage())); 00191 } 00192 }
void ODRunConfigInfo::setDescription | ( | std::string | x | ) | [inline] |
Definition at line 30 of file ODRunConfigInfo.h.
References m_description.
00030 { m_description = x;}
Definition at line 45 of file ODRunConfigInfo.h.
References m_num_events.
00045 { m_num_events = x ;}
void ODRunConfigInfo::setRunModeDef | ( | const RunModeDef | runModeDef | ) |
Definition at line 44 of file ODRunConfigInfo.cc.
References m_ID, and m_runModeDef.
00045 { 00046 if (runModeDef != m_runModeDef) { 00047 m_ID = 0; 00048 m_runModeDef = runModeDef; 00049 } 00050 }
void ODRunConfigInfo::setRunTypeDef | ( | const RunTypeDef | runTypeDef | ) |
Definition at line 35 of file ODRunConfigInfo.cc.
References m_ID, and m_runTypeDef.
00036 { 00037 if (runTypeDef != m_runTypeDef) { 00038 m_ID = 0; 00039 m_runTypeDef = runTypeDef; 00040 } 00041 }
void ODRunConfigInfo::setTag | ( | std::string | x | ) | [inline] |
void ODRunConfigInfo::setTriggerMode | ( | std::string | x | ) | [inline] |
Definition at line 42 of file ODRunConfigInfo.h.
References m_trigger_mode.
00042 { m_trigger_mode = x;}
int ODRunConfigInfo::updateDefaultCycle | ( | ) | throw (runtime_error) [private] |
Definition at line 266 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, m_defaults, m_ID, and writeDB().
00268 { 00269 this->checkConnection(); 00270 00271 // Check if this has already been written 00272 if(!this->fetchID()){ 00273 this->writeDB(); 00274 } 00275 00276 00277 try { 00278 Statement* stmt = m_conn->createStatement(); 00279 00280 stmt->setSQL("UPDATE ecal_run_configuration_dat set defaults=:1 where config_id=:2 " ); 00281 00282 stmt->setInt(1, m_defaults); 00283 stmt->setInt(2, m_ID); 00284 00285 stmt->executeUpdate(); 00286 00287 m_conn->terminateStatement(stmt); 00288 } catch (SQLException &e) { 00289 throw(runtime_error("ODRunConfigInfo::writeDB: "+e.getMessage())); 00290 } 00291 00292 return m_ID; 00293 }
void ODRunConfigInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 219 of file ODRunConfigInfo.cc.
References IDBObject::checkConnection(), IODConfig::checkPrepare(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), RunModeDef::fetchID(), RunTypeDef::fetchID(), IDBObject::m_conn, IDBObject::m_env, m_ID, m_runModeDef, m_runTypeDef, IODConfig::m_writeStmt, setByID(), and IDBObject::setConnection().
Referenced by updateDefaultCycle().
00221 { 00222 this->checkConnection(); 00223 this->checkPrepare(); 00224 00225 // Validate the data, use infinity-till convention 00226 DateHandler dh(m_env, m_conn); 00227 00228 try { 00229 00230 // get the run mode 00231 m_runModeDef.setConnection(m_env, m_conn); 00232 int run_mode_id = m_runModeDef.fetchID(); 00233 00234 // get the run type 00235 m_runTypeDef.setConnection(m_env, m_conn); 00236 int run_type_id = m_runTypeDef.fetchID(); 00237 00238 // now insert 00239 00240 m_writeStmt->setString(2, this->getTag()); 00241 m_writeStmt->setInt(3, this->getVersion()); 00242 m_writeStmt->setInt(4, run_type_id); 00243 m_writeStmt->setInt(5, run_mode_id); 00244 m_writeStmt->setInt(6, this->getNumberOfSequences()); 00245 m_writeStmt->setInt(7, this->getDefaults()); 00246 m_writeStmt->setString(8, this->getTriggerMode()); 00247 m_writeStmt->setInt(9, this->getNumberOfEvents()); 00248 m_writeStmt->setString(10, this->getDescription()); 00249 00250 m_writeStmt->executeUpdate(); 00251 00252 } catch (SQLException &e) { 00253 throw(runtime_error("ODRunConfigInfo::writeDB: "+e.getMessage())); 00254 } 00255 // Now get the ID 00256 if (!this->fetchID()) { 00257 throw(runtime_error("ODRunConfigInfo::writeDB Failed to write")); 00258 } 00259 00260 this->setByID(m_ID); 00261 00262 cout<< "ODRunConfigInfo::writeDB>> done inserting ODRunConfigInfo with id="<<m_ID<<endl; 00263 }
friend class EcalCondDBInterface [friend] |
Tm ODRunConfigInfo::m_db_time [private] |
int ODRunConfigInfo::m_defaults [private] |
Definition at line 70 of file ODRunConfigInfo.h.
Referenced by getDefaults(), ODRunConfigInfo(), setByID(), setDefaults(), and updateDefaultCycle().
std::string ODRunConfigInfo::m_description [private] |
Definition at line 69 of file ODRunConfigInfo.h.
Referenced by getDescription(), setByID(), and setDescription().
int ODRunConfigInfo::m_ID [private] |
Definition at line 62 of file ODRunConfigInfo.h.
Referenced by fetchID(), fetchIDFromTagAndVersion(), fetchIDLast(), getId(), ODRunConfigInfo(), operator==(), prepareWrite(), setByID(), setId(), setRunModeDef(), setRunTypeDef(), updateDefaultCycle(), and writeDB().
int ODRunConfigInfo::m_num_events [private] |
Definition at line 72 of file ODRunConfigInfo.h.
Referenced by getNumberOfEvents(), ODRunConfigInfo(), setByID(), and setNumberOfEvents().
int ODRunConfigInfo::m_num_seq [private] |
Definition at line 68 of file ODRunConfigInfo.h.
Referenced by getNumberOfSequences(), ODRunConfigInfo(), setByID(), and setNumberOfSequences().
RunModeDef ODRunConfigInfo::m_runModeDef [private] |
Definition at line 66 of file ODRunConfigInfo.h.
Referenced by getRunModeDef(), ODRunConfigInfo(), setByID(), setRunModeDef(), and writeDB().
RunTypeDef ODRunConfigInfo::m_runTypeDef [private] |
Definition at line 67 of file ODRunConfigInfo.h.
Referenced by getRunTypeDef(), ODRunConfigInfo(), setByID(), setRunTypeDef(), and writeDB().
std::string ODRunConfigInfo::m_tag [private] |
Definition at line 64 of file ODRunConfigInfo.h.
Referenced by fetchID(), getTag(), ODRunConfigInfo(), setByID(), and setTag().
std::string ODRunConfigInfo::m_trigger_mode [private] |
Definition at line 71 of file ODRunConfigInfo.h.
Referenced by getTriggerMode(), ODRunConfigInfo(), setByID(), and setTriggerMode().
int ODRunConfigInfo::m_version [private] |
Definition at line 65 of file ODRunConfigInfo.h.
Referenced by fetchID(), getVersion(), ODRunConfigInfo(), setByID(), and setVersion().