#include <ODCCSCycle.h>
Public Member Functions | |
int | getCCSConfigurationID () const |
int | getId () const |
std::string | getTable () |
ODCCSCycle () | |
bool | operator!= (const ODCCSCycle &m) const |
bool | operator== (const ODCCSCycle &m) const |
void | setCCSConfigurationID (int x) |
void | setId (int id) |
~ODCCSCycle () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODCCSCycle *result) throw (std::runtime_error) |
int | fetchID () 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_ccs_config_id |
int | m_ID |
Friends | |
class | EcalCondDBInterface |
class | ODEcalCycle |
Definition at line 11 of file ODCCSCycle.h.
ODCCSCycle::ODCCSCycle | ( | ) |
Definition at line 9 of file ODCCSCycle.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; // m_ID = 0; m_ccs_config_id = 0; }
ODCCSCycle::~ODCCSCycle | ( | ) |
Definition at line 21 of file ODCCSCycle.cc.
{ }
void ODCCSCycle::clear | ( | void | ) | [private] |
Definition at line 66 of file ODCCSCycle.cc.
{ m_ccs_config_id=0; }
void ODCCSCycle::fetchData | ( | ODCCSCycle * | result | ) | throw (std::runtime_error) [private] |
Definition at line 131 of file ODCCSCycle.cc.
References alignCSCRings::e, and query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0){ throw(std::runtime_error("ODCCSConfig::fetchData(): no Id defined for this ODCCSConfig ")); } try { m_readStmt->setSQL("SELECT ccs_configuration_id FROM ecal_ccs_cycle " "WHERE cycle_id = :1 "); m_readStmt->setInt(1, result->getId()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); result->setCCSConfigurationID( rset->getInt(1) ); } catch (SQLException &e) { throw(std::runtime_error("ODCCSCycle::fetchData(): "+e.getMessage())); } }
int ODCCSCycle::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 71 of file ODCCSCycle.cc.
References alignCSCRings::e.
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id, ccs_configuration_id FROM ecal_ccs_cycle " "WHERE cycle_id = :1 "); stmt->setInt(1, m_ID); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); m_ccs_config_id = rset->getInt(2); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODCCSCycle::fetchID: "+e.getMessage())); } return m_ID; }
int ODCCSCycle::getCCSConfigurationID | ( | ) | const [inline] |
int ODCCSCycle::getId | ( | ) | const [inline] |
std::string ODCCSCycle::getTable | ( | ) | [inline, virtual] |
void ODCCSCycle::insertConfig | ( | ) | throw (std::runtime_error) [private] |
Definition at line 158 of file ODCCSCycle.cc.
References alignCSCRings::e.
Referenced by ODEcalCycle::writeDB().
{ try { prepareWrite(); writeDB(); terminateWriteStatement(); } catch (SQLException &e) { throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught")); } }
bool ODCCSCycle::operator!= | ( | const ODCCSCycle & | m | ) | const [inline] |
bool ODCCSCycle::operator== | ( | const ODCCSCycle & | m | ) | const [inline] |
void ODCCSCycle::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 26 of file ODCCSCycle.cc.
References alignCSCRings::e.
{ this->checkConnection(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO ECAL_CCS_Cycle (cycle_id, ccs_configuration_id ) " "VALUES (:1, :2 )"); } catch (SQLException &e) { throw(std::runtime_error("ODCCSCycle::prepareWrite(): "+e.getMessage())); } }
void ODCCSCycle::setByID | ( | int | id | ) | throw (std::runtime_error) [private] |
Definition at line 104 of file ODCCSCycle.cc.
References alignCSCRings::e.
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT cycle_id, ccs_configuration_id FROM ecal_ccs_cycle " "WHERE cycle_id = :1 "); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); m_ccs_config_id = rset->getInt(2); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODCCSCycle::fetchID: "+e.getMessage())); } }
void ODCCSCycle::setCCSConfigurationID | ( | int | x | ) | [inline] |
Definition at line 25 of file ODCCSCycle.h.
References m_ccs_config_id, and x.
Referenced by ODEcalCycle::writeDB().
{m_ccs_config_id=x;}
void ODCCSCycle::setId | ( | int | id | ) | [inline] |
Definition at line 21 of file ODCCSCycle.h.
References m_ID.
Referenced by ODEcalCycle::writeDB().
{m_ID=id;}
void ODCCSCycle::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 41 of file ODCCSCycle.cc.
References alignCSCRings::e, and getId().
{ this->checkConnection(); this->checkPrepare(); try { m_writeStmt->setInt(1, this->getId()); m_writeStmt->setInt(2, this->getCCSConfigurationID()); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("ODCCSCycle::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODCCSCycle::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 13 of file ODCCSCycle.h.
friend class ODEcalCycle [friend] |
Definition at line 14 of file ODCCSCycle.h.
int ODCCSCycle::m_ccs_config_id [private] |
Definition at line 37 of file ODCCSCycle.h.
Referenced by getCCSConfigurationID(), and setCCSConfigurationID().
int ODCCSCycle::m_ID [private] |
Definition at line 36 of file ODCCSCycle.h.
Referenced by getId(), operator==(), and setId().