#include <ODCond2ConfInfo.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
int | fetchNextId () throw (std::runtime_error) |
Tm | getDBDate () const |
std::string | getDescription () const |
int | getId () const |
std::string | getLocation () const |
Tm | getRecordDate () const |
int | getRunNumber () const |
std::string | getTable () |
std::string | getType () const |
ODCond2ConfInfo () | |
void | setDBDate (Tm x) |
void | setDescription (std::string x) |
void | setId (int id) |
void | setLocation (std::string x) |
void | setParameters (std::map< std::string, std::string > my_keys_map) |
void | setRecordDate (Tm x) |
void | setRunNumber (int id) |
void | setType (std::string x) |
~ODCond2ConfInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODCond2ConfInfo *result) throw (std::runtime_error) |
void | fetchParents () throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
Tm | m_db_time |
std::string | m_desc |
int | m_ID |
std::string | m_loc |
int | m_loc_id |
Tm | m_rec_time |
int | m_run |
int | m_typ_id |
std::string | m_type |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file ODCond2ConfInfo.h.
ODCond2ConfInfo::ODCond2ConfInfo | ( | ) |
Definition at line 12 of file ODCond2ConfInfo.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_ID=0; clear(); }
ODCond2ConfInfo::~ODCond2ConfInfo | ( | ) |
Definition at line 39 of file ODCond2ConfInfo.cc.
{ }
void ODCond2ConfInfo::clear | ( | void | ) | [private] |
void ODCond2ConfInfo::fetchData | ( | ODCond2ConfInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 187 of file ODCond2ConfInfo.cc.
References DateHandler::dateToTm(), ExpressReco_HICollisions_FallBack::e, and query::result.
{ this->checkConnection(); result->clear(); DateHandler dh(m_env, m_conn); if(result->getId()==0 ){ throw(std::runtime_error("ODCond2ConfInfo::fetchData(): no Id defined for this ODCond2ConfInfo ")); } try { m_readStmt->setSQL("SELECT rec_id, REC_TYPE, rec_date, location, " "run_number, short_desc, db_timestamp FROM " + getTable() + " , COND2CONF_TYPE_DEF , location_def " " where rec_id = :1 AND COND2CONF_TYPE_DEF.def_id=" +getTable()+".REC_TYPE_ID AND location_def.def_id=LOCATION_ID "); m_readStmt->setInt(1, result->getId()); 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->setType(rset->getString(2)); Date startDate = rset->getDate(3); result->setLocation(rset->getString(4)); result->setRunNumber(rset->getInt(5)); result->setDescription(rset->getString(6)); Date endDate = rset->getDate(7); m_rec_time = dh.dateToTm( startDate ); m_db_time = dh.dateToTm( endDate ); } catch (SQLException &e) { throw(std::runtime_error("ODCond2ConfInfo::fetchData(): "+e.getMessage())); } }
int ODCond2ConfInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 234 of file ODCond2ConfInfo.cc.
References ExpressReco_HICollisions_FallBack::e.
{ // Return from memory if available if (m_ID!=0) { return m_ID; } this->checkConnection(); fetchParents(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT rec_id FROM "+ getTable()+ "WHERE rec_type_id=:1 and (run_number=:2 or short_desc=:3 ) order by rec_id DESC " ); stmt->setInt(1, m_typ_id ); stmt->setInt(2, getRunNumber() ); stmt->setString(3, getDescription() ); 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("ODCond2ConfInfo::fetchID: "+e.getMessage())); } return m_ID; }
int ODCond2ConfInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 45 of file ODCond2ConfInfo.cc.
References ExpressReco_HICollisions_FallBack::e, and query::result.
{ int result=0; try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select COND2CONF_INFO_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("ODCond2ConfInfo::fetchNextId(): "+e.getMessage())); } }
void ODCond2ConfInfo::fetchParents | ( | ) | throw (std::runtime_error) [private] |
Definition at line 67 of file ODCond2ConfInfo.cc.
References ExpressReco_HICollisions_FallBack::e.
{ if(m_typ_id==0) { if(getType()!=""){ try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select def_id from COND2CONF_TYPE_DEF where rec_type="+getType()); ResultSet* rset = m_readStmt->executeQuery(); while (rset->next ()){ m_typ_id= rset->getInt(1); } m_conn->terminateStatement(m_readStmt); } catch (SQLException &e) { throw(std::runtime_error("ODCond2ConfInfo::fetchParents(): "+e.getMessage())); } } } if(m_loc_id==0){ if(getLocation()!=""){ try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select def_id from location_def where location="+getLocation()); ResultSet* rset = m_readStmt->executeQuery(); while (rset->next ()){ m_loc_id= rset->getInt(1); } m_conn->terminateStatement(m_readStmt); } catch (SQLException &e) { throw(std::runtime_error("ODCond2ConfInfo::fetchParents(): "+e.getMessage())); } } } }
Tm ODCond2ConfInfo::getDBDate | ( | ) | const [inline] |
std::string ODCond2ConfInfo::getDescription | ( | ) | const [inline] |
int ODCond2ConfInfo::getId | ( | ) | const [inline] |
std::string ODCond2ConfInfo::getLocation | ( | ) | const [inline] |
Tm ODCond2ConfInfo::getRecordDate | ( | ) | const [inline] |
int ODCond2ConfInfo::getRunNumber | ( | ) | const [inline] |
std::string ODCond2ConfInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 19 of file ODCond2ConfInfo.h.
{ return "COND_2_CONF_INFO"; }
std::string ODCond2ConfInfo::getType | ( | void | ) | const [inline] |
void ODCond2ConfInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 109 of file ODCond2ConfInfo.cc.
References ExpressReco_HICollisions_FallBack::e, and CastorDbASCIIIO::getId().
{ this->checkConnection(); int next_id=0; if(getId()==0){ next_id=fetchNextId(); } fetchParents(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( rec_id, rec_type_id, rec_date, " "location_id, run_number, short_desc ) " " VALUES ( :1, :2, :3 , :4, :5, :6 ) " ); m_writeStmt->setInt(1, next_id); m_writeStmt->setInt(3, m_typ_id); m_writeStmt->setInt(4, m_loc_id); m_ID=next_id; } catch (SQLException &e) { throw(std::runtime_error("ODCond2ConfInfo::prepareWrite(): "+e.getMessage())); } }
void ODCond2ConfInfo::setDBDate | ( | Tm | x | ) | [inline] |
Definition at line 39 of file ODCond2ConfInfo.h.
References m_db_time, and ExpressReco_HICollisions_FallBack::x.
void ODCond2ConfInfo::setDescription | ( | std::string | x | ) | [inline] |
Definition at line 36 of file ODCond2ConfInfo.h.
References m_desc, and ExpressReco_HICollisions_FallBack::x.
void ODCond2ConfInfo::setId | ( | int | id | ) | [inline] |
Definition at line 21 of file ODCond2ConfInfo.h.
References ExpressReco_HICollisions_FallBack::id, and m_ID.
void LocationDef::setLocation | ( | std::string | x | ) | [inline] |
Definition at line 30 of file ODCond2ConfInfo.h.
References m_loc, and ExpressReco_HICollisions_FallBack::x.
void ODCond2ConfInfo::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void ODCond2ConfInfo::setRecordDate | ( | Tm | x | ) | [inline] |
Definition at line 27 of file ODCond2ConfInfo.h.
References m_rec_time, and ExpressReco_HICollisions_FallBack::x.
{ m_rec_time = x; }
void ODCond2ConfInfo::setRunNumber | ( | int | id | ) | [inline] |
Definition at line 33 of file ODCond2ConfInfo.h.
References ExpressReco_HICollisions_FallBack::id, and m_run.
void ODCond2ConfInfo::setType | ( | std::string | x | ) | [inline] |
Definition at line 24 of file ODCond2ConfInfo.h.
References m_type, and ExpressReco_HICollisions_FallBack::x.
void ODCond2ConfInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 154 of file ODCond2ConfInfo.cc.
References ExpressReco_HICollisions_FallBack::e, and DateHandler::tmToDate().
{ this->checkConnection(); this->checkPrepare(); DateHandler dh(m_env, m_conn); if (m_rec_time.isNull()) { int very_old_time=0; m_rec_time = Tm(very_old_time); } try { m_writeStmt->setDate(3, dh.tmToDate(this->m_rec_time)); m_writeStmt->setInt(5, this->getRunNumber()); m_writeStmt->setString(6, this->getDescription()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("ODCond2ConfInfo::writeDB(): "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODCond2ConfInfo::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 14 of file ODCond2ConfInfo.h.
Tm ODCond2ConfInfo::m_db_time [private] |
Definition at line 68 of file ODCond2ConfInfo.h.
Referenced by getDBDate(), and setDBDate().
std::string ODCond2ConfInfo::m_desc [private] |
Definition at line 67 of file ODCond2ConfInfo.h.
Referenced by getDescription(), and setDescription().
int ODCond2ConfInfo::m_ID [private] |
Definition at line 62 of file ODCond2ConfInfo.h.
std::string ODCond2ConfInfo::m_loc [private] |
Definition at line 65 of file ODCond2ConfInfo.h.
Referenced by getLocation(), and setLocation().
int ODCond2ConfInfo::m_loc_id [private] |
Definition at line 69 of file ODCond2ConfInfo.h.
Tm ODCond2ConfInfo::m_rec_time [private] |
Definition at line 64 of file ODCond2ConfInfo.h.
Referenced by getRecordDate(), and setRecordDate().
int ODCond2ConfInfo::m_run [private] |
Definition at line 66 of file ODCond2ConfInfo.h.
Referenced by getRunNumber(), and setRunNumber().
int ODCond2ConfInfo::m_typ_id [private] |
Definition at line 70 of file ODCond2ConfInfo.h.
std::string ODCond2ConfInfo::m_type [private] |
Definition at line 63 of file ODCond2ConfInfo.h.