CMS 3D CMS Logo

ODRunConfigSeqInfo Class Reference

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

Inheritance diagram for ODRunConfigSeqInfo:

IODConfig IDBObject

List of all members.

Public Member Functions

std::string getDescription () const
int getEcalConfigId () const
int getId () const
int getNumberOfCycles () const
RunSeqDef getRunSeqDef () const
int getSequenceNumber () const
std::string getTable ()
 ODRunConfigSeqInfo ()
bool operator!= (const ODRunConfigSeqInfo &r) const
bool operator== (const ODRunConfigSeqInfo &r) const
void setDescription (std::string x)
void setEcalConfigId (int x)
void setId (int id)
void setNumberOfCycles (int x)
void setRunSeqDef (const RunSeqDef runSeqDef)
void setSequenceNumber (int x)
 ~ODRunConfigSeqInfo ()

Private Member Functions

void clear ()
void fetchData (ODRunConfigSeqInfo *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchIDLast () 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_cycles
std::string m_description
int m_ecal_config_id
int m_ID
RunSeqDef m_run_seq
int m_seq_num

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 15 of file ODRunConfigSeqInfo.h.


Constructor & Destructor Documentation

ODRunConfigSeqInfo::ODRunConfigSeqInfo (  ) 

Definition at line 12 of file ODRunConfigSeqInfo.cc.

References IDBObject::m_conn, m_cycles, m_description, m_ecal_config_id, IDBObject::m_env, m_ID, IODConfig::m_readStmt, m_run_seq, m_seq_num, IODConfig::m_writeStmt, and NULL.

00013 {
00014   m_env = NULL;
00015   m_conn = NULL;
00016   m_writeStmt = NULL;
00017   m_readStmt = NULL;
00018 
00019   m_ID = 0;
00020   //
00021   m_ecal_config_id =0;
00022   m_seq_num =0;
00023   m_cycles =0;
00024   m_run_seq = RunSeqDef();
00025   m_description="";
00026 }

ODRunConfigSeqInfo::~ODRunConfigSeqInfo (  ) 

Definition at line 28 of file ODRunConfigSeqInfo.cc.

00028 {}


Member Function Documentation

void ODRunConfigSeqInfo::clear ( void   )  [private]

Definition at line 197 of file ODRunConfigSeqInfo.cc.

References m_cycles, m_description, m_ecal_config_id, m_run_seq, and m_seq_num.

00197                               {
00198   m_ecal_config_id =0;
00199   m_seq_num =0;
00200   m_cycles =0;
00201   m_run_seq = RunSeqDef();
00202   m_description="";
00203 }

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

Definition at line 206 of file ODRunConfigSeqInfo.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IODConfig::m_readStmt, m_run_seq, HLT_VtxMuL3::result, RunSeqDef::setByID(), and IDBObject::setConnection().

00208 {
00209   this->checkConnection();
00210   result->clear();
00211   if(result->getId()==0){
00212     throw(runtime_error("ODRunConfigSeqInfo::fetchData(): no Id defined for this record "));
00213   }
00214 
00215   try {
00216     
00217     m_readStmt->setSQL("SELECT ecal_config_id, sequence_num, num_of_cycles, "
00218                        "sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
00219     
00220     m_readStmt->setInt(1, result->getId());
00221     ResultSet* rset = m_readStmt->executeQuery();
00222     
00223     rset->next();
00224     
00225     result->setEcalConfigId(       rset->getInt(1) );
00226     result->setSequenceNumber(        rset->getInt(2) );
00227     result->setNumberOfCycles(         rset->getInt(3) );
00228     int seq_def_id=rset->getInt(4);
00229 
00230     m_run_seq.setConnection(m_env, m_conn);
00231     m_run_seq.setByID(seq_def_id);
00232     result->setDescription(   rset->getString(5) );
00233     
00234     
00235   } catch (SQLException &e) {
00236     throw(runtime_error("ODRunConfigSeqInfo::fetchData():  "+e.getMessage()));
00237   }
00238 }

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

Definition at line 43 of file ODRunConfigSeqInfo.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, m_ecal_config_id, IDBObject::m_env, m_ID, m_seq_num, and setByID().

00045 {
00046   // Return from memory if available
00047   if (m_ID>0) {
00048     return m_ID;
00049   }
00050 
00051   this->checkConnection();
00052 
00053 
00054   DateHandler dh(m_env, m_conn);
00055 
00056   try {
00057     Statement* stmt = m_conn->createStatement();
00058     stmt->setSQL("SELECT sequence_id from ECAL_sequence_DAT "
00059                  "WHERE ecal_config_id = :id1 " 
00060                  " and sequence_num = :id2  " );
00061     stmt->setInt(1, m_ecal_config_id);
00062     stmt->setInt(2, m_seq_num);
00063 
00064     ResultSet* rset = stmt->executeQuery();
00065 
00066     if (rset->next()) {
00067       m_ID = rset->getInt(1);
00068     } else {
00069       m_ID = 0;
00070     }
00071     m_conn->terminateStatement(stmt);
00072   } catch (SQLException &e) {
00073     throw(runtime_error("ODRunConfigSeqInfo::fetchID:  "+e.getMessage()));
00074   }
00075   setByID(m_ID);
00076   return m_ID;
00077 }

int ODRunConfigSeqInfo::fetchIDLast (  )  throw (std::runtime_error) [private]

Definition at line 81 of file ODRunConfigSeqInfo.cc.

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

00083 {
00084 
00085   this->checkConnection();
00086 
00087   DateHandler dh(m_env, m_conn);
00088 
00089   try {
00090     Statement* stmt = m_conn->createStatement();
00091     stmt->setSQL("SELECT max(sequence_id) FROM ecal_sequence_dat "      );
00092     ResultSet* rset = stmt->executeQuery();
00093 
00094     if (rset->next()) {
00095       m_ID = rset->getInt(1);
00096     } else {
00097       m_ID = 0;
00098     }
00099     m_conn->terminateStatement(stmt);
00100   } catch (SQLException &e) {
00101     throw(runtime_error("ODRunConfigSeqInfo::fetchIDLast:  "+e.getMessage()));
00102   }
00103 
00104   setByID(m_ID);
00105   return m_ID;
00106 }

std::string ODRunConfigSeqInfo::getDescription (  )  const [inline]

Definition at line 31 of file ODRunConfigSeqInfo.h.

References m_description.

00031 { return m_description;}

int ODRunConfigSeqInfo::getEcalConfigId (  )  const [inline]

Definition at line 33 of file ODRunConfigSeqInfo.h.

References m_ecal_config_id.

00033 { return m_ecal_config_id;}

int ODRunConfigSeqInfo::getId (  )  const [inline]

Definition at line 28 of file ODRunConfigSeqInfo.h.

References m_ID.

00028 { return m_ID; }

int ODRunConfigSeqInfo::getNumberOfCycles (  )  const [inline]

Definition at line 35 of file ODRunConfigSeqInfo.h.

References m_cycles.

00035 {return m_cycles;}

RunSeqDef ODRunConfigSeqInfo::getRunSeqDef (  )  const

Definition at line 31 of file ODRunConfigSeqInfo.cc.

References m_run_seq.

00031 {  return m_run_seq;}

int ODRunConfigSeqInfo::getSequenceNumber (  )  const [inline]

Definition at line 37 of file ODRunConfigSeqInfo.h.

References m_seq_num.

00037 {return m_seq_num;}

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

Implements IODConfig.

Definition at line 22 of file ODRunConfigSeqInfo.h.

00022 { return "ECAL_SEQUENCE_DAT"; }

bool ODRunConfigSeqInfo::operator!= ( const ODRunConfigSeqInfo r  )  const [inline]

Definition at line 44 of file ODRunConfigSeqInfo.h.

00044 { return !(*this == r); }

bool ODRunConfigSeqInfo::operator== ( const ODRunConfigSeqInfo r  )  const [inline]

Definition at line 43 of file ODRunConfigSeqInfo.h.

References m_ID.

00043 {  return (m_ID   == r.m_ID ); }

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

Implements IODConfig.

Definition at line 143 of file ODRunConfigSeqInfo.cc.

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

00145 {
00146   this->checkConnection();
00147 
00148   try {
00149     m_writeStmt = m_conn->createStatement();
00150     m_writeStmt->setSQL("INSERT INTO ECAL_SEQUENCE_DAT ( ecal_config_id, "
00151                         "sequence_num, num_of_cycles, sequence_type_def_id, description ) "
00152                         "VALUES (:1, :2, :3 , :4, :5 )");
00153   } catch (SQLException &e) {
00154     throw(runtime_error("ODRunConfigSeqInfo::prepareWrite():  "+e.getMessage()));
00155   }
00156 }

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

Definition at line 109 of file ODRunConfigSeqInfo.cc.

References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), id, IDBObject::m_conn, m_cycles, m_description, m_ecal_config_id, IDBObject::m_env, m_ID, m_run_seq, m_seq_num, RunSeqDef::setByID(), and IDBObject::setConnection().

Referenced by fetchID(), and fetchIDLast().

00111 {
00112    this->checkConnection();
00113 
00114    DateHandler dh(m_env, m_conn);
00115 
00116    cout<< "ODRunConfigSeqInfo::setByID called for id "<<id<<endl;
00117 
00118    try {
00119      Statement* stmt = m_conn->createStatement();
00120 
00121      stmt->setSQL("SELECT ecal_config_id, sequence_num, num_of_cycles, sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
00122      stmt->setInt(1, id);
00123      
00124      ResultSet* rset = stmt->executeQuery();
00125      if (rset->next()) {
00126        m_ecal_config_id= rset->getInt(1);
00127        m_seq_num=rset->getInt(2);
00128        m_cycles=rset->getInt(3);
00129        int seq_def_id=rset->getInt(4);
00130        m_description= rset->getString(5);
00131        m_ID = id;
00132        m_run_seq.setConnection(m_env, m_conn);
00133        m_run_seq.setByID(seq_def_id);
00134      } else {
00135        throw(runtime_error("ODRunConfigSeqInfo::setByID:  Given config_id is not in the database"));
00136      }
00137      m_conn->terminateStatement(stmt);
00138    } catch (SQLException &e) {
00139      throw(runtime_error("ODRunConfigSeqInfo::setByID:  "+e.getMessage()));
00140    }
00141 }

void ODRunConfigSeqInfo::setDescription ( std::string  x  )  [inline]

Definition at line 30 of file ODRunConfigSeqInfo.h.

References m_description.

00030 { m_description = x; }

void ODRunConfigSeqInfo::setEcalConfigId ( int  x  )  [inline]

Definition at line 32 of file ODRunConfigSeqInfo.h.

References m_ecal_config_id.

00032 { m_ecal_config_id = x; }

void ODRunConfigSeqInfo::setId ( int  id  )  [inline]

Definition at line 27 of file ODRunConfigSeqInfo.h.

References m_ID.

00027 { m_ID = id; }

void ODRunConfigSeqInfo::setNumberOfCycles ( int  x  )  [inline]

Definition at line 34 of file ODRunConfigSeqInfo.h.

References m_cycles.

00034 { m_cycles = x; }

void ODRunConfigSeqInfo::setRunSeqDef ( const RunSeqDef  runSeqDef  ) 

Definition at line 32 of file ODRunConfigSeqInfo.cc.

References m_run_seq.

00033 {
00034   if (run_seq != m_run_seq) {
00035     m_run_seq = run_seq;
00036   }
00037 }

void ODRunConfigSeqInfo::setSequenceNumber ( int  x  )  [inline]

Definition at line 36 of file ODRunConfigSeqInfo.h.

References m_seq_num.

00036 {m_seq_num=x;}

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

Definition at line 157 of file ODRunConfigSeqInfo.cc.

References IDBObject::checkConnection(), IODConfig::checkPrepare(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), IDBObject::m_conn, IDBObject::m_env, m_ID, m_run_seq, IODConfig::m_writeStmt, IDBObject::setConnection(), and RunSeqDef::writeDB().

00159 {
00160   this->checkConnection();
00161   this->checkPrepare();
00162 
00163 
00164 
00165   // Validate the data, use infinity-till convention
00166   DateHandler dh(m_env, m_conn);
00167 
00168   try {
00169 
00170     // get the run mode
00171 
00172 
00173 
00174     m_run_seq.setConnection(m_env, m_conn);
00175     int seq_def_id = m_run_seq.writeDB();
00176 
00177 
00178     m_writeStmt->setInt(1, this->getEcalConfigId());
00179     m_writeStmt->setInt(2, this->getSequenceNumber());
00180     m_writeStmt->setInt(3, this->getNumberOfCycles());
00181     m_writeStmt->setInt(4,seq_def_id );
00182     m_writeStmt->setString(5,this->getDescription() );
00183 
00184     m_writeStmt->executeUpdate();
00185 
00186    } catch (SQLException &e) {
00187     throw(runtime_error("ODRunConfigSeqInfo::writeDB():  "+e.getMessage()));
00188   }
00189   if (!this->fetchID()) {
00190     throw(runtime_error("ODRunConfigSeqInfo::writeDB:  Failed to write"));
00191   }
00192   cout<< "ODRunConfigSeqInfo::writeDB>> done inserting ODRunConfigSeqInfo with id="<<m_ID<<endl;
00193 
00194 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 17 of file ODRunConfigSeqInfo.h.


Member Data Documentation

int ODRunConfigSeqInfo::m_cycles [private]

Definition at line 50 of file ODRunConfigSeqInfo.h.

Referenced by clear(), getNumberOfCycles(), ODRunConfigSeqInfo(), setByID(), and setNumberOfCycles().

std::string ODRunConfigSeqInfo::m_description [private]

Definition at line 52 of file ODRunConfigSeqInfo.h.

Referenced by clear(), getDescription(), ODRunConfigSeqInfo(), setByID(), and setDescription().

int ODRunConfigSeqInfo::m_ecal_config_id [private]

Definition at line 48 of file ODRunConfigSeqInfo.h.

Referenced by clear(), fetchID(), getEcalConfigId(), ODRunConfigSeqInfo(), setByID(), and setEcalConfigId().

int ODRunConfigSeqInfo::m_ID [private]

Definition at line 47 of file ODRunConfigSeqInfo.h.

Referenced by fetchID(), fetchIDLast(), getId(), ODRunConfigSeqInfo(), operator==(), setByID(), setId(), and writeDB().

RunSeqDef ODRunConfigSeqInfo::m_run_seq [private]

Definition at line 51 of file ODRunConfigSeqInfo.h.

Referenced by clear(), fetchData(), getRunSeqDef(), ODRunConfigSeqInfo(), setByID(), setRunSeqDef(), and writeDB().

int ODRunConfigSeqInfo::m_seq_num [private]

Definition at line 49 of file ODRunConfigSeqInfo.h.

Referenced by clear(), fetchID(), getSequenceNumber(), ODRunConfigSeqInfo(), setByID(), and setSequenceNumber().


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