#include <CaliIOV.h>
Public Member Functions | |
CaliIOV () | |
int | fetchID () throw (std::runtime_error) |
CaliTag | getCaliTag () const |
int | getID () |
Tm | getSince () const |
Tm | getTill () const |
bool | operator!= (const CaliIOV &m) const |
bool | operator== (const CaliIOV &m) const |
void | setByID (int id) throw (std::runtime_error) |
void | setCaliTag (CaliTag tag) |
void | setSince (Tm since) |
void | setTill (Tm till) |
~CaliIOV () | |
Private Member Functions | |
void | setByTm (CaliTag *tag, Tm time) throw (std::runtime_error) |
int | writeDB () throw (std::runtime_error) |
Private Attributes | |
CaliTag | m_caliTag |
Tm | m_since |
Tm | m_till |
Friends | |
class | EcalCondDBInterface |
CaliIOV::CaliIOV | ( | ) |
CaliIOV::~CaliIOV | ( | ) |
Definition at line 22 of file CaliIOV.cc.
{ }
int CaliIOV::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 79 of file CaliIOV.cc.
References alignCSCRings::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().
{ // Return from memory if available if (m_ID) { return m_ID; } this->checkConnection(); m_caliTag.setConnection(m_env, m_conn); int tagID = m_caliTag.fetchID(); if (!tagID) { return 0; } DateHandler dh(m_env, m_conn); if (m_till.isNull()) { m_till = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id FROM cali_iov " "WHERE tag_id = :tag_id AND " "since = :since AND " "till = :till"); stmt->setInt(1, tagID); stmt->setDate(2, dh.tmToDate(m_since)); stmt->setDate(3, dh.tmToDate(m_till)); 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("CaliIOV::fetchID: "+e.getMessage())); } return m_ID; }
CaliTag CaliIOV::getCaliTag | ( | ) | const |
Definition at line 72 of file CaliIOV.cc.
{ return m_caliTag; }
int CaliIOV::getID | ( | ) | [inline] |
Tm CaliIOV::getSince | ( | ) | const |
Definition at line 38 of file CaliIOV.cc.
{ return m_since; }
Tm CaliIOV::getTill | ( | ) | const |
Definition at line 55 of file CaliIOV.cc.
{ return m_till; }
bool CaliIOV::operator!= | ( | const CaliIOV & | m | ) | const [inline] |
bool CaliIOV::operator== | ( | const CaliIOV & | m | ) | const [inline] |
void CaliIOV::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 128 of file CaliIOV.cc.
References DateHandler::dateToTm(), and alignCSCRings::e.
{ this->checkConnection(); DateHandler dh(m_env, m_conn); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id, since, till FROM cali_iov WHERE iov_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { int tagID = rset->getInt(1); Date since = rset->getDate(2); Date till = rset->getDate(3); m_since = dh.dateToTm( since ); m_till = dh.dateToTm( till ); m_caliTag.setConnection(m_env, m_conn); m_caliTag.setByID(tagID); m_ID = id; } else { throw(std::runtime_error("CaliTag::setByID: Given tag_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("CaliTag::setByID: "+e.getMessage())); } }
Definition at line 215 of file CaliIOV.cc.
References DateHandler::dateToTm(), alignCSCRings::e, GlobalPosition_Frontier_DevDB_cff::tag, and DateHandler::tmToDate().
Referenced by EcalCondDBInterface::fetchCaliIOV().
{ this->checkConnection(); tag->setConnection(m_env, m_conn); int tagID = tag->fetchID(); if (!tagID) { throw(std::runtime_error("CaliIOV::setByTm: Given CaliTag does not exist in the DB")); } DateHandler dh(m_env, m_conn); Date eventDate = dh.tmToDate(eventTm); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT iov_id, since, till FROM cali_iov " "WHERE tag_id = :1 AND since <= :2 AND till > :3"); stmt->setInt(1, tagID); stmt->setDate(2, eventDate); stmt->setDate(3, eventDate); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_caliTag = *tag; m_ID = rset->getInt(1); Date sinceDate = rset->getDate(2); Date tillDate = rset->getDate(3); m_since = dh.dateToTm( sinceDate ); m_till = dh.dateToTm( tillDate ); } else { throw(std::runtime_error("CaliIOV::setByTm: Given subrun is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("CaliIOV::setByTm: "+e.getMessage())); } }
void CaliIOV::setCaliTag | ( | CaliTag | tag | ) |
Definition at line 62 of file CaliIOV.cc.
References GlobalPosition_Frontier_DevDB_cff::tag.
void CaliIOV::setSince | ( | Tm | since | ) |
Definition at line 28 of file CaliIOV.cc.
void CaliIOV::setTill | ( | Tm | till | ) |
Definition at line 45 of file CaliIOV.cc.
int CaliIOV::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 165 of file CaliIOV.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; } m_caliTag.setConnection(m_env, m_conn); int tagID = m_caliTag.writeDB(); // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); if (m_since.isNull()) { throw(std::runtime_error("CaliIOV::writeDB: Must setSince before writing")); } if (m_till.isNull()) { m_till = dh.getPlusInfTm(); } try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("INSERT INTO cali_iov (iov_id, tag_id, since, till) " "VALUES (cali_iov_sq.NextVal, :1, :2, :3)"); stmt->setInt(1, tagID); stmt->setDate(2, dh.tmToDate(m_since)); stmt->setDate(3, dh.tmToDate(m_till)); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("CaliIOV::writeDB: "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("CaliIOV::writeDB: Failed to write")); } return m_ID; }
friend class EcalCondDBInterface [friend] |
CaliTag CaliIOV::m_caliTag [private] |
Definition at line 50 of file CaliIOV.h.
Referenced by operator==().
Tm CaliIOV::m_since [private] |
Definition at line 48 of file CaliIOV.h.
Referenced by operator==().
Tm CaliIOV::m_till [private] |
Definition at line 49 of file CaliIOV.h.
Referenced by operator==().