CMS 3D CMS Logo

ODCCSCycle Class Reference

#include <OnlineDB/EcalCondDB/interface/ODCCSCycle.h>

Inheritance diagram for ODCCSCycle:

IODConfig IDBObject

List of all members.

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


Detailed Description

Definition at line 11 of file ODCCSCycle.h.


Constructor & Destructor Documentation

ODCCSCycle::ODCCSCycle (  ) 

Definition at line 9 of file ODCCSCycle.cc.

References m_ccs_config_id, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, IODConfig::m_writeStmt, and NULL.

00010 {
00011   m_env = NULL;
00012   m_conn = NULL;
00013   m_writeStmt = NULL;
00014   m_readStmt = NULL;
00015   //
00016   m_ID = 0;
00017   m_ccs_config_id = 0;
00018 }

ODCCSCycle::~ODCCSCycle (  ) 

Definition at line 21 of file ODCCSCycle.cc.

00022 {
00023 }


Member Function Documentation

void ODCCSCycle::clear ( void   )  [private]

Definition at line 66 of file ODCCSCycle.cc.

References m_ccs_config_id.

00066                       {
00067   m_ccs_config_id=0;
00068 }

void ODCCSCycle::fetchData ( ODCCSCycle result  )  throw (std::runtime_error) [private]

Definition at line 131 of file ODCCSCycle.cc.

References IDBObject::checkConnection(), e, IODConfig::m_readStmt, and HLT_VtxMuL3::result.

00133 {
00134   this->checkConnection();
00135   result->clear();
00136 
00137   if(result->getId()==0){
00138     throw(runtime_error("ODCCSConfig::fetchData(): no Id defined for this ODCCSConfig "));
00139   }
00140 
00141   try {
00142 
00143     m_readStmt->setSQL("SELECT  ccs_configuration_id FROM ecal_ccs_cycle "
00144                  "WHERE cycle_id = :1 ");
00145 
00146     m_readStmt->setInt(1, result->getId());
00147     ResultSet* rset = m_readStmt->executeQuery();
00148 
00149     rset->next();
00150 
00151     result->setCCSConfigurationID(       rset->getInt(1) );
00152 
00153   } catch (SQLException &e) {
00154     throw(runtime_error("ODCCSCycle::fetchData():  "+e.getMessage()));
00155   }
00156 }

int ODCCSCycle::fetchID (  )  throw (std::runtime_error) [private]

Definition at line 71 of file ODCCSCycle.cc.

References IDBObject::checkConnection(), e, m_ccs_config_id, IDBObject::m_conn, and m_ID.

00073 {
00074   // Return from memory if available
00075   if (m_ID) {
00076     return m_ID;
00077   }
00078 
00079   this->checkConnection();
00080 
00081   try {
00082     Statement* stmt = m_conn->createStatement();
00083     stmt->setSQL("SELECT cycle_id, ccs_configuration_id FROM ecal_ccs_cycle "
00084                  "WHERE cycle_id = :1 ");
00085     stmt->setInt(1, m_ID);
00086     ResultSet* rset = stmt->executeQuery();
00087 
00088     if (rset->next()) {
00089       m_ID = rset->getInt(1);
00090       m_ccs_config_id = rset->getInt(2);
00091     } else {
00092       m_ID = 0;
00093     }
00094     m_conn->terminateStatement(stmt);
00095   } catch (SQLException &e) {
00096     throw(runtime_error("ODCCSCycle::fetchID:  "+e.getMessage()));
00097   }
00098 
00099   return m_ID;
00100 }

int ODCCSCycle::getCCSConfigurationID (  )  const [inline]

Definition at line 26 of file ODCCSCycle.h.

References m_ccs_config_id.

00026 {return m_ccs_config_id;}

int ODCCSCycle::getId (  )  const [inline]

Definition at line 22 of file ODCCSCycle.h.

References m_ID.

00022 { return m_ID;} ;

std::string ODCCSCycle::getTable (  )  [inline, virtual]

Implements IODConfig.

Definition at line 19 of file ODCCSCycle.h.

00019 { return "ECAL_CCS_CYCLE"; }

void ODCCSCycle::insertConfig (  )  throw (std::runtime_error) [private]

Definition at line 158 of file ODCCSCycle.cc.

References e, prepareWrite(), IODConfig::terminateWriteStatement(), and writeDB().

Referenced by ODEcalCycle::writeDB().

00160 {
00161   try {
00162 
00163     prepareWrite();
00164     writeDB();
00165     terminateWriteStatement();
00166   } catch (SQLException &e) {
00167     throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
00168   }
00169 }

bool ODCCSCycle::operator!= ( const ODCCSCycle m  )  const [inline]

Definition at line 30 of file ODCCSCycle.h.

00030 { return !(*this == m); }

bool ODCCSCycle::operator== ( const ODCCSCycle m  )  const [inline]

Definition at line 29 of file ODCCSCycle.h.

References m_ID.

00029 { return ( m_ID   == m.m_ID); }

void ODCCSCycle::prepareWrite (  )  throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 26 of file ODCCSCycle.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, and IODConfig::m_writeStmt.

Referenced by insertConfig().

00028 {
00029   this->checkConnection();
00030 
00031   try {
00032     m_writeStmt = m_conn->createStatement();
00033     m_writeStmt->setSQL("INSERT INTO ECAL_CCS_Cycle (cycle_id, ccs_configuration_id ) "
00034                  "VALUES (:1, :2 )");
00035   } catch (SQLException &e) {
00036     throw(runtime_error("ODCCSCycle::prepareWrite():  "+e.getMessage()));
00037   }
00038 }

void ODCCSCycle::setByID ( int  id  )  throw (std::runtime_error) [private]

Definition at line 104 of file ODCCSCycle.cc.

References IDBObject::checkConnection(), e, m_ccs_config_id, IDBObject::m_conn, and m_ID.

00106 {
00107    this->checkConnection();
00108 
00109 
00110   try {
00111     Statement* stmt = m_conn->createStatement();
00112     stmt->setSQL("SELECT cycle_id, ccs_configuration_id FROM ecal_ccs_cycle "
00113                  "WHERE cycle_id = :1 ");
00114     stmt->setInt(1, id);
00115     ResultSet* rset = stmt->executeQuery();
00116 
00117     if (rset->next()) {
00118       m_ID = rset->getInt(1);
00119       m_ccs_config_id = rset->getInt(2);
00120     } else {
00121       m_ID = 0;
00122     }
00123     m_conn->terminateStatement(stmt);
00124   } catch (SQLException &e) {
00125     throw(runtime_error("ODCCSCycle::fetchID:  "+e.getMessage()));
00126   }
00127 }

void ODCCSCycle::setCCSConfigurationID ( int  x  )  [inline]

Definition at line 25 of file ODCCSCycle.h.

References m_ccs_config_id.

Referenced by ODEcalCycle::writeDB().

00025 {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().

00021 {m_ID=id;}

void ODCCSCycle::writeDB (  )  throw (std::runtime_error) [private]

Definition at line 41 of file ODCCSCycle.cc.

References IDBObject::checkConnection(), IODConfig::checkPrepare(), e, and IODConfig::m_writeStmt.

Referenced by insertConfig().

00042 {
00043   this->checkConnection();
00044   this->checkPrepare();
00045 
00046   try {
00047 
00048     m_writeStmt->setInt(1, this->getId());
00049     m_writeStmt->setInt(2, this->getCCSConfigurationID());
00050 
00051     m_writeStmt->executeUpdate();
00052 
00053 
00054   } catch (SQLException &e) {
00055     throw(runtime_error("ODCCSCycle::writeDB:  "+e.getMessage()));
00056   }
00057 
00058   // Now get the ID
00059   if (!this->fetchID()) {
00060     throw(runtime_error("ODCCSCycle::writeDB:  Failed to write"));
00061   }
00062   
00063  
00064 }


Friends And Related Function Documentation

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.


Member Data Documentation

int ODCCSCycle::m_ccs_config_id [private]

Definition at line 37 of file ODCCSCycle.h.

Referenced by clear(), fetchID(), getCCSConfigurationID(), ODCCSCycle(), setByID(), and setCCSConfigurationID().

int ODCCSCycle::m_ID [private]

Definition at line 36 of file ODCCSCycle.h.

Referenced by fetchID(), getId(), ODCCSCycle(), operator==(), setByID(), and setId().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:29:09 2009 for CMSSW by  doxygen 1.5.4