#include <MODRunIOV.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
int | getID () |
RunIOV | getRunIOV () |
Tm | getSubRunEnd () const |
run_t | getSubRunNumber () const |
Tm | getSubRunStart () const |
MODRunIOV () | |
bool | operator!= (const MODRunIOV &m) const |
bool | operator== (const MODRunIOV &m) const |
void | setByID (int id) throw (std::runtime_error) |
void | setID (int id) |
void | setRunIOV (RunIOV iov) |
void | setSubRunEnd (Tm end) |
void | setSubRunNumber (subrun_t subrun) |
void | setSubRunStart (Tm start) |
~MODRunIOV () | |
Private Member Functions | |
void | fetchParentIDs (int *runIOVID) throw (std::runtime_error) |
void | setByRun (RunIOV *runiov, subrun_t subrun) throw (std::runtime_error) |
int | writeDB () throw (std::runtime_error) |
Private Attributes | |
RunIOV | m_runIOV |
Tm | m_subRunEnd |
subrun_t | m_subRunNum |
Tm | m_subRunStart |
Friends | |
class | EcalCondDBInterface |
Definition at line 13 of file MODRunIOV.h.
MODRunIOV::MODRunIOV | ( | ) |
Definition at line 12 of file MODRunIOV.cc.
References NULL.
{ m_conn = NULL; m_ID = 0; m_runIOV = RunIOV(); m_subRunNum = 0; m_subRunStart = Tm(); m_subRunEnd = Tm(); }
MODRunIOV::~MODRunIOV | ( | ) |
Definition at line 24 of file MODRunIOV.cc.
{ }
int MODRunIOV::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 101 of file MODRunIOV.cc.
References alignCSCRings::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); // fetch the parent IDs int runIOVID; this->fetchParentIDs(&runIOVID); if (!runIOVID) { return 0; } DateHandler dh(m_env, m_conn); if (m_subRunEnd.isNull()) { m_subRunEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id FROM OD_run_iov " "WHERE " "run_iov_id = :1 AND " "subrun_num = :2 AND " "subrun_start = :3 AND " "subrun_end = :4"); stmt->setInt(1, runIOVID); stmt->setInt(2, m_subRunNum); stmt->setDate(3, dh.tmToDate(m_subRunStart)); stmt->setDate(4, dh.tmToDate(m_subRunEnd)); 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("MODRunIOV::fetchID: "+e.getMessage())); } return m_ID; }
void MODRunIOV::fetchParentIDs | ( | int * | runIOVID | ) | throw (std::runtime_error) [private] |
Definition at line 247 of file MODRunIOV.cc.
int MODRunIOV::getID | ( | ) | [inline] |
RunIOV MODRunIOV::getRunIOV | ( | ) |
Definition at line 44 of file MODRunIOV.cc.
{ return m_runIOV; }
Tm MODRunIOV::getSubRunEnd | ( | ) | const |
Definition at line 94 of file MODRunIOV.cc.
{ return m_subRunEnd; }
run_t MODRunIOV::getSubRunNumber | ( | ) | const |
Definition at line 60 of file MODRunIOV.cc.
{ return m_subRunNum; }
Tm MODRunIOV::getSubRunStart | ( | ) | const |
Definition at line 77 of file MODRunIOV.cc.
{ return m_subRunStart; }
bool MODRunIOV::operator!= | ( | const MODRunIOV & | m | ) | const [inline] |
bool MODRunIOV::operator== | ( | const MODRunIOV & | m | ) | const [inline] |
Definition at line 38 of file MODRunIOV.h.
References m_runIOV, m_subRunEnd, m_subRunNum, and m_subRunStart.
{ return ( m_runIOV == m.m_runIOV && m_subRunNum == m.m_subRunNum && m_subRunStart == m.m_subRunStart && m_subRunEnd == m.m_subRunEnd ); }
void MODRunIOV::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 156 of file MODRunIOV.cc.
References DateHandler::dateToTm(), and alignCSCRings::e.
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT run_iov_id, subrun_num, subrun_start, subrun_end FROM OD_run_iov WHERE iov_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { int runIOVID = rset->getInt(1); m_subRunNum = rset->getInt(2); Date startDate = rset->getDate(3); Date endDate = rset->getDate(4); m_subRunStart = dh.dateToTm( startDate ); m_subRunEnd = dh.dateToTm( endDate ); m_runIOV.setConnection(m_env, m_conn); m_runIOV.setByID(runIOVID); m_ID = id; } else { throw(std::runtime_error("MODRunIOV::setByID: Given id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MODRunIOV::setByID: "+e.getMessage())); } }
Definition at line 262 of file MODRunIOV.cc.
References DateHandler::dateToTm(), and alignCSCRings::e.
{ this->checkConnection(); runiov->setConnection(m_env, m_conn); int runIOVID = runiov->fetchID(); if (!runIOVID) { throw(std::runtime_error("MODRunIOV::setByRun: Given RunIOV does not exist in DB")); } DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id, subrun_start, subrun_end FROM OD_run_iov " "WHERE run_iov_id = :1 AND subrun_num = :2"); stmt->setInt(1, runIOVID); stmt->setInt(2, subrun); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_runIOV = *runiov; m_subRunNum = subrun; m_ID = rset->getInt(1); Date startDate = rset->getDate(2); Date endDate = rset->getDate(3); m_subRunStart = dh.dateToTm( startDate ); m_subRunEnd = dh.dateToTm( endDate ); } else { throw(std::runtime_error("MODRunIOV::setByRun: Given subrun is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MODRunIOV::setByRun: "+e.getMessage())); } }
void MODRunIOV::setID | ( | int | id | ) |
Definition at line 29 of file MODRunIOV.cc.
{ m_ID = id; }
void MODRunIOV::setRunIOV | ( | RunIOV | iov | ) |
void MODRunIOV::setSubRunEnd | ( | Tm | end | ) |
Definition at line 84 of file MODRunIOV.cc.
References end.
{ if (end != m_subRunEnd) { m_ID = 0; m_subRunEnd = end; } }
void MODRunIOV::setSubRunNumber | ( | subrun_t | subrun | ) |
Definition at line 50 of file MODRunIOV.cc.
{ if (subrun != m_subRunNum) { m_ID = 0; m_subRunNum = subrun; } }
void MODRunIOV::setSubRunStart | ( | Tm | start | ) |
Definition at line 67 of file MODRunIOV.cc.
References dqm_diff::start.
{ if (start != m_subRunStart) { m_ID = 0; m_subRunStart = start; } }
int MODRunIOV::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 195 of file MODRunIOV.cc.
References alignCSCRings::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ this->checkConnection(); // Check if this IOV has already been written if (this->fetchID()) { return m_ID; } // fetch Parent IDs int runIOVID; this->fetchParentIDs(&runIOVID); // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); if (m_subRunStart.isNull()) { throw(std::runtime_error("MODRunIOV::writeDB: Must setSubRunStart before writing")); } if (m_subRunEnd.isNull()) { m_subRunEnd = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("INSERT INTO od_run_iov (iov_id, run_iov_id, subrun_num, subrun_start, subrun_end) " "VALUES (OD_run_iov_sq.NextVal, :1, :2, :3, :4)"); stmt->setInt(1, runIOVID); stmt->setInt(2, m_subRunNum); stmt->setDate(3, dh.tmToDate(m_subRunStart)); stmt->setDate(4, dh.tmToDate(m_subRunEnd)); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MODRunIOV::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("MODRunIOV::writeDB: Failed to write")); } return m_ID; }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 15 of file MODRunIOV.h.
RunIOV MODRunIOV::m_runIOV [private] |
Definition at line 50 of file MODRunIOV.h.
Referenced by operator==().
Tm MODRunIOV::m_subRunEnd [private] |
Definition at line 53 of file MODRunIOV.h.
Referenced by operator==().
subrun_t MODRunIOV::m_subRunNum [private] |
Definition at line 51 of file MODRunIOV.h.
Referenced by operator==().
Tm MODRunIOV::m_subRunStart [private] |
Definition at line 52 of file MODRunIOV.h.
Referenced by operator==().