#include <OnlineDB/EcalCondDB/interface/FEConfigLinInfo.h>
Public Member Functions | |
FEConfigLinInfo () | |
int | fetchID () throw (std::runtime_error) |
int | fetchNextId () throw (std::runtime_error) |
Tm | getDBTime () const |
int | getID () |
int | getId () const |
int | getIOVId () const |
std::string | getTable () |
int | getVersion () const |
bool | operator!= (const FEConfigLinInfo &r) const |
bool | operator== (const FEConfigLinInfo &r) const |
void | setByID (int id) throw (std::runtime_error) |
void | setDBTime (Tm x) |
void | setID (int id) |
void | setId (int id) |
void | setIOVId (int iov_id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setVersion (int id) |
~FEConfigLinInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (FEConfigLinInfo *result) throw (std::runtime_error) |
void | fetchLastData (FEConfigLinInfo *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 FEConfigLinInfo.h.
FEConfigLinInfo::FEConfigLinInfo | ( | ) |
Definition at line 13 of file FEConfigLinInfo.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 }
FEConfigLinInfo::~FEConfigLinInfo | ( | ) |
Definition at line 26 of file FEConfigLinInfo.cc.
References m_iov_id.
Referenced by FEConfigLinInfo().
00026 { 00027 m_iov_id=0; 00028 }
void FEConfigLinInfo::fetchData | ( | FEConfigLinInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 128 of file FEConfigLinInfo.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("FEConfigLinInfo::fetchData(): no Id defined for this FEConfigLinInfo ")); 00135 } 00136 00137 try { 00138 DateHandler dh(m_env, m_conn); 00139 00140 m_readStmt->setSQL("SELECT * FROM " + getTable() + 00141 " where ( lin_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->setIOVId(rset->getInt(4)); 00155 Date dbdate = rset->getDate(5); 00156 result->setDBTime( dh.dateToTm( dbdate )); 00157 00158 } catch (SQLException &e) { 00159 throw(runtime_error("FEConfigLinInfo::fetchData(): "+e.getMessage())); 00160 } 00161 }
int FEConfigLinInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 189 of file FEConfigLinInfo.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 lin_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("FEConfigLinInfo::fetchID: "+e.getMessage())); 00216 } 00217 00218 return m_ID; 00219 }
void FEConfigLinInfo::fetchLastData | ( | FEConfigLinInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 163 of file FEConfigLinInfo.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 lin_conf_id = ( select max( lin_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->setIOVId(rset->getInt(4)); 00181 Date dbdate = rset->getDate(5); 00182 result->setDBTime( dh.dateToTm( dbdate )); 00183 00184 } catch (SQLException &e) { 00185 throw(runtime_error("FEConfigLinInfo::fetchData(): "+e.getMessage())); 00186 } 00187 }
int FEConfigLinInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 38 of file FEConfigLinInfo.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_LIN_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("FEConfigLinInfo::fetchNextId(): "+e.getMessage())); 00056 } 00057 00058 }
Tm FEConfigLinInfo::getDBTime | ( | ) | const [inline] |
int FEConfigLinInfo::getID | ( | ) | [inline] |
Definition at line 29 of file FEConfigLinInfo.h.
References getId().
Referenced by EcalTPGDBApp::writeToConfDB_TPGLinearCoef().
00029 { return getId() ;}
int FEConfigLinInfo::getId | ( | ) | const [inline] |
Definition at line 26 of file FEConfigLinInfo.h.
References m_ID.
Referenced by getID(), and prepareWrite().
00026 { return m_ID; }
int FEConfigLinInfo::getIOVId | ( | ) | const [inline] |
std::string FEConfigLinInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 19 of file FEConfigLinInfo.h.
Referenced by fetchData(), fetchID(), fetchLastData(), and prepareWrite().
int FEConfigLinInfo::getVersion | ( | ) | const [inline] |
Definition at line 32 of file FEConfigLinInfo.h.
References m_version.
Referenced by fetchID().
00032 { return m_version; }
bool FEConfigLinInfo::operator!= | ( | const FEConfigLinInfo & | r | ) | const [inline] |
bool FEConfigLinInfo::operator== | ( | const FEConfigLinInfo & | r | ) | const [inline] |
void FEConfigLinInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 60 of file FEConfigLinInfo.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()+" ( lin_conf_id, tag, version, iov_id) " 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("FEConfigLinInfo::prepareWrite(): "+e.getMessage())); 00080 } 00081 00082 }
Definition at line 223 of file FEConfigLinInfo.cc.
References IDBObject::checkConnection(), DateHandler::dateToTm(), e, IDBObject::m_conn, IDBObject::m_env, IODConfig::setConfigTag(), setDBTime(), setId(), setIOVId(), 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_lin_info WHERE lin_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->setIOVId(rset->getInt(4)); 00242 Date dbdate = rset->getDate(5); 00243 this->setDBTime( dh.dateToTm( dbdate )); 00244 } else { 00245 throw(runtime_error("FEConfigLinInfo::setByID: Given config_id is not in the database")); 00246 } 00247 00248 m_conn->terminateStatement(stmt); 00249 } catch (SQLException &e) { 00250 throw(runtime_error("FEConfigLinInfo::setByID: "+e.getMessage())); 00251 } 00252 }
Definition at line 36 of file FEConfigLinInfo.h.
References m_db_time.
Referenced by setByID().
00036 { m_db_time=x; }
Definition at line 22 of file FEConfigLinInfo.h.
References m_iov_id.
Referenced by setByID(), setParameters(), and EcalTPGDBApp::writeToConfDB_TPGLinearCoef().
00022 { m_iov_id = iov_id; }
void FEConfigLinInfo::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 84 of file FEConfigLinInfo.cc.
References IODConfig::setConfigTag(), setIOVId(), 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== "IOV_ID") setIOVId(atoi(ci->second.c_str()) ); 00095 00096 } 00097 00098 }
Definition at line 31 of file FEConfigLinInfo.h.
References m_version.
Referenced by setByID(), and setParameters().
void FEConfigLinInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 100 of file FEConfigLinInfo.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->getIOVId()); 00112 00113 m_writeStmt->executeUpdate(); 00114 00115 00116 } catch (SQLException &e) { 00117 throw(runtime_error("FEConfigLinInfo::writeDB(): "+e.getMessage())); 00118 } 00119 // Now get the ID 00120 if (!this->fetchID()) { 00121 throw(runtime_error("FEConfigLinInfo::writeDB: Failed to write")); 00122 } 00123 00124 00125 }
friend class EcalCondDBInterface [friend] |
Tm FEConfigLinInfo::m_db_time [private] |
int FEConfigLinInfo::m_ID [private] |
Definition at line 52 of file FEConfigLinInfo.h.
Referenced by FEConfigLinInfo(), fetchID(), getId(), operator==(), prepareWrite(), and setId().
int FEConfigLinInfo::m_iov_id [private] |
int FEConfigLinInfo::m_version [private] |
Definition at line 54 of file FEConfigLinInfo.h.
Referenced by FEConfigLinInfo(), getVersion(), and setVersion().