#include <OnlineDB/EcalCondDB/interface/FEConfigFgrInfo.h>
Public Member Functions | |
FEConfigFgrInfo () | |
int | fetchID () throw (std::runtime_error) |
int | fetchNextId () throw (std::runtime_error) |
Tm | getDBTime () const |
int | getID () |
int | getId () const |
int | getNumberOfGroups () const |
std::string | getTable () |
int | getVersion () const |
bool | operator!= (const FEConfigFgrInfo &r) const |
bool | operator== (const FEConfigFgrInfo &r) const |
void | setByID (int id) throw (std::runtime_error) |
void | setDBTime (Tm x) |
void | setID (int id) |
void | setId (int id) |
void | setNumberOfGroups (int iov_id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setVersion (int id) |
~FEConfigFgrInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (FEConfigFgrInfo *result) throw (std::runtime_error) |
void | fetchLastData (FEConfigFgrInfo *result) throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
Tm | m_db_time |
int | m_ID |
int | m_iov_id |
int | m_version |
Friends | |
class | EcalCondDBInterface |
Definition at line 11 of file FEConfigFgrInfo.h.
FEConfigFgrInfo::FEConfigFgrInfo | ( | ) |
Definition at line 13 of file FEConfigFgrInfo.cc.
References clear(), IODConfig::m_config_tag, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, m_version, IODConfig::m_writeStmt, and NULL.
00014 { 00015 m_env = NULL; 00016 m_conn = NULL; 00017 m_writeStmt = NULL; 00018 m_readStmt = NULL; 00019 m_config_tag=""; 00020 m_version=0; 00021 m_ID=0; 00022 clear(); 00023 }
FEConfigFgrInfo::~FEConfigFgrInfo | ( | ) |
Definition at line 26 of file FEConfigFgrInfo.cc.
References m_iov_id.
Referenced by FEConfigFgrInfo().
00026 { 00027 m_iov_id=0; 00028 }
void FEConfigFgrInfo::fetchData | ( | FEConfigFgrInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 128 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), DateHandler::dateToTm(), e, getTable(), IDBObject::m_conn, IDBObject::m_env, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
00130 { 00131 this->checkConnection(); 00132 result->clear(); 00133 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00134 throw(runtime_error("FEConfigFgrInfo::fetchData(): no Id defined for this FEConfigFgrInfo ")); 00135 } 00136 00137 try { 00138 DateHandler dh(m_env, m_conn); 00139 00140 m_readStmt->setSQL("SELECT * FROM " + getTable() + 00141 " where ( fgr_conf_id= :1 or (tag=:2 AND version=:3 ) )" ); 00142 m_readStmt->setInt(1, result->getId()); 00143 m_readStmt->setString(2, result->getConfigTag()); 00144 m_readStmt->setInt(3, result->getVersion()); 00145 ResultSet* rset = m_readStmt->executeQuery(); 00146 00147 rset->next(); 00148 00149 // 1 is the id and 2 is the config tag and 3 is the version 00150 00151 result->setId(rset->getInt(1)); 00152 result->setConfigTag(rset->getString(2)); 00153 result->setVersion(rset->getInt(3)); 00154 result->setNumberOfGroups(rset->getInt(4)); 00155 Date dbdate = rset->getDate(5); 00156 result->setDBTime( dh.dateToTm( dbdate )); 00157 00158 } catch (SQLException &e) { 00159 throw(runtime_error("FEConfigFgrInfo::fetchData(): "+e.getMessage())); 00160 } 00161 }
int FEConfigFgrInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 189 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), getTable(), getVersion(), IDBObject::m_conn, and m_ID.
00190 { 00191 // Return from memory if available 00192 if (m_ID!=0) { 00193 return m_ID; 00194 } 00195 00196 this->checkConnection(); 00197 00198 try { 00199 Statement* stmt = m_conn->createStatement(); 00200 stmt->setSQL("SELECT fgr_conf_id FROM "+ getTable()+ 00201 " WHERE tag=:1 and version=:2 " ); 00202 00203 stmt->setString(1, getConfigTag() ); 00204 stmt->setInt(2, getVersion() ); 00205 00206 ResultSet* rset = stmt->executeQuery(); 00207 00208 if (rset->next()) { 00209 m_ID = rset->getInt(1); 00210 } else { 00211 m_ID = 0; 00212 } 00213 m_conn->terminateStatement(stmt); 00214 } catch (SQLException &e) { 00215 throw(runtime_error("FEConfigFgrInfo::fetchID: "+e.getMessage())); 00216 } 00217 00218 return m_ID; 00219 }
void FEConfigFgrInfo::fetchLastData | ( | FEConfigFgrInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 163 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), DateHandler::dateToTm(), e, getTable(), IDBObject::m_conn, IDBObject::m_env, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
00165 { 00166 this->checkConnection(); 00167 result->clear(); 00168 try { 00169 DateHandler dh(m_env, m_conn); 00170 00171 m_readStmt->setSQL("SELECT * FROM " + getTable() + 00172 " where fgr_conf_id = ( select max( fgr_conf_id) from "+ getTable() +" ) " ); 00173 ResultSet* rset = m_readStmt->executeQuery(); 00174 00175 rset->next(); 00176 00177 result->setId(rset->getInt(1)); 00178 result->setConfigTag(rset->getString(2)); 00179 result->setVersion(rset->getInt(3)); 00180 result->setNumberOfGroups(rset->getInt(4)); 00181 Date dbdate = rset->getDate(5); 00182 result->setDBTime( dh.dateToTm( dbdate )); 00183 00184 } catch (SQLException &e) { 00185 throw(runtime_error("FEConfigFgrInfo::fetchData(): "+e.getMessage())); 00186 } 00187 }
int FEConfigFgrInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 38 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00038 { 00039 00040 int result=0; 00041 try { 00042 this->checkConnection(); 00043 00044 m_readStmt = m_conn->createStatement(); 00045 m_readStmt->setSQL("select FE_CONFIG_FGR_SQ.NextVal from DUAL "); 00046 ResultSet* rset = m_readStmt->executeQuery(); 00047 while (rset->next ()){ 00048 result= rset->getInt(1); 00049 } 00050 result++; 00051 m_conn->terminateStatement(m_readStmt); 00052 return result; 00053 00054 } catch (SQLException &e) { 00055 throw(runtime_error("FEConfigFgrInfo::fetchNextId(): "+e.getMessage())); 00056 } 00057 00058 }
Tm FEConfigFgrInfo::getDBTime | ( | ) | const [inline] |
int FEConfigFgrInfo::getID | ( | ) | [inline] |
int FEConfigFgrInfo::getId | ( | ) | const [inline] |
Definition at line 26 of file FEConfigFgrInfo.h.
References m_ID.
Referenced by getID(), prepareWrite(), and EcalTPGDBApp::writeToConfDB_TPGFgr().
00026 { return m_ID; }
int FEConfigFgrInfo::getNumberOfGroups | ( | ) | const [inline] |
std::string FEConfigFgrInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 19 of file FEConfigFgrInfo.h.
Referenced by fetchData(), fetchID(), fetchLastData(), and prepareWrite().
int FEConfigFgrInfo::getVersion | ( | ) | const [inline] |
Definition at line 32 of file FEConfigFgrInfo.h.
References m_version.
Referenced by fetchID().
00032 { return m_version; }
bool FEConfigFgrInfo::operator!= | ( | const FEConfigFgrInfo & | r | ) | const [inline] |
bool FEConfigFgrInfo::operator== | ( | const FEConfigFgrInfo & | r | ) | const [inline] |
void FEConfigFgrInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 60 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), e, fetchNextId(), getId(), getTable(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00062 { 00063 this->checkConnection(); 00064 00065 int next_id=0; 00066 if(getId()==0){ 00067 next_id=fetchNextId(); 00068 } 00069 00070 try { 00071 m_writeStmt = m_conn->createStatement(); 00072 m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( fgr_conf_id, tag, version, number_of_groups) " 00073 " VALUES ( :1, :2, :3 , :4) " ); 00074 00075 m_writeStmt->setInt(1, next_id); 00076 m_ID=next_id; 00077 00078 } catch (SQLException &e) { 00079 throw(runtime_error("FEConfigFgrInfo::prepareWrite(): "+e.getMessage())); 00080 } 00081 00082 }
Definition at line 223 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), DateHandler::dateToTm(), e, IDBObject::m_conn, IDBObject::m_env, IODConfig::setConfigTag(), setDBTime(), setId(), setNumberOfGroups(), and setVersion().
00225 { 00226 this->checkConnection(); 00227 00228 DateHandler dh(m_env, m_conn); 00229 00230 try { 00231 Statement* stmt = m_conn->createStatement(); 00232 00233 stmt->setSQL("SELECT * FROM fe_config_fgr_info WHERE fgr_conf_id = :1"); 00234 stmt->setInt(1, id); 00235 00236 ResultSet* rset = stmt->executeQuery(); 00237 if (rset->next()) { 00238 this->setId(rset->getInt(1)); 00239 this->setConfigTag(rset->getString(2)); 00240 this->setVersion(rset->getInt(3)); 00241 this->setNumberOfGroups(rset->getInt(4)); 00242 Date dbdate = rset->getDate(5); 00243 this->setDBTime( dh.dateToTm( dbdate )); 00244 } else { 00245 throw(runtime_error("FEConfigFgrInfo::setByID: Given config_id is not in the database")); 00246 } 00247 00248 m_conn->terminateStatement(stmt); 00249 } catch (SQLException &e) { 00250 throw(runtime_error("FEConfigFgrInfo::setByID: "+e.getMessage())); 00251 } 00252 }
Definition at line 36 of file FEConfigFgrInfo.h.
References m_db_time.
Referenced by setByID().
00036 { m_db_time=x; }
Definition at line 22 of file FEConfigFgrInfo.h.
References m_iov_id.
Referenced by setByID(), setParameters(), and EcalTPGDBApp::writeToConfDB_TPGFgr().
00022 { m_iov_id = iov_id; }
void FEConfigFgrInfo::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 84 of file FEConfigFgrInfo.cc.
References IODConfig::setConfigTag(), setNumberOfGroups(), and setVersion().
00084 { 00085 00086 // parses the result of the XML parser that is a map of 00087 // string string with variable name variable value 00088 00089 for( std::map<std::string, std::string >::iterator ci= 00090 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00091 00092 if(ci->first== "VERSION") setVersion(atoi(ci->second.c_str()) ); 00093 if(ci->first== "TAG") setConfigTag(ci->second); 00094 if(ci->first== "NUMBER_OF_GROUPS") setNumberOfGroups(atoi(ci->second.c_str()) ); 00095 00096 } 00097 00098 }
Definition at line 31 of file FEConfigFgrInfo.h.
References m_version.
Referenced by setByID(), and setParameters().
void FEConfigFgrInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 100 of file FEConfigFgrInfo.cc.
References IDBObject::checkConnection(), IODConfig::checkPrepare(), e, and IODConfig::m_writeStmt.
00102 { 00103 this->checkConnection(); 00104 this->checkPrepare(); 00105 00106 try { 00107 00108 // number 1 is the id 00109 m_writeStmt->setString(2, this->getConfigTag()); 00110 m_writeStmt->setInt(3, this->getVersion()); 00111 m_writeStmt->setInt(4, this->getNumberOfGroups()); 00112 00113 m_writeStmt->executeUpdate(); 00114 00115 00116 } catch (SQLException &e) { 00117 throw(runtime_error("FEConfigFgrInfo::writeDB(): "+e.getMessage())); 00118 } 00119 // Now get the ID 00120 if (!this->fetchID()) { 00121 throw(runtime_error("FEConfigFgrInfo::writeDB: Failed to write")); 00122 } 00123 00124 00125 }
friend class EcalCondDBInterface [friend] |
Tm FEConfigFgrInfo::m_db_time [private] |
int FEConfigFgrInfo::m_ID [private] |
Definition at line 52 of file FEConfigFgrInfo.h.
Referenced by FEConfigFgrInfo(), fetchID(), getId(), operator==(), prepareWrite(), and setId().
int FEConfigFgrInfo::m_iov_id [private] |
Definition at line 51 of file FEConfigFgrInfo.h.
Referenced by clear(), getNumberOfGroups(), and setNumberOfGroups().
int FEConfigFgrInfo::m_version [private] |
Definition at line 54 of file FEConfigFgrInfo.h.
Referenced by FEConfigFgrInfo(), getVersion(), and setVersion().