![]() |
![]() |
#include <OnlineDB/EcalCondDB/interface/ODRunConfigCycleInfo.h>
Public Member Functions | |
int | getCycleNumber () const |
std::string | getDescription () const |
int | getId () const |
int | getSequenceID () const |
std::string | getTable () |
std::string | getTag () const |
ODRunConfigCycleInfo () | |
bool | operator!= (const ODRunConfigCycleInfo &r) const |
bool | operator== (const ODRunConfigCycleInfo &r) const |
void | setCycleNumber (int n) |
void | setDescription (std::string x) |
void | setId (int id) |
void | setSequenceID (int x) |
void | setTag (std::string x) |
~ODRunConfigCycleInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODRunConfigCycleInfo *result) throw (std::runtime_error) |
int | fetchID () throw (std::runtime_error) |
int | fetchIDLast () throw (std::runtime_error) |
void | insertConfig () throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | setByID (int id) throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
int | m_cycle_num |
std::string | m_description |
int | m_ID |
int | m_sequence_id |
std::string | m_tag |
Friends | |
class | EcalCondDBInterface |
class | ODEcalCycle |
Definition at line 14 of file ODRunConfigCycleInfo.h.
ODRunConfigCycleInfo::ODRunConfigCycleInfo | ( | ) |
Definition at line 12 of file ODRunConfigCycleInfo.cc.
References IDBObject::m_conn, m_cycle_num, m_description, IDBObject::m_env, m_ID, IODConfig::m_readStmt, m_sequence_id, m_tag, IODConfig::m_writeStmt, and NULL.
00013 { 00014 m_env = NULL; 00015 m_conn = NULL; 00016 m_writeStmt = NULL; 00017 m_readStmt = NULL; 00018 00019 m_ID=0; 00020 00021 m_sequence_id =0; 00022 m_cycle_num =0; 00023 m_tag = ""; 00024 m_description=""; 00025 }
ODRunConfigCycleInfo::~ODRunConfigCycleInfo | ( | ) |
Definition at line 32 of file ODRunConfigCycleInfo.cc.
References m_cycle_num, m_description, m_sequence_id, and m_tag.
00032 { 00033 m_sequence_id =0; 00034 m_cycle_num =0; 00035 m_tag = ""; 00036 m_description=""; 00037 00038 }
void ODRunConfigCycleInfo::fetchData | ( | ODRunConfigCycleInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 191 of file ODRunConfigCycleInfo.cc.
References IDBObject::checkConnection(), e, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
00193 { 00194 this->checkConnection(); 00195 result->clear(); 00196 if(result->getId()==0){ 00197 throw(runtime_error("ODRunConfigCycleInfo::fetchData(): no Id defined for this ODRunConfigCycleInfo ")); 00198 } 00199 00200 try { 00201 m_readStmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 "); 00202 00203 m_readStmt->setInt(1, result->getId()); 00204 ResultSet* rset = m_readStmt->executeQuery(); 00205 00206 rset->next(); 00207 00208 result->setSequenceID( rset->getInt(1) ); 00209 result->setCycleNumber( rset->getInt(2) ); 00210 result->setTag( rset->getString(3) ); 00211 result->setDescription( rset->getString(4) ); 00212 00213 } catch (SQLException &e) { 00214 throw(runtime_error("ODRunConfigCycleInfo::fetchData(): "+e.getMessage())); 00215 } 00216 }
int ODRunConfigCycleInfo::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 92 of file ODRunConfigCycleInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, m_cycle_num, IDBObject::m_env, m_ID, m_sequence_id, and setByID().
00094 { 00095 // Return from memory if available 00096 if (m_ID>0) { 00097 return m_ID; 00098 } 00099 00100 this->checkConnection(); 00101 00102 00103 DateHandler dh(m_env, m_conn); 00104 00105 try { 00106 Statement* stmt = m_conn->createStatement(); 00107 stmt->setSQL("SELECT cycle_id from ECAL_cycle_DAT " 00108 "WHERE sequence_id = :id1 " 00109 " and cycle_num = :id2 " ); 00110 stmt->setInt(1, m_sequence_id); 00111 stmt->setInt(2, m_cycle_num); 00112 00113 ResultSet* rset = stmt->executeQuery(); 00114 00115 if (rset->next()) { 00116 m_ID = rset->getInt(1); 00117 } else { 00118 m_ID = 0; 00119 } 00120 m_conn->terminateStatement(stmt); 00121 } catch (SQLException &e) { 00122 throw(runtime_error("ODRunConfigCycleInfo::fetchID: "+e.getMessage())); 00123 } 00124 setByID(m_ID); 00125 00126 return m_ID; 00127 }
int ODRunConfigCycleInfo::fetchIDLast | ( | ) | throw (std::runtime_error) [private] |
Definition at line 131 of file ODRunConfigCycleInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, m_ID, and setByID().
00133 { 00134 00135 this->checkConnection(); 00136 00137 DateHandler dh(m_env, m_conn); 00138 00139 try { 00140 Statement* stmt = m_conn->createStatement(); 00141 stmt->setSQL("SELECT max(cycle_id) FROM ecal_cycle_dat " ); 00142 ResultSet* rset = stmt->executeQuery(); 00143 00144 if (rset->next()) { 00145 m_ID = rset->getInt(1); 00146 } else { 00147 m_ID = 0; 00148 } 00149 m_conn->terminateStatement(stmt); 00150 } catch (SQLException &e) { 00151 throw(runtime_error("ODRunConfigCycleInfo::fetchIDLast: "+e.getMessage())); 00152 } 00153 00154 setByID(m_ID); 00155 return m_ID; 00156 }
int ODRunConfigCycleInfo::getCycleNumber | ( | ) | const [inline] |
Definition at line 40 of file ODRunConfigCycleInfo.h.
References m_cycle_num.
00040 {return m_cycle_num; }
std::string ODRunConfigCycleInfo::getDescription | ( | ) | const [inline] |
Definition at line 31 of file ODRunConfigCycleInfo.h.
References m_description.
00031 { return m_description;}
int ODRunConfigCycleInfo::getId | ( | ) | const [inline] |
Definition at line 26 of file ODRunConfigCycleInfo.h.
References m_ID.
Referenced by ODEcalCycle::writeDB().
00026 { return m_ID; }
int ODRunConfigCycleInfo::getSequenceID | ( | ) | const [inline] |
Definition at line 37 of file ODRunConfigCycleInfo.h.
References m_sequence_id.
00037 { return m_sequence_id;}
std::string ODRunConfigCycleInfo::getTable | ( | ) | [inline, virtual] |
std::string ODRunConfigCycleInfo::getTag | ( | void | ) | const [inline] |
void ODRunConfigCycleInfo::insertConfig | ( | ) | throw (std::runtime_error) [private] |
Definition at line 218 of file ODRunConfigCycleInfo.cc.
References e, IDBObject::m_conn, prepareWrite(), IODConfig::terminateWriteStatement(), and writeDB().
Referenced by ODEcalCycle::writeDB().
00220 { 00221 try { 00222 00223 prepareWrite(); 00224 writeDB(); 00225 m_conn->commit(); 00226 terminateWriteStatement(); 00227 } catch (std::runtime_error &e) { 00228 m_conn->rollback(); 00229 throw(e); 00230 } catch (...) { 00231 m_conn->rollback(); 00232 throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught")); 00233 } 00234 }
bool ODRunConfigCycleInfo::operator!= | ( | const ODRunConfigCycleInfo & | r | ) | const [inline] |
bool ODRunConfigCycleInfo::operator== | ( | const ODRunConfigCycleInfo & | r | ) | const [inline] |
void ODRunConfigCycleInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 40 of file ODRunConfigCycleInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, and IODConfig::m_writeStmt.
Referenced by insertConfig().
00042 { 00043 this->checkConnection(); 00044 00045 try { 00046 m_writeStmt = m_conn->createStatement(); 00047 m_writeStmt->setSQL("INSERT INTO ECAL_CYCLE_DAT ( sequence_id , cycle_num, tag, description ) " 00048 "VALUES (:1, :2, :3 , :4 )"); 00049 00050 } catch (SQLException &e) { 00051 throw(runtime_error("ODRunConfigCycleInfo::prepareWrite(): "+e.getMessage())); 00052 } 00053 }
Definition at line 159 of file ODRunConfigCycleInfo.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), id, IDBObject::m_conn, m_cycle_num, m_description, IDBObject::m_env, m_ID, m_sequence_id, and m_tag.
Referenced by fetchID(), and fetchIDLast().
00161 { 00162 this->checkConnection(); 00163 00164 DateHandler dh(m_env, m_conn); 00165 00166 cout<< "ODRunConfigCycleInfo::setByID called for id "<<id<<endl; 00167 00168 try { 00169 Statement* stmt = m_conn->createStatement(); 00170 00171 stmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 "); 00172 stmt->setInt(1, id); 00173 00174 ResultSet* rset = stmt->executeQuery(); 00175 if (rset->next()) { 00176 m_sequence_id=rset->getInt(1); 00177 m_cycle_num=rset->getInt(2); 00178 m_tag = rset->getString(3); 00179 m_description= rset->getString(4); 00180 m_ID = id; 00181 } else { 00182 throw(runtime_error("ODRunConfigCycleInfo::setByID: Given cycle_id is not in the database")); 00183 } 00184 m_conn->terminateStatement(stmt); 00185 } catch (SQLException &e) { 00186 throw(runtime_error("ODRunConfigCycleInfo::setByID: "+e.getMessage())); 00187 } 00188 }
Definition at line 39 of file ODRunConfigCycleInfo.h.
References m_cycle_num.
Referenced by ODEcalCycle::writeDB().
00039 { m_cycle_num = n; }
void ODRunConfigCycleInfo::setDescription | ( | std::string | x | ) | [inline] |
Definition at line 30 of file ODRunConfigCycleInfo.h.
References m_description.
Referenced by ODEcalCycle::writeDB().
00030 { m_description = x;}
Definition at line 36 of file ODRunConfigCycleInfo.h.
References m_sequence_id.
Referenced by ODEcalCycle::writeDB().
00036 { m_sequence_id = x;}
void ODRunConfigCycleInfo::setTag | ( | std::string | x | ) | [inline] |
Definition at line 33 of file ODRunConfigCycleInfo.h.
References m_tag.
Referenced by ODEcalCycle::writeDB().
void ODRunConfigCycleInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 56 of file ODRunConfigCycleInfo.cc.
References IDBObject::checkConnection(), IODConfig::checkPrepare(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), IDBObject::m_conn, IDBObject::m_env, m_ID, and IODConfig::m_writeStmt.
Referenced by insertConfig().
00058 { 00059 this->checkConnection(); 00060 this->checkPrepare(); 00061 00062 // Validate the data, use infinity-till convention 00063 DateHandler dh(m_env, m_conn); 00064 00065 try { 00066 00067 m_writeStmt->setInt(1, this->getSequenceID()); 00068 m_writeStmt->setInt(2, this->getCycleNumber()); 00069 m_writeStmt->setString(3, this->getTag()); 00070 m_writeStmt->setString(4, this->getDescription()); 00071 m_writeStmt->executeUpdate(); 00072 00073 00074 00075 } catch (SQLException &e) { 00076 throw(runtime_error("ODRunConfigCycleInfo::writeDB: "+e.getMessage())); 00077 } 00078 // Now get the ID 00079 if (!this->fetchID()) { 00080 throw(runtime_error("ODRunConfigCycleInfo::writeDB: Failed to write")); 00081 } 00082 00083 cout<< "ODRunConfigCycleInfo::writeDB>> done inserting ODRunConfigCycleInfo with id="<<m_ID<<endl; 00084 00085 }
friend class EcalCondDBInterface [friend] |
friend class ODEcalCycle [friend] |
Definition at line 17 of file ODRunConfigCycleInfo.h.
int ODRunConfigCycleInfo::m_cycle_num [private] |
Definition at line 53 of file ODRunConfigCycleInfo.h.
Referenced by clear(), fetchID(), getCycleNumber(), ODRunConfigCycleInfo(), setByID(), and setCycleNumber().
std::string ODRunConfigCycleInfo::m_description [private] |
Definition at line 55 of file ODRunConfigCycleInfo.h.
Referenced by clear(), getDescription(), ODRunConfigCycleInfo(), setByID(), and setDescription().
int ODRunConfigCycleInfo::m_ID [private] |
Definition at line 51 of file ODRunConfigCycleInfo.h.
Referenced by fetchID(), fetchIDLast(), getId(), ODRunConfigCycleInfo(), operator==(), setByID(), setId(), and writeDB().
int ODRunConfigCycleInfo::m_sequence_id [private] |
Definition at line 52 of file ODRunConfigCycleInfo.h.
Referenced by clear(), fetchID(), getSequenceID(), ODRunConfigCycleInfo(), setByID(), and setSequenceID().
std::string ODRunConfigCycleInfo::m_tag [private] |
Definition at line 54 of file ODRunConfigCycleInfo.h.
Referenced by clear(), getTag(), ODRunConfigCycleInfo(), setByID(), and setTag().