![]() |
![]() |
#include <RunTag.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
std::string | getGeneralTag () const |
LocationDef | getLocationDef () const |
RunTypeDef | getRunTypeDef () const |
bool | operator!= (const RunTag &t) const |
bool | operator== (const RunTag &t) const |
RunTag () | |
void | setByID (int id) throw (std::runtime_error) |
void | setGeneralTag (std::string tag) |
void | setLocationDef (const LocationDef locDef) |
void | setRunTypeDef (const RunTypeDef runTypeDef) |
~RunTag () | |
Private Member Functions | |
void | fetchAllTags (std::vector< RunTag > *fillVec) throw (std::runtime_error) |
void | fetchParentIDs (int *locId, int *runTypeID) throw (std::runtime_error) |
int | writeDB () throw (std::runtime_error) |
Private Attributes | |
std::string | m_genTag |
LocationDef | m_locDef |
RunTypeDef | m_runTypeDef |
Friends | |
class | EcalCondDBInterface |
class | RunIOV |
RunTag::RunTag | ( | ) |
Definition at line 9 of file RunTag.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_ID = 0; m_genTag = "default"; m_locDef = LocationDef(); m_runTypeDef = RunTypeDef(); }
void RunTag::fetchAllTags | ( | std::vector< RunTag > * | fillVec | ) | throw (std::runtime_error) [private] |
Definition at line 204 of file RunTag.cc.
References setByID(), and IDBObject::setConnection().
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id FROM run_tag ORDER BY tag_id"); ResultSet* rset = stmt->executeQuery(); RunTag 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("RunTag::fetchAllTags: "+e.getMessage())); } }
int RunTag::fetchID | ( | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 80 of file RunTag.cc.
{ // Return tag from memory if available if (m_ID) { return m_ID; } this->checkConnection(); // fetch the parent IDs int locID, runTypeID; this->fetchParentIDs(&locID, &runTypeID); // fetch this ID try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT tag_id FROM run_tag WHERE " "gen_tag = :1 AND " "location_id = :2 AND " "run_type_id = :3"); stmt->setString(1, m_genTag); stmt->setInt(2, locID); stmt->setInt(3, runTypeID); 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("RunTag::fetchID: "+e.getMessage())); } return m_ID; }
void RunTag::fetchParentIDs | ( | int * | locId, |
int * | runTypeID | ||
) | throw (std::runtime_error) [private] |
Definition at line 227 of file RunTag.cc.
{ // get the location m_locDef.setConnection(m_env, m_conn); *locID = m_locDef.fetchID(); // get the run type m_runTypeDef.setConnection(m_env, m_conn); *runTypeID = m_runTypeDef.fetchID(); if (! *locID) { throw(std::runtime_error("RunTag::fetchparentids: Given location does not exist in DB")); } if (! *runTypeID) { throw(std::runtime_error("RunTag::fetchParentIDs: Given run type does not exist in DB")); } }
string RunTag::getGeneralTag | ( | ) | const |
Definition at line 27 of file RunTag.cc.
Referenced by EcalTPGDBApp::printTag().
{ return m_genTag; }
LocationDef RunTag::getLocationDef | ( | ) | const |
Definition at line 46 of file RunTag.cc.
Referenced by EcalTPGDBApp::printTag(), and EcalErrorMask::readDB().
{ return m_locDef; }
RunTypeDef RunTag::getRunTypeDef | ( | ) | const |
Definition at line 63 of file RunTag.cc.
Referenced by EcalTPGDBApp::printTag().
{ return m_runTypeDef; }
bool RunTag::operator!= | ( | const RunTag & | t | ) | const [inline] |
bool RunTag::operator== | ( | const RunTag & | t | ) | const [inline] |
Definition at line 36 of file RunTag.h.
References m_genTag, m_locDef, and m_runTypeDef.
{ return (m_genTag == t.m_genTag && m_locDef == t.m_locDef && m_runTypeDef == t.m_runTypeDef); }
void RunTag::setByID | ( | int | id | ) | throw (std::runtime_error) [virtual] |
Implements IUniqueDBObject.
Definition at line 127 of file RunTag.cc.
Referenced by fetchAllTags().
{ this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT gen_tag, location_id, run_type_id FROM run_tag WHERE tag_id = :1"); stmt->setInt(1, id); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_genTag = rset->getString(1); int locID = rset->getInt(2); int runTypeID = rset->getInt(3); m_locDef.setConnection(m_env, m_conn); m_locDef.setByID(locID); m_runTypeDef.setConnection(m_env, m_conn); m_runTypeDef.setByID(runTypeID); m_ID = id; } else { throw(std::runtime_error("RunTag::setByID: Given tag_id is not in the database")); } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunTag::setByID: "+e.getMessage())); } }
void RunTag::setGeneralTag | ( | std::string | tag | ) |
Definition at line 36 of file CaliTag.cc.
Referenced by EcalEndcapMonitorClient::beginRunDb(), EcalBarrelMonitorClient::beginRunDb(), RunList::fetchGlobalRunsByLocation(), RunList::fetchRunsByLocation(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().
void RunTag::setLocationDef | ( | const LocationDef | locDef | ) |
Definition at line 53 of file RunTag.cc.
Referenced by EcalEndcapMonitorClient::beginRunDb(), EcalBarrelMonitorClient::beginRunDb(), RunList::fetchGlobalRunsByLocation(), RunList::fetchRunsByLocation(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGLutGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().
void RunTag::setRunTypeDef | ( | const RunTypeDef | runTypeDef | ) |
Definition at line 70 of file RunTag.cc.
Referenced by EcalEndcapMonitorClient::beginRunDb(), EcalBarrelMonitorClient::beginRunDb(), RunList::fetchGlobalRunsByLocation(), RunList::fetchRunsByLocation(), popcon::EcalTPGFineGrainEBGroupHandler::getNewObjects(), popcon::EcalTPGFineGrainTowerEEHandler::getNewObjects(), popcon::EcalTPGWeightGroupHandler::getNewObjects(), popcon::EcalTPGBadXTHandler::getNewObjects(), popcon::EcalTPGWeightIdMapHandler::getNewObjects(), popcon::EcalDAQHandler::getNewObjects(), popcon::EcalTPGBadTTHandler::getNewObjects(), popcon::EcalTPGPedestalsHandler::getNewObjects(), popcon::EcalTPGSlidingWindowHandler::getNewObjects(), popcon::EcalTPGFineGrainEBIdMapHandler::getNewObjects(), popcon::EcalTPGPhysicsConstHandler::getNewObjects(), popcon::EcalTPGLinConstHandler::getNewObjects(), popcon::EcalTPGLutIdMapHandler::getNewObjects(), popcon::EcalTPGFineGrainStripEEHandler::getNewObjects(), popcon::EcalChannelStatusHandler::getNewObjects(), popcon::EcalPedestalsHandler::getNewObjectsH2(), popcon::EcalPedestalsHandler::getNewObjectsP5(), EcalTPGDBApp::readFromCondDB_Pedestals(), and EcalPedOffset::writeDb().
{ if (runTypeDef != m_runTypeDef) { m_ID = 0; m_runTypeDef = runTypeDef; } }
int RunTag::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 162 of file RunTag.cc.
{ // see if this data is already in the DB if (this->fetchID()) { return m_ID; } // check the connectioin this->checkConnection(); // fetch the parent IDs int locID, runTypeID; this->fetchParentIDs(&locID, &runTypeID); // write new tag to the DB try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("INSERT INTO run_tag (tag_id, gen_tag, location_id, run_type_id) " "VALUES (run_tag_sq.NextVal, :1, :2, :3)"); stmt->setString(1, m_genTag); stmt->setInt(2, locID); stmt->setInt(3, runTypeID); stmt->executeUpdate(); m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("RunTag::writeDB: "+e.getMessage())); } // now get the tag_id if (!this->fetchID()) { throw(std::runtime_error("RunTag::writeDB: Failed to write")); } return m_ID; }
friend class EcalCondDBInterface [friend] |
std::string RunTag::m_genTag [private] |
Definition at line 47 of file RunTag.h.
Referenced by operator==().
LocationDef RunTag::m_locDef [private] |
Definition at line 48 of file RunTag.h.
Referenced by operator==().
RunTypeDef RunTag::m_runTypeDef [private] |
Definition at line 49 of file RunTag.h.
Referenced by operator==().