#include <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< std::string, std::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 NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_version=0; m_ID=0; clear(); }
FEConfigFgrInfo::~FEConfigFgrInfo | ( | ) |
Definition at line 32 of file FEConfigFgrInfo.cc.
{ }
void FEConfigFgrInfo::clear | ( | void | ) | [private] |
Definition at line 26 of file FEConfigFgrInfo.cc.
{ m_iov_id=0; }
void FEConfigFgrInfo::fetchData | ( | FEConfigFgrInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 128 of file FEConfigFgrInfo.cc.
References DateHandler::dateToTm(), and query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0 && (result->getConfigTag()=="") ){ throw(std::runtime_error("FEConfigFgrInfo::fetchData(): no Id defined for this FEConfigFgrInfo ")); } try { DateHandler dh(m_env, m_conn); m_readStmt->setSQL("SELECT * FROM " + getTable() + " where ( fgr_conf_id= :1 or (tag=:2 AND version=:3 ) )" ); m_readStmt->setInt(1, result->getId()); m_readStmt->setString(2, result->getConfigTag()); m_readStmt->setInt(3, result->getVersion()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); // 1 is the id and 2 is the config tag and 3 is the version result->setId(rset->getInt(1)); result->setConfigTag(rset->getString(2)); result->setVersion(rset->getInt(3)); result->setNumberOfGroups(rset->getInt(4)); Date dbdate = rset->getDate(5); result->setDBTime( dh.dateToTm( dbdate )); } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::fetchData(): "+e.getMessage())); } }
int FEConfigFgrInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 189 of file FEConfigFgrInfo.cc.
{ // Return from memory if available if (m_ID!=0) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT fgr_conf_id FROM "+ getTable()+ " WHERE tag=:1 and version=:2 " ); stmt->setString(1, getConfigTag() ); stmt->setInt(2, getVersion() ); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::fetchID: "+e.getMessage())); } return m_ID; }
void FEConfigFgrInfo::fetchLastData | ( | FEConfigFgrInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 163 of file FEConfigFgrInfo.cc.
References DateHandler::dateToTm(), and query::result.
{ this->checkConnection(); result->clear(); try { DateHandler dh(m_env, m_conn); m_readStmt->setSQL("SELECT * FROM " + getTable() + " where fgr_conf_id = ( select max( fgr_conf_id) from "+ getTable() +" ) " ); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); result->setId(rset->getInt(1)); result->setConfigTag(rset->getString(2)); result->setVersion(rset->getInt(3)); result->setNumberOfGroups(rset->getInt(4)); Date dbdate = rset->getDate(5); result->setDBTime( dh.dateToTm( dbdate )); } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::fetchData(): "+e.getMessage())); } }
int FEConfigFgrInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 38 of file FEConfigFgrInfo.cc.
References query::result.
{ int result=0; try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select FE_CONFIG_FGR_SQ.NextVal from DUAL "); ResultSet* rset = m_readStmt->executeQuery(); while (rset->next ()){ result= rset->getInt(1); } result++; m_conn->terminateStatement(m_readStmt); return result; } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::fetchNextId(): "+e.getMessage())); } }
Tm FEConfigFgrInfo::getDBTime | ( | ) | const [inline] |
int FEConfigFgrInfo::getId | ( | ) | const [inline] |
Definition at line 26 of file FEConfigFgrInfo.h.
References m_ID.
Referenced by getID(), and EcalTPGDBApp::writeToConfDB_TPGFgr().
{ return m_ID; }
int FEConfigFgrInfo::getID | ( | ) | [inline] |
int FEConfigFgrInfo::getNumberOfGroups | ( | ) | const [inline] |
std::string FEConfigFgrInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 19 of file FEConfigFgrInfo.h.
{ return "FE_CONFIG_FGR_INFO"; }
int FEConfigFgrInfo::getVersion | ( | ) | const [inline] |
bool FEConfigFgrInfo::operator!= | ( | const FEConfigFgrInfo & | r | ) | const [inline] |
Definition at line 47 of file FEConfigFgrInfo.h.
References csvReporter::r.
{ return !(*this == r); }
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 getId().
{ this->checkConnection(); int next_id=0; if(getId()==0){ next_id=fetchNextId(); } try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( fgr_conf_id, tag, version, number_of_groups) " " VALUES ( :1, :2, :3 , :4) " ); m_writeStmt->setInt(1, next_id); m_ID=next_id; } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::prepareWrite(): "+e.getMessage())); } }
void FEConfigFgrInfo::setByID | ( | int | id | ) | throw (std::runtime_error) |
Definition at line 223 of file FEConfigFgrInfo.cc.
References DateHandler::dateToTm().
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT * FROM fe_config_fgr_info WHERE fgr_conf_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { this->setId(rset->getInt(1)); this->setConfigTag(rset->getString(2)); this->setVersion(rset->getInt(3)); this->setNumberOfGroups(rset->getInt(4)); Date dbdate = rset->getDate(5); this->setDBTime( dh.dateToTm( dbdate )); } else { throw(std::runtime_error("FEConfigFgrInfo::setByID: Given config_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::setByID: "+e.getMessage())); } }
void FEConfigFgrInfo::setDBTime | ( | Tm | x | ) | [inline] |
void FEConfigFgrInfo::setId | ( | int | id | ) | [inline] |
Definition at line 25 of file FEConfigFgrInfo.h.
References m_ID.
Referenced by popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), and setID().
{ m_ID = id; }
void FEConfigFgrInfo::setID | ( | int | id | ) | [inline] |
void FEConfigFgrInfo::setNumberOfGroups | ( | int | iov_id | ) | [inline] |
Definition at line 22 of file FEConfigFgrInfo.h.
References m_iov_id.
Referenced by EcalTPGDBApp::writeToConfDB_TPGFgr().
{ m_iov_id = iov_id; }
void FEConfigFgrInfo::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void FEConfigFgrInfo::setVersion | ( | int | id | ) | [inline] |
void FEConfigFgrInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 100 of file FEConfigFgrInfo.cc.
{ this->checkConnection(); this->checkPrepare(); try { // number 1 is the id m_writeStmt->setString(2, this->getConfigTag()); m_writeStmt->setInt(3, this->getVersion()); m_writeStmt->setInt(4, this->getNumberOfGroups()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("FEConfigFgrInfo::writeDB(): "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("FEConfigFgrInfo::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 13 of file FEConfigFgrInfo.h.
Tm FEConfigFgrInfo::m_db_time [private] |
Definition at line 53 of file FEConfigFgrInfo.h.
Referenced by getDBTime(), and setDBTime().
int FEConfigFgrInfo::m_ID [private] |
Definition at line 52 of file FEConfigFgrInfo.h.
Referenced by getId(), operator==(), and setId().
int FEConfigFgrInfo::m_iov_id [private] |
Definition at line 51 of file FEConfigFgrInfo.h.
Referenced by getNumberOfGroups(), and setNumberOfGroups().
int FEConfigFgrInfo::m_version [private] |
Definition at line 54 of file FEConfigFgrInfo.h.
Referenced by getVersion(), and setVersion().