CMS 3D CMS Logo

ODRunConfigInfo Class Reference

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

Inheritance diagram for ODRunConfigInfo:

IODConfig IDBObject

List of all members.

Public Member Functions

Tm getDBTime () const
int getDefaults () const
std::string getDescription () const
int getId () const
int getNumberOfEvents () const
int getNumberOfSequences () const
RunModeDef getRunModeDef () const
RunTypeDef getRunTypeDef () const
std::string getTable ()
std::string getTag () const
std::string getTriggerMode () const
int getVersion () const
 ODRunConfigInfo ()
bool operator!= (const ODRunConfigInfo &r) const
bool operator== (const ODRunConfigInfo &r) const
void setDefaults (int x)
void setDescription (std::string x)
void setId (int id)
void setNumberOfEvents (int x)
void setNumberOfSequences (int n)
void setRunModeDef (const RunModeDef runModeDef)
void setRunTypeDef (const RunTypeDef runTypeDef)
void setTag (std::string x)
void setTriggerMode (std::string x)
void setVersion (int x)
 ~ODRunConfigInfo ()

Private Member Functions

void fetchData (ODRunConfigInfo *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchIDFromTagAndVersion () throw (std::runtime_error)
int fetchIDLast () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void setByID (int id) throw (std::runtime_error)
int updateDefaultCycle () throw (runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

Tm m_db_time
int m_defaults
std::string m_description
int m_ID
int m_num_events
int m_num_seq
RunModeDef m_runModeDef
RunTypeDef m_runTypeDef
std::string m_tag
std::string m_trigger_mode
int m_version

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file ODRunConfigInfo.h.


Constructor & Destructor Documentation

ODRunConfigInfo::ODRunConfigInfo (  ) 

Definition at line 12 of file ODRunConfigInfo.cc.

References IDBObject::m_conn, m_defaults, m_ID, m_num_events, m_num_seq, m_runModeDef, m_runTypeDef, m_tag, m_trigger_mode, m_version, and NULL.

00013 {
00014   m_conn = NULL;
00015   m_ID = 0;
00016   //
00017   m_tag ="";
00018   m_version=0;
00019   m_num_seq=0;
00020   m_runTypeDef = RunTypeDef();
00021   m_runModeDef = RunModeDef();
00022   m_defaults=0;
00023   m_trigger_mode=""; 
00024   m_num_events=0;
00025 }

ODRunConfigInfo::~ODRunConfigInfo (  ) 

Definition at line 29 of file ODRunConfigInfo.cc.

00029 {}


Member Function Documentation

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

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

Definition at line 74 of file ODRunConfigInfo.cc.

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

Referenced by fetchIDFromTagAndVersion().

00076 {
00077   // Return from memory if available
00078   if (m_ID>0) {
00079     return m_ID;
00080   }
00081 
00082   this->checkConnection();
00083 
00084 
00085   DateHandler dh(m_env, m_conn);
00086 
00087   try {
00088     Statement* stmt = m_conn->createStatement();
00089     stmt->setSQL("SELECT config_id from ECAL_RUN_CONFIGURATION_DAT "
00090                  "WHERE tag = :tag " 
00091                  " and version = :version " );
00092     stmt->setString(1, m_tag);
00093     stmt->setInt(2, m_version);
00094 
00095     ResultSet* rset = stmt->executeQuery();
00096 
00097     if (rset->next()) {
00098       m_ID = rset->getInt(1);
00099     } else {
00100       m_ID = 0;
00101     }
00102     m_conn->terminateStatement(stmt);
00103   } catch (SQLException &e) {
00104     throw(runtime_error("ODRunConfigInfo::fetchID:  "+e.getMessage()));
00105   }
00106   setByID(m_ID);
00107   return m_ID;
00108 }

int ODRunConfigInfo::fetchIDFromTagAndVersion (  )  throw (std::runtime_error) [private]

Definition at line 140 of file ODRunConfigInfo.cc.

References fetchID(), and m_ID.

00142 {
00143   fetchID();
00144   return m_ID;
00145 }

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

Definition at line 112 of file ODRunConfigInfo.cc.

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

00114 {
00115 
00116   this->checkConnection();
00117 
00118   DateHandler dh(m_env, m_conn);
00119 
00120   try {
00121     Statement* stmt = m_conn->createStatement();
00122     stmt->setSQL("SELECT max(config_id) FROM ecal_run_configuration_dat "       );
00123     ResultSet* rset = stmt->executeQuery();
00124 
00125     if (rset->next()) {
00126       m_ID = rset->getInt(1);
00127     } else {
00128       m_ID = 0;
00129     }
00130     m_conn->terminateStatement(stmt);
00131   } catch (SQLException &e) {
00132     throw(runtime_error("ODRunConfigInfo::fetchIDLast:  "+e.getMessage()));
00133   }
00134 
00135   setByID(m_ID);
00136   return m_ID;
00137 }

int ODRunConfigInfo::fetchNextId (  )  throw (std::runtime_error) [private]

Definition at line 53 of file ODRunConfigInfo.cc.

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

Referenced by prepareWrite().

00053                                                           {
00054 
00055   int result=0;
00056   try {
00057     this->checkConnection();
00058 
00059     m_readStmt = m_conn->createStatement(); 
00060     m_readStmt->setSQL("select ecal_run_sq.NextVal from dual");
00061     ResultSet* rset = m_readStmt->executeQuery();
00062     while (rset->next ()){
00063       result= rset->getInt(1);
00064     }
00065     m_conn->terminateStatement(m_readStmt);
00066     return result; 
00067 
00068   } catch (SQLException &e) {
00069     throw(runtime_error("ODDCCConfig::fetchNextId():  "+e.getMessage()));
00070   }
00071 
00072 }

Tm ODRunConfigInfo::getDBTime (  )  const [inline]

Definition at line 25 of file ODRunConfigInfo.h.

References m_db_time.

00025 {  return m_db_time;}

int ODRunConfigInfo::getDefaults (  )  const [inline]

Definition at line 40 of file ODRunConfigInfo.h.

References m_defaults.

00040 {  return m_defaults;}

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

Definition at line 31 of file ODRunConfigInfo.h.

References m_description.

00031 {  return m_description;}

int ODRunConfigInfo::getId (  )  const [inline]

Definition at line 21 of file ODRunConfigInfo.h.

References m_ID.

00021 { return m_ID; }

int ODRunConfigInfo::getNumberOfEvents (  )  const [inline]

Definition at line 46 of file ODRunConfigInfo.h.

References m_num_events.

00046 {  return m_num_events ;}

int ODRunConfigInfo::getNumberOfSequences (  )  const [inline]

Definition at line 37 of file ODRunConfigInfo.h.

References m_num_seq.

00037 {return m_num_seq;  }

RunModeDef ODRunConfigInfo::getRunModeDef (  )  const

Definition at line 43 of file ODRunConfigInfo.cc.

References m_runModeDef.

00043 {  return m_runModeDef;}

RunTypeDef ODRunConfigInfo::getRunTypeDef (  )  const

Definition at line 34 of file ODRunConfigInfo.cc.

References m_runTypeDef.

00034 {  return m_runTypeDef;}

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

Implements IODConfig.

Definition at line 18 of file ODRunConfigInfo.h.

00018 { return "ECAL_RUN_CONFIGURATION_DAT"; }

std::string ODRunConfigInfo::getTag ( void   )  const [inline]

Definition at line 28 of file ODRunConfigInfo.h.

References m_tag.

00028 {  return m_tag;}

std::string ODRunConfigInfo::getTriggerMode (  )  const [inline]

Definition at line 43 of file ODRunConfigInfo.h.

References m_trigger_mode.

00043 {  return m_trigger_mode;}

int ODRunConfigInfo::getVersion (  )  const [inline]

Definition at line 34 of file ODRunConfigInfo.h.

References m_version.

00034 {return m_version;  }

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

Definition at line 58 of file ODRunConfigInfo.h.

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

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

Definition at line 57 of file ODRunConfigInfo.h.

References m_ID.

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

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

Implements IODConfig.

Definition at line 194 of file ODRunConfigInfo.cc.

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

00196 {
00197   this->checkConnection();
00198 
00199   int next_id=fetchNextId();
00200 
00201 
00202 
00203 
00204   try {
00205     m_writeStmt = m_conn->createStatement();
00206     m_writeStmt->setSQL("INSERT INTO ECAL_RUN_CONFIGURATION_DAT (CONFIG_ID, tag, version, run_type_def_id, "
00207                  " run_mode_def_id, num_of_sequences, defaults, trg_mode, num_of_events, description ) "
00208                  " VALUES (:1, :2, :3 , :4, :5, :6 ,:7, :8, :9, :10 )");
00209 
00210     m_writeStmt->setInt(1, next_id);
00211     m_ID=next_id;
00212 
00213   } catch (SQLException &e) {
00214     throw(runtime_error("ODRunConfigInfo::prepareWrite():  "+e.getMessage()));
00215   }
00216 }

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

Definition at line 149 of file ODRunConfigInfo.cc.

References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, DateHandler::dateToTm(), e, lat::endl(), id, IDBObject::m_conn, m_db_time, m_defaults, m_description, IDBObject::m_env, m_ID, m_num_events, m_num_seq, m_runModeDef, m_runTypeDef, m_tag, m_trigger_mode, m_version, RunTypeDef::setByID(), RunModeDef::setByID(), and IDBObject::setConnection().

Referenced by fetchID(), fetchIDLast(), and writeDB().

00151 {
00152    this->checkConnection();
00153 
00154    DateHandler dh(m_env, m_conn);
00155 
00156    cout<< "ODRunConfigInfo::setByID called for id "<<id<<endl;
00157 
00158    try {
00159      Statement* stmt = m_conn->createStatement();
00160 
00161      stmt->setSQL("SELECT tag, version, run_type_def_id, run_mode_def_id, num_of_sequences, description, defaults,"
00162                   " trg_mode,num_of_events, db_timestamp"
00163                   " FROM ECAL_RUN_CONFIGURATION_DAT WHERE config_id = :1");
00164      stmt->setInt(1, id);
00165      
00166      ResultSet* rset = stmt->executeQuery();
00167      if (rset->next()) {
00168        m_tag= rset->getString(1);
00169        m_version= rset->getInt(2);
00170        int run_type_id=rset->getInt(3);
00171        int run_mode_id=rset->getInt(4);
00172        m_num_seq=rset->getInt(5);
00173        m_description= rset->getString(6);
00174        m_defaults= rset->getInt(7);
00175        m_trigger_mode= rset->getString(8);
00176        m_num_events= rset->getInt(9);
00177        Date dbdate = rset->getDate(10);
00178        m_db_time = dh.dateToTm( dbdate );
00179        m_ID = id;
00180        m_runModeDef.setConnection(m_env, m_conn);
00181        m_runModeDef.setByID(run_mode_id);
00182        m_runTypeDef.setConnection(m_env, m_conn);
00183        m_runTypeDef.setByID(run_type_id);
00184 
00185      } else {
00186        throw(runtime_error("ODRunConfigInfo::setByID:  Given config_id is not in the database"));
00187      }
00188      m_conn->terminateStatement(stmt);
00189    } catch (SQLException &e) {
00190      throw(runtime_error("ODRunConfigInfo::setByID:  "+e.getMessage()));
00191    }
00192 }

void ODRunConfigInfo::setDefaults ( int  x  )  [inline]

Definition at line 39 of file ODRunConfigInfo.h.

References m_defaults.

00039 { m_defaults = x;}

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

Definition at line 30 of file ODRunConfigInfo.h.

References m_description.

00030 { m_description = x;}

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

Definition at line 20 of file ODRunConfigInfo.h.

References m_ID.

00020 { m_ID = id; }

void ODRunConfigInfo::setNumberOfEvents ( int  x  )  [inline]

Definition at line 45 of file ODRunConfigInfo.h.

References m_num_events.

00045 { m_num_events = x ;}

void ODRunConfigInfo::setNumberOfSequences ( int  n  )  [inline]

Definition at line 36 of file ODRunConfigInfo.h.

References m_num_seq.

00036 { m_num_seq = n;  }

void ODRunConfigInfo::setRunModeDef ( const RunModeDef  runModeDef  ) 

Definition at line 44 of file ODRunConfigInfo.cc.

References m_ID, and m_runModeDef.

00045 {
00046   if (runModeDef != m_runModeDef) {
00047     m_ID = 0;
00048     m_runModeDef = runModeDef;
00049   }
00050 }

void ODRunConfigInfo::setRunTypeDef ( const RunTypeDef  runTypeDef  ) 

Definition at line 35 of file ODRunConfigInfo.cc.

References m_ID, and m_runTypeDef.

00036 {
00037   if (runTypeDef != m_runTypeDef) {
00038     m_ID = 0;
00039     m_runTypeDef = runTypeDef;
00040   }
00041 }

void ODRunConfigInfo::setTag ( std::string  x  )  [inline]

Definition at line 27 of file ODRunConfigInfo.h.

References m_tag.

00027 { m_tag = x; }

void ODRunConfigInfo::setTriggerMode ( std::string  x  )  [inline]

Definition at line 42 of file ODRunConfigInfo.h.

References m_trigger_mode.

00042 { m_trigger_mode = x;}

void ODRunConfigInfo::setVersion ( int  x  )  [inline]

Definition at line 33 of file ODRunConfigInfo.h.

References m_version.

00033 { m_version = x;  }

int ODRunConfigInfo::updateDefaultCycle (  )  throw (runtime_error) [private]

Definition at line 266 of file ODRunConfigInfo.cc.

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

00268 {
00269   this->checkConnection();
00270 
00271   // Check if this has already been written
00272   if(!this->fetchID()){
00273     this->writeDB();
00274   }
00275 
00276 
00277   try {
00278     Statement* stmt = m_conn->createStatement();
00279     
00280     stmt->setSQL("UPDATE ecal_run_configuration_dat set defaults=:1 where config_id=:2 " );
00281    
00282     stmt->setInt(1, m_defaults);
00283     stmt->setInt(2, m_ID);
00284 
00285     stmt->executeUpdate();
00286 
00287     m_conn->terminateStatement(stmt);
00288   } catch (SQLException &e) {
00289     throw(runtime_error("ODRunConfigInfo::writeDB:  "+e.getMessage()));
00290   }
00291   
00292   return m_ID;
00293 }

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

Definition at line 219 of file ODRunConfigInfo.cc.

References IDBObject::checkConnection(), IODConfig::checkPrepare(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), RunModeDef::fetchID(), RunTypeDef::fetchID(), IDBObject::m_conn, IDBObject::m_env, m_ID, m_runModeDef, m_runTypeDef, IODConfig::m_writeStmt, setByID(), and IDBObject::setConnection().

Referenced by updateDefaultCycle().

00221 {
00222   this->checkConnection();
00223   this->checkPrepare();
00224 
00225   // Validate the data, use infinity-till convention
00226   DateHandler dh(m_env, m_conn);
00227 
00228   try {
00229     
00230     // get the run mode
00231     m_runModeDef.setConnection(m_env, m_conn);
00232     int run_mode_id = m_runModeDef.fetchID();
00233 
00234     // get the run type
00235     m_runTypeDef.setConnection(m_env, m_conn);
00236     int run_type_id = m_runTypeDef.fetchID();
00237 
00238     // now insert 
00239 
00240     m_writeStmt->setString(2, this->getTag());
00241     m_writeStmt->setInt(3, this->getVersion());
00242     m_writeStmt->setInt(4, run_type_id);
00243     m_writeStmt->setInt(5, run_mode_id);
00244     m_writeStmt->setInt(6, this->getNumberOfSequences());
00245     m_writeStmt->setInt(7, this->getDefaults());
00246     m_writeStmt->setString(8, this->getTriggerMode());
00247     m_writeStmt->setInt(9, this->getNumberOfEvents());
00248     m_writeStmt->setString(10, this->getDescription());
00249 
00250     m_writeStmt->executeUpdate();
00251 
00252   } catch (SQLException &e) {
00253     throw(runtime_error("ODRunConfigInfo::writeDB:  "+e.getMessage()));
00254   }
00255   // Now get the ID
00256   if (!this->fetchID()) {
00257     throw(runtime_error("ODRunConfigInfo::writeDB  Failed to write"));
00258   }
00259 
00260   this->setByID(m_ID);
00261 
00262   cout<< "ODRunConfigInfo::writeDB>> done inserting ODRunConfigInfo with id="<<m_ID<<endl;
00263 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file ODRunConfigInfo.h.


Member Data Documentation

Tm ODRunConfigInfo::m_db_time [private]

Definition at line 63 of file ODRunConfigInfo.h.

Referenced by getDBTime(), and setByID().

int ODRunConfigInfo::m_defaults [private]

Definition at line 70 of file ODRunConfigInfo.h.

Referenced by getDefaults(), ODRunConfigInfo(), setByID(), setDefaults(), and updateDefaultCycle().

std::string ODRunConfigInfo::m_description [private]

Definition at line 69 of file ODRunConfigInfo.h.

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

int ODRunConfigInfo::m_ID [private]

Definition at line 62 of file ODRunConfigInfo.h.

Referenced by fetchID(), fetchIDFromTagAndVersion(), fetchIDLast(), getId(), ODRunConfigInfo(), operator==(), prepareWrite(), setByID(), setId(), setRunModeDef(), setRunTypeDef(), updateDefaultCycle(), and writeDB().

int ODRunConfigInfo::m_num_events [private]

Definition at line 72 of file ODRunConfigInfo.h.

Referenced by getNumberOfEvents(), ODRunConfigInfo(), setByID(), and setNumberOfEvents().

int ODRunConfigInfo::m_num_seq [private]

Definition at line 68 of file ODRunConfigInfo.h.

Referenced by getNumberOfSequences(), ODRunConfigInfo(), setByID(), and setNumberOfSequences().

RunModeDef ODRunConfigInfo::m_runModeDef [private]

Definition at line 66 of file ODRunConfigInfo.h.

Referenced by getRunModeDef(), ODRunConfigInfo(), setByID(), setRunModeDef(), and writeDB().

RunTypeDef ODRunConfigInfo::m_runTypeDef [private]

Definition at line 67 of file ODRunConfigInfo.h.

Referenced by getRunTypeDef(), ODRunConfigInfo(), setByID(), setRunTypeDef(), and writeDB().

std::string ODRunConfigInfo::m_tag [private]

Definition at line 64 of file ODRunConfigInfo.h.

Referenced by fetchID(), getTag(), ODRunConfigInfo(), setByID(), and setTag().

std::string ODRunConfigInfo::m_trigger_mode [private]

Definition at line 71 of file ODRunConfigInfo.h.

Referenced by getTriggerMode(), ODRunConfigInfo(), setByID(), and setTriggerMode().

int ODRunConfigInfo::m_version [private]

Definition at line 65 of file ODRunConfigInfo.h.

Referenced by fetchID(), getVersion(), ODRunConfigInfo(), setByID(), and setVersion().


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