#include <OnlineDB/EcalCondDB/interface/FEConfigLUTInfo.h>
Public Member Functions | |
FEConfigLUTInfo () | |
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 FEConfigLUTInfo &r) const |
bool | operator== (const FEConfigLUTInfo &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) |
~FEConfigLUTInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (FEConfigLUTInfo *result) throw (std::runtime_error) |
void | fetchLastData (FEConfigLUTInfo *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 FEConfigLUTInfo.h.
FEConfigLUTInfo::FEConfigLUTInfo | ( | ) |
Definition at line 13 of file FEConfigLUTInfo.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 }
FEConfigLUTInfo::~FEConfigLUTInfo | ( | ) |
Definition at line 26 of file FEConfigLUTInfo.cc.
References m_iov_id.
Referenced by FEConfigLUTInfo().
00026 { 00027 m_iov_id=0; 00028 }
void FEConfigLUTInfo::fetchData | ( | FEConfigLUTInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 128 of file FEConfigLUTInfo.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("FEConfigLUTInfo::fetchData(): no Id defined for this FEConfigLUTInfo ")); 00135 } 00136 00137 try { 00138 DateHandler dh(m_env, m_conn); 00139 00140 m_readStmt->setSQL("SELECT * FROM " + getTable() + 00141 " where ( lut_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("FEConfigLUTInfo::fetchData(): "+e.getMessage())); 00160 } 00161 }
int FEConfigLUTInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 189 of file FEConfigLUTInfo.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 lut_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("FEConfigLUTInfo::fetchID: "+e.getMessage())); 00216 } 00217 00218 return m_ID; 00219 }
void FEConfigLUTInfo::fetchLastData | ( | FEConfigLUTInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 163 of file FEConfigLUTInfo.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 lut_conf_id = ( select max( lut_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("FEConfigLUTInfo::fetchData(): "+e.getMessage())); 00186 } 00187 }
int FEConfigLUTInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 38 of file FEConfigLUTInfo.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_LUT_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("FEConfigLUTInfo::fetchNextId(): "+e.getMessage())); 00056 } 00057 00058 }
Tm FEConfigLUTInfo::getDBTime | ( | ) | const [inline] |
int FEConfigLUTInfo::getID | ( | ) | [inline] |
int FEConfigLUTInfo::getId | ( | ) | const [inline] |
Definition at line 26 of file FEConfigLUTInfo.h.
References m_ID.
Referenced by getID(), prepareWrite(), and EcalTPGDBApp::writeToConfDB_TPGLUT().
00026 { return m_ID; }
int FEConfigLUTInfo::getNumberOfGroups | ( | ) | const [inline] |
std::string FEConfigLUTInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 19 of file FEConfigLUTInfo.h.
Referenced by fetchData(), fetchID(), fetchLastData(), and prepareWrite().
int FEConfigLUTInfo::getVersion | ( | ) | const [inline] |
Definition at line 32 of file FEConfigLUTInfo.h.
References m_version.
Referenced by fetchID().
00032 { return m_version; }
bool FEConfigLUTInfo::operator!= | ( | const FEConfigLUTInfo & | r | ) | const [inline] |
bool FEConfigLUTInfo::operator== | ( | const FEConfigLUTInfo & | r | ) | const [inline] |
void FEConfigLUTInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 60 of file FEConfigLUTInfo.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()+" ( lut_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("FEConfigLUTInfo::prepareWrite(): "+e.getMessage())); 00080 } 00081 00082 }
Definition at line 223 of file FEConfigLUTInfo.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_lut_info WHERE lut_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("FEConfigLUTInfo::setByID: Given config_id is not in the database")); 00246 } 00247 00248 m_conn->terminateStatement(stmt); 00249 } catch (SQLException &e) { 00250 throw(runtime_error("FEConfigLUTInfo::setByID: "+e.getMessage())); 00251 } 00252 }
Definition at line 36 of file FEConfigLUTInfo.h.
References m_db_time.
Referenced by setByID().
00036 { m_db_time=x; }
Definition at line 22 of file FEConfigLUTInfo.h.
References m_iov_id.
Referenced by setByID(), setParameters(), and EcalTPGDBApp::writeToConfDB_TPGLUT().
00022 { m_iov_id = iov_id; }
void FEConfigLUTInfo::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 84 of file FEConfigLUTInfo.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 FEConfigLUTInfo.h.
References m_version.
Referenced by setByID(), and setParameters().
void FEConfigLUTInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 100 of file FEConfigLUTInfo.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("FEConfigLUTInfo::writeDB(): "+e.getMessage())); 00118 } 00119 // Now get the ID 00120 if (!this->fetchID()) { 00121 throw(runtime_error("FEConfigLUTInfo::writeDB: Failed to write")); 00122 } 00123 00124 00125 }
friend class EcalCondDBInterface [friend] |
Tm FEConfigLUTInfo::m_db_time [private] |
int FEConfigLUTInfo::m_ID [private] |
Definition at line 52 of file FEConfigLUTInfo.h.
Referenced by FEConfigLUTInfo(), fetchID(), getId(), operator==(), prepareWrite(), and setId().
int FEConfigLUTInfo::m_iov_id [private] |
Definition at line 51 of file FEConfigLUTInfo.h.
Referenced by clear(), getNumberOfGroups(), and setNumberOfGroups().
int FEConfigLUTInfo::m_version [private] |
Definition at line 54 of file FEConfigLUTInfo.h.
Referenced by FEConfigLUTInfo(), getVersion(), and setVersion().