#include <OnlineDB/EcalCondDB/interface/ODFEDelaysInfo.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
int | fetchNextId () throw (std::runtime_error) |
int | getId () const |
std::string | getTable () |
int | getVersion () const |
ODFEDelaysInfo () | |
void | setId (int id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setVersion (int id) |
~ODFEDelaysInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODFEDelaysInfo *result) throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
int | m_ID |
int | m_version |
Friends | |
class | EcalCondDBInterface |
Definition at line 9 of file ODFEDelaysInfo.h.
ODFEDelaysInfo::ODFEDelaysInfo | ( | ) |
Definition at line 11 of file ODFEDelaysInfo.cc.
References clear(), IODConfig::m_config_tag, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, IODConfig::m_writeStmt, and NULL.
00012 { 00013 m_env = NULL; 00014 m_conn = NULL; 00015 m_writeStmt = NULL; 00016 m_readStmt = NULL; 00017 m_config_tag=""; 00018 m_ID=0; 00019 clear(); 00020 }
ODFEDelaysInfo::~ODFEDelaysInfo | ( | ) |
Definition at line 23 of file ODFEDelaysInfo.cc.
References m_version.
Referenced by ODFEDelaysInfo().
00023 { 00024 m_version=0; 00025 00026 }
void ODFEDelaysInfo::fetchData | ( | ODFEDelaysInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 124 of file ODFEDelaysInfo.cc.
References IDBObject::checkConnection(), e, getTable(), IODConfig::m_readStmt, and HLT_VtxMuL3::result.
00126 { 00127 this->checkConnection(); 00128 result->clear(); 00129 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00130 throw(runtime_error("ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo ")); 00131 } 00132 00133 try { 00134 00135 m_readStmt->setSQL("SELECT * FROM " + getTable() + 00136 " where ( rec_id = :1 or (tag=:2 AND version=:3 ) )" ); 00137 m_readStmt->setInt(1, result->getId()); 00138 m_readStmt->setString(2, result->getConfigTag()); 00139 m_readStmt->setInt(3, result->getVersion()); 00140 ResultSet* rset = m_readStmt->executeQuery(); 00141 00142 rset->next(); 00143 00144 // 1 is the id and 2 is the config tag and 3 is the version 00145 00146 result->setId(rset->getInt(1)); 00147 result->setConfigTag(rset->getString(2)); 00148 result->setVersion(rset->getInt(3)); 00149 00150 } catch (SQLException &e) { 00151 throw(runtime_error("ODFEDelaysInfo::fetchData(): "+e.getMessage())); 00152 } 00153 }
int ODFEDelaysInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 155 of file ODFEDelaysInfo.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), getTable(), getVersion(), IDBObject::m_conn, and m_ID.
00156 { 00157 // Return from memory if available 00158 if (m_ID!=0) { 00159 return m_ID; 00160 } 00161 00162 this->checkConnection(); 00163 00164 try { 00165 Statement* stmt = m_conn->createStatement(); 00166 stmt->setSQL("SELECT rec_id FROM "+ getTable()+ 00167 "WHERE tag=:1 and version=:2 " ); 00168 00169 stmt->setString(1, getConfigTag() ); 00170 stmt->setInt(2, getVersion() ); 00171 00172 ResultSet* rset = stmt->executeQuery(); 00173 00174 if (rset->next()) { 00175 m_ID = rset->getInt(1); 00176 } else { 00177 m_ID = 0; 00178 } 00179 m_conn->terminateStatement(stmt); 00180 } catch (SQLException &e) { 00181 throw(runtime_error("ODFEDelaysInfo::fetchID: "+e.getMessage())); 00182 } 00183 00184 return m_ID; 00185 }
int ODFEDelaysInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 36 of file ODFEDelaysInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00036 { 00037 00038 int result=0; 00039 try { 00040 this->checkConnection(); 00041 00042 m_readStmt = m_conn->createStatement(); 00043 m_readStmt->setSQL("select COND2CONF_INFO_SQ.NextVal from DUAL "); 00044 ResultSet* rset = m_readStmt->executeQuery(); 00045 while (rset->next ()){ 00046 result= rset->getInt(1); 00047 } 00048 result++; 00049 m_conn->terminateStatement(m_readStmt); 00050 return result; 00051 00052 } catch (SQLException &e) { 00053 throw(runtime_error("ODFEDelaysInfo::fetchNextId(): "+e.getMessage())); 00054 } 00055 00056 }
int ODFEDelaysInfo::getId | ( | ) | const [inline] |
Definition at line 19 of file ODFEDelaysInfo.h.
References m_ID.
Referenced by prepareWrite().
00019 { return m_ID; }
std::string ODFEDelaysInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 16 of file ODFEDelaysInfo.h.
Referenced by fetchData(), fetchID(), and prepareWrite().
int ODFEDelaysInfo::getVersion | ( | ) | const [inline] |
Definition at line 24 of file ODFEDelaysInfo.h.
References m_version.
Referenced by fetchID().
00024 { return m_version; }
void ODFEDelaysInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 58 of file ODFEDelaysInfo.cc.
References IDBObject::checkConnection(), e, fetchNextId(), getId(), getTable(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00060 { 00061 this->checkConnection(); 00062 00063 int next_id=0; 00064 if(getId()==0){ 00065 next_id=fetchNextId(); 00066 } 00067 00068 try { 00069 m_writeStmt = m_conn->createStatement(); 00070 m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( rec_id, tag, version) " 00071 " VALUES ( :1, :2, :3 ) " ); 00072 00073 m_writeStmt->setInt(1, next_id); 00074 m_ID=next_id; 00075 00076 } catch (SQLException &e) { 00077 throw(runtime_error("ODFEDelaysInfo::prepareWrite(): "+e.getMessage())); 00078 } 00079 00080 }
void ODFEDelaysInfo::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 82 of file ODFEDelaysInfo.cc.
References IODConfig::setConfigTag(), and setVersion().
00082 { 00083 00084 // parses the result of the XML parser that is a map of 00085 // string string with variable name variable value 00086 00087 for( std::map<std::string, std::string >::iterator ci= 00088 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00089 00090 if(ci->first== "VERSION") setVersion(atoi(ci->second.c_str()) ); 00091 if(ci->first== "TAG") setConfigTag(ci->second); 00092 00093 } 00094 00095 }
Definition at line 23 of file ODFEDelaysInfo.h.
References m_version.
Referenced by setParameters().
void ODFEDelaysInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 97 of file ODFEDelaysInfo.cc.
References IDBObject::checkConnection(), IODConfig::checkPrepare(), e, and IODConfig::m_writeStmt.
00099 { 00100 this->checkConnection(); 00101 this->checkPrepare(); 00102 00103 try { 00104 00105 // number 1 is the id 00106 m_writeStmt->setString(2, this->getConfigTag()); 00107 m_writeStmt->setInt(3, this->getVersion()); 00108 00109 m_writeStmt->executeUpdate(); 00110 00111 00112 } catch (SQLException &e) { 00113 throw(runtime_error("ODFEDelaysInfo::writeDB(): "+e.getMessage())); 00114 } 00115 // Now get the ID 00116 if (!this->fetchID()) { 00117 throw(runtime_error("ODFEDelaysInfo::writeDB: Failed to write")); 00118 } 00119 00120 00121 }
friend class EcalCondDBInterface [friend] |
int ODFEDelaysInfo::m_ID [private] |
Definition at line 42 of file ODFEDelaysInfo.h.
Referenced by fetchID(), getId(), ODFEDelaysInfo(), prepareWrite(), and setId().
int ODFEDelaysInfo::m_version [private] |
Definition at line 43 of file ODFEDelaysInfo.h.
Referenced by clear(), getVersion(), and setVersion().