![]() |
![]() |
#include <MonRunTag.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
std::string | getGeneralTag () const |
MonVersionDef | getMonVersionDef () const |
MonRunTag () | |
bool | operator!= (const MonRunTag &t) const |
bool | operator== (const MonRunTag &t) const |
void | setByID (int id) throw (std::runtime_error) |
void | setGeneralTag (std::string tag) |
void | setMonVersionDef (MonVersionDef ver) |
~MonRunTag () | |
Private Member Functions | |
void | fetchAllTags (std::vector< MonRunTag > *fillVec) throw (std::runtime_error) |
void | fetchParentIDs (int *verID) throw (std::runtime_error) |
int | writeDB () throw (std::runtime_error) |
Private Attributes | |
std::string | m_genTag |
MonVersionDef | m_monVersionDef |
Friends | |
class | EcalCondDBInterface |
class | MonRunIOV |
Tag for Monitoring Sub-Run information
Definition at line 14 of file MonRunTag.h.
MonRunTag::MonRunTag | ( | ) |
Definition at line 9 of file MonRunTag.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_ID = 0; m_genTag = "default"; m_monVersionDef = MonVersionDef(); }
MonRunTag::~MonRunTag | ( | ) |
Definition at line 20 of file MonRunTag.cc.
{ }
void MonRunTag::fetchAllTags | ( | std::vector< MonRunTag > * | fillVec | ) | throw (std::runtime_error) [private] |
Definition at line 169 of file MonRunTag.cc.
References setByID(), and IDBObject::setConnection().
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id FROM mon_run_tag ORDER BY tag_id"); ResultSet* rset = stmt->executeQuery(); MonRunTag runtag; runtag.setConnection(m_env, m_conn); while(rset->next()) { runtag.setByID( rset->getInt(1) ); fillVec->push_back( runtag ); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunTag::fetchAllTags: "+e.getMessage())); } }
int MonRunTag::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 59 of file MonRunTag.cc.
{ // Return tag from memory if available if (m_ID) { return m_ID; } this->checkConnection(); // fetch parent IDs int verID; this->fetchParentIDs(&verID); // fetch this ID try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id FROM mon_run_tag WHERE " "gen_tag = :1 AND " "mon_ver_id = :2"); stmt->setString(1, m_genTag); stmt->setInt(2, verID); 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("MonRunTag::fetchID: "+e.getMessage())); } return m_ID; }
void MonRunTag::fetchParentIDs | ( | int * | verID | ) | throw (std::runtime_error) [private] |
Definition at line 192 of file MonRunTag.cc.
{ // get the monitoring version m_monVersionDef.setConnection(m_env, m_conn); *verID = m_monVersionDef.fetchID(); if (! *verID) { throw(std::runtime_error("MonRunTag::writeDB: Given monitoring version does not exist in DB")); } }
string MonRunTag::getGeneralTag | ( | ) | const |
Definition at line 26 of file MonRunTag.cc.
{ return m_genTag; }
MonVersionDef MonRunTag::getMonVersionDef | ( | ) | const |
Definition at line 43 of file MonRunTag.cc.
{ return m_monVersionDef; }
bool MonRunTag::operator!= | ( | const MonRunTag & | t | ) | const [inline] |
bool MonRunTag::operator== | ( | const MonRunTag & | t | ) | const [inline] |
Definition at line 34 of file MonRunTag.h.
References m_genTag, and m_monVersionDef.
{ return (m_genTag == t.m_genTag && m_monVersionDef == t.m_monVersionDef); }
void MonRunTag::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 100 of file MonRunTag.cc.
Referenced by fetchAllTags().
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT gen_tag, mon_ver_id FROM mon_run_tag WHERE tag_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_genTag = rset->getString(1); int verID = rset->getInt(2); m_monVersionDef.setByID(verID); m_ID = id; } else { throw(std::runtime_error("MonRunTag::setByID: Given tag_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunTag::setByID: "+e.getMessage())); } }
void MonRunTag::setGeneralTag | ( | std::string | tag | ) |
Referenced by popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), EcalEndcapMonitorClient::writeDb(), EcalBarrelMonitorClient::writeDb(), and EcalPedOffset::writeDb().
void MonRunTag::setMonVersionDef | ( | MonVersionDef | ver | ) |
Definition at line 49 of file MonRunTag.cc.
Referenced by popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), EcalEndcapMonitorClient::writeDb(), EcalBarrelMonitorClient::writeDb(), and EcalPedOffset::writeDb().
{ if (ver != m_monVersionDef) { m_ID = 0; m_monVersionDef = ver; } }
int MonRunTag::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 128 of file MonRunTag.cc.
{ // see if this data is already in the DB if (this->fetchID()) { return m_ID; } // check the connectioin this->checkConnection(); // fetch parent IDs int verID; this->fetchParentIDs(&verID); // write new tag to the DB try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("INSERT INTO mon_run_tag (tag_id, gen_tag, mon_ver_id) " "VALUES (mon_run_tag_sq.NextVal, :1, :2)"); stmt->setString(1, m_genTag); stmt->setInt(2, verID); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("MonRunTag::writeDB: "+e.getMessage())); } // now get the tag_id if (!this->fetchID()) { throw(std::runtime_error("MonRunTag::writeDB: Failed to write")); } return m_ID; }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 17 of file MonRunTag.h.
friend class MonRunIOV [friend] |
Definition at line 16 of file MonRunTag.h.
std::string MonRunTag::m_genTag [private] |
Definition at line 44 of file MonRunTag.h.
Referenced by operator==().
MonVersionDef MonRunTag::m_monVersionDef [private] |
Definition at line 45 of file MonRunTag.h.
Referenced by operator==().