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