#include <ODRunConfigCycleInfo.h>
Public Member Functions | |
int | getCycleNumber () const |
std::string | getDescription () const |
int | getId () const |
int | getSequenceID () const |
std::string | getTable () |
std::string | getTag () const |
ODRunConfigCycleInfo () | |
bool | operator!= (const ODRunConfigCycleInfo &r) const |
bool | operator== (const ODRunConfigCycleInfo &r) const |
void | setCycleNumber (int n) |
void | setDescription (std::string x) |
void | setId (int id) |
void | setSequenceID (int x) |
void | setTag (std::string x) |
~ODRunConfigCycleInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODRunConfigCycleInfo *result) throw (std::runtime_error) |
int | fetchID () throw (std::runtime_error) |
int | fetchIDLast () throw (std::runtime_error) |
void | insertConfig () throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | setByID (int id) throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
int | m_cycle_num |
std::string | m_description |
int | m_ID |
int | m_sequence_id |
std::string | m_tag |
Friends | |
class | EcalCondDBInterface |
class | ODEcalCycle |
Definition at line 14 of file ODRunConfigCycleInfo.h.
ODRunConfigCycleInfo::ODRunConfigCycleInfo | ( | ) |
Definition at line 12 of file ODRunConfigCycleInfo.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_ID=0; m_sequence_id =0; m_cycle_num =0; m_tag = ""; m_description=""; }
ODRunConfigCycleInfo::~ODRunConfigCycleInfo | ( | ) |
Definition at line 29 of file ODRunConfigCycleInfo.cc.
{}
void ODRunConfigCycleInfo::clear | ( | void | ) | [private] |
Definition at line 32 of file ODRunConfigCycleInfo.cc.
{ m_sequence_id =0; m_cycle_num =0; m_tag = ""; m_description=""; }
void ODRunConfigCycleInfo::fetchData | ( | ODRunConfigCycleInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 191 of file ODRunConfigCycleInfo.cc.
References query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0){ throw(std::runtime_error("ODRunConfigCycleInfo::fetchData(): no Id defined for this ODRunConfigCycleInfo ")); } try { m_readStmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 "); m_readStmt->setInt(1, result->getId()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); result->setSequenceID( rset->getInt(1) ); result->setCycleNumber( rset->getInt(2) ); result->setTag( rset->getString(3) ); result->setDescription( rset->getString(4) ); } catch (SQLException &e) { throw(std::runtime_error("ODRunConfigCycleInfo::fetchData(): "+e.getMessage())); } }
int ODRunConfigCycleInfo::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 92 of file ODRunConfigCycleInfo.cc.
{ // Return from memory if available if (m_ID>0) { return m_ID; } this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id from ECAL_cycle_DAT " "WHERE sequence_id = :id1 " " and cycle_num = :id2 " ); stmt->setInt(1, m_sequence_id); stmt->setInt(2, m_cycle_num); 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("ODRunConfigCycleInfo::fetchID: "+e.getMessage())); } setByID(m_ID); return m_ID; }
int ODRunConfigCycleInfo::fetchIDLast | ( | ) | throw (std::runtime_error) [private] |
Definition at line 131 of file ODRunConfigCycleInfo.cc.
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT max(cycle_id) FROM ecal_cycle_dat " ); 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("ODRunConfigCycleInfo::fetchIDLast: "+e.getMessage())); } setByID(m_ID); return m_ID; }
int ODRunConfigCycleInfo::getCycleNumber | ( | ) | const [inline] |
Definition at line 40 of file ODRunConfigCycleInfo.h.
References m_cycle_num.
{return m_cycle_num; }
std::string ODRunConfigCycleInfo::getDescription | ( | ) | const [inline] |
Definition at line 31 of file ODRunConfigCycleInfo.h.
References m_description.
{ return m_description;}
int ODRunConfigCycleInfo::getId | ( | ) | const [inline] |
Definition at line 26 of file ODRunConfigCycleInfo.h.
References m_ID.
Referenced by ODEcalCycle::writeDB().
{ return m_ID; }
int ODRunConfigCycleInfo::getSequenceID | ( | ) | const [inline] |
Definition at line 37 of file ODRunConfigCycleInfo.h.
References m_sequence_id.
{ return m_sequence_id;}
std::string ODRunConfigCycleInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 22 of file ODRunConfigCycleInfo.h.
{ return "ECAL_CYCLE_DAT"; }
std::string ODRunConfigCycleInfo::getTag | ( | void | ) | const [inline] |
void ODRunConfigCycleInfo::insertConfig | ( | ) | throw (std::runtime_error) [private] |
Definition at line 218 of file ODRunConfigCycleInfo.cc.
Referenced by ODEcalCycle::writeDB().
{ try { prepareWrite(); writeDB(); m_conn->commit(); terminateWriteStatement(); } catch (std::runtime_error &e) { m_conn->rollback(); throw(e); } catch (...) { m_conn->rollback(); throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught")); } }
bool ODRunConfigCycleInfo::operator!= | ( | const ODRunConfigCycleInfo & | r | ) | const [inline] |
Definition at line 47 of file ODRunConfigCycleInfo.h.
References csvReporter::r.
{ return !(*this == r); }
bool ODRunConfigCycleInfo::operator== | ( | const ODRunConfigCycleInfo & | r | ) | const [inline] |
Definition at line 46 of file ODRunConfigCycleInfo.h.
References m_ID.
void ODRunConfigCycleInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 40 of file ODRunConfigCycleInfo.cc.
{ this->checkConnection(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO ECAL_CYCLE_DAT ( sequence_id , cycle_num, tag, description ) " "VALUES (:1, :2, :3 , :4 )"); } catch (SQLException &e) { throw(std::runtime_error("ODRunConfigCycleInfo::prepareWrite(): "+e.getMessage())); } }
void ODRunConfigCycleInfo::setByID | ( | int | id | ) | throw (std::runtime_error) [private] |
Definition at line 159 of file ODRunConfigCycleInfo.cc.
References gather_cfg::cout.
{ this->checkConnection(); DateHandler dh(m_env, m_conn); cout<< "ODRunConfigCycleInfo::setByID called for id "<<id<<endl; try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 "); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_sequence_id=rset->getInt(1); m_cycle_num=rset->getInt(2); m_tag = rset->getString(3); m_description= rset->getString(4); m_ID = id; } else { throw(std::runtime_error("ODRunConfigCycleInfo::setByID: Given cycle_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODRunConfigCycleInfo::setByID: "+e.getMessage())); } }
void ODRunConfigCycleInfo::setCycleNumber | ( | int | n | ) | [inline] |
Definition at line 39 of file ODRunConfigCycleInfo.h.
References m_cycle_num, and n.
Referenced by ODEcalCycle::writeDB().
{ m_cycle_num = n; }
void ODRunConfigCycleInfo::setDescription | ( | std::string | x | ) | [inline] |
Definition at line 30 of file ODRunConfigCycleInfo.h.
References m_description, and x.
Referenced by ODEcalCycle::writeDB().
{ m_description = x;}
void ODRunConfigCycleInfo::setId | ( | int | id | ) | [inline] |
void ODRunConfigCycleInfo::setSequenceID | ( | int | x | ) | [inline] |
Definition at line 36 of file ODRunConfigCycleInfo.h.
References m_sequence_id, and x.
Referenced by ODEcalCycle::writeDB().
{ m_sequence_id = x;}
void ODRunConfigCycleInfo::setTag | ( | std::string | x | ) | [inline] |
Definition at line 33 of file ODRunConfigCycleInfo.h.
Referenced by ODEcalCycle::writeDB().
void ODRunConfigCycleInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 56 of file ODRunConfigCycleInfo.cc.
References gather_cfg::cout.
{ this->checkConnection(); this->checkPrepare(); // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); try { m_writeStmt->setInt(1, this->getSequenceID()); m_writeStmt->setInt(2, this->getCycleNumber()); m_writeStmt->setString(3, this->getTag()); m_writeStmt->setString(4, this->getDescription()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("ODRunConfigCycleInfo::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODRunConfigCycleInfo::writeDB: Failed to write")); } cout<< "ODRunConfigCycleInfo::writeDB>> done inserting ODRunConfigCycleInfo with id="<<m_ID<<endl; }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 16 of file ODRunConfigCycleInfo.h.
friend class ODEcalCycle [friend] |
Definition at line 17 of file ODRunConfigCycleInfo.h.
int ODRunConfigCycleInfo::m_cycle_num [private] |
Definition at line 53 of file ODRunConfigCycleInfo.h.
Referenced by getCycleNumber(), and setCycleNumber().
std::string ODRunConfigCycleInfo::m_description [private] |
Definition at line 55 of file ODRunConfigCycleInfo.h.
Referenced by getDescription(), and setDescription().
int ODRunConfigCycleInfo::m_ID [private] |
Definition at line 51 of file ODRunConfigCycleInfo.h.
Referenced by getId(), operator==(), and setId().
int ODRunConfigCycleInfo::m_sequence_id [private] |
Definition at line 52 of file ODRunConfigCycleInfo.h.
Referenced by getSequenceID(), and setSequenceID().
std::string ODRunConfigCycleInfo::m_tag [private] |
Definition at line 54 of file ODRunConfigCycleInfo.h.