#include <LMFSeqDat.h>
Public Member Functions | |
std::map< int, LMFSeqDat > | fetchByRunIOV (RunIOV &iov) |
std::map< int, LMFSeqDat > | fetchByRunIOV (RunIOV &iov, const LMFColor &col) |
LMFSeqDat | fetchByRunIOV (RunIOV &iov, int seq_num) |
std::map< int, LMFSeqDat > | fetchByRunNumber (int runno) |
LMFSeqDat | fetchByRunNumber (int runno, int seq_num) |
LMFSeqDat | fetchByRunNumber (int runno, Tm taken_at) |
LMFSeqDat | fetchByRunNumber (int runno, std::string taken_at) |
LMFSeqDat | fetchLast () |
RunIOV | fetchLastRun () |
RunIOV | getRunIOV () const |
int | getSequenceNumber () const |
Tm | getSequenceStart () const |
Tm | getSequenceStop () const |
int | getVmax () const |
int | getVmin () const |
bool | isValid () const |
LMFSeqDat () | |
LMFSeqDat (oracle::occi::Environment *env, oracle::occi::Connection *conn) | |
LMFSeqDat (EcalDBConnection *c) | |
bool | operator!= (const LMFSeqDat &m) const |
bool | operator== (const LMFSeqDat &m) const |
LMFSeqDat & | setRunIOV (const RunIOV &iov) |
LMFSeqDat & | setSequenceNumber (int n) |
LMFSeqDat & | setSequenceStart (Tm start) |
LMFSeqDat & | setSequenceStop (Tm end) |
LMFSeqDat & | setVersions (int vmin, int vmax) |
~LMFSeqDat () | |
Private Member Functions | |
std::map< int, LMFSeqDat > | fetchByRunIOV (std::vector< std::string > par, std::string sql, std::string method) throw (std::runtime_error) |
std::map< int, LMFSeqDat > | fetchByRunIOV (int par, std::string sql, std::string method) throw (std::runtime_error) |
std::map< int, LMFSeqDat > | fetchByRunIOV (std::string sql, std::string method) throw (std::runtime_error) |
std::string | fetchIdSql (Statement *stmt) |
void | fetchParentIDs () throw (std::runtime_error) |
void | getParameters (ResultSet *rset) |
std::string | setByIDSql (Statement *stmt, int id) |
void | setVmax (int v) |
void | setVmin (int v) |
std::string | writeDBSql (Statement *stmt) |
Private Attributes | |
RunIOV | m_runIOV |
Friends | |
class | EcalCondDBInterface |
Definition at line 14 of file LMFSeqDat.h.
LMFSeqDat::LMFSeqDat | ( | ) |
Definition at line 10 of file LMFSeqDat.cc.
References LMFUnique::m_intFields, m_runIOV, LMFUnique::m_stringFields, Tm::plusInfinity(), LMFUnique::setClassName(), Tm::str(), and matplotRender::t.
: LMFUnique() { setClassName("LMFSeqDat"); m_runIOV = RunIOV(); m_intFields["seq_num"] = 0; Tm t; t = t.plusInfinity(); m_stringFields["seq_start"] = t.str(); m_stringFields["seq_stop"] = t.str(); m_intFields["vmin"] = 1; m_intFields["vmax"] = 0; }
LMFSeqDat::LMFSeqDat | ( | oracle::occi::Environment * | env, |
oracle::occi::Connection * | conn | ||
) |
Definition at line 37 of file LMFSeqDat.cc.
References LMFUnique::m_intFields, m_runIOV, LMFUnique::m_stringFields, Tm::plusInfinity(), LMFUnique::setClassName(), Tm::str(), and matplotRender::t.
: LMFUnique(env, conn) { setClassName("LMFSeqDat"); m_runIOV = RunIOV(); m_intFields["seq_num"] = 0; Tm t; t = t.plusInfinity(); m_stringFields["seq_start"] = t.str(); m_stringFields["seq_stop"] = t.str(); m_intFields["vmin"] = 1; m_intFields["vmax"] = 0; }
LMFSeqDat::LMFSeqDat | ( | EcalDBConnection * | c | ) |
Definition at line 24 of file LMFSeqDat.cc.
References LMFUnique::m_intFields, m_runIOV, LMFUnique::m_stringFields, Tm::plusInfinity(), LMFUnique::setClassName(), Tm::str(), and matplotRender::t.
: LMFUnique(c) { setClassName("LMFSeqDat"); m_runIOV = RunIOV(); m_intFields["seq_num"] = 0; Tm t; t = t.plusInfinity(); m_stringFields["seq_start"] = t.str(); m_stringFields["seq_stop"] = t.str(); m_intFields["vmin"] = 1; m_intFields["vmax"] = 0; }
LMFSeqDat::~LMFSeqDat | ( | ) |
Definition at line 51 of file LMFSeqDat.cc.
{ }
Definition at line 266 of file LMFSeqDat.cc.
References RunIOV::getID().
Referenced by fetchByRunIOV(), fetchByRunNumber(), and fetchLast().
{ int runIOVID = iov.getID(); return fetchByRunIOV(runIOVID, "SELECT SEQ_ID FROM LMF_SEQ_DAT WHERE RUN_IOV_ID = :1", "fetchByRunIOV"); }
Definition at line 273 of file LMFSeqDat.cc.
References fetchByRunIOV(), LMFUnique::getID(), and RunIOV::getID().
{ int runIOVID = iov.getID(); int colorId = col.getID(); std::vector<std::string> pars; std::stringstream ss; ss << "I" << runIOVID; pars.push_back(ss.str()); ss.str(std::string()); ss << "I" << colorId; pars.push_back(ss.str()); return fetchByRunIOV(pars, "SELECT S.SEQ_ID FROM LMF_SEQ_DAT S JOIN LMF_RUN_IOV R" " ON S.SEQ_ID = R.SEQ_ID WHERE RUN_IOV_ID = :1 AND " " COLOR_ID = :2", "fetchByRunIOVAndColor"); }
Definition at line 66 of file LMFSeqDat.h.
References fetchByRunIOV().
{ return fetchByRunIOV(iov)[seq_num]; }
std::map< int, LMFSeqDat > LMFSeqDat::fetchByRunIOV | ( | int | par, |
std::string | sql, | ||
std::string | method | ||
) | throw (std::runtime_error) [private] |
Definition at line 203 of file LMFSeqDat.cc.
References Gflash::par.
{ std::vector<std::string> pars; std::stringstream ss; ss << "I" << par; pars.push_back(ss.str()); return fetchByRunIOV(pars, sql, method); }
std::map< int, LMFSeqDat > LMFSeqDat::fetchByRunIOV | ( | std::string | sql, |
std::string | method | ||
) | throw (std::runtime_error) [private] |
Definition at line 195 of file LMFSeqDat.cc.
{ std::vector<std::string> pars; return fetchByRunIOV(pars, sql, method); }
std::map< int, LMFSeqDat > LMFSeqDat::fetchByRunIOV | ( | std::vector< std::string > | par, |
std::string | sql, | ||
std::string | method | ||
) | throw (std::runtime_error) [private] |
Definition at line 215 of file LMFSeqDat.cc.
References ExpressReco_HICollisions_FallBack::e, getSequenceNumber(), i, prof2calltree::l, asciidump::s, LMFUnique::setByID(), and IDBObject::setConnection().
{ std::map<int, LMFSeqDat> l; this->checkConnection(); try { Statement *stmt = m_conn->createStatement(); stmt->setSQL(sql); for (unsigned int i = 0; i < pars.size(); i++) { if (pars[i][0] == 'I') { stmt->setInt(i + 1, atoi(pars[i].c_str() + 1)); } else if (pars[i][0] == 'S') { stmt->setString(i + 1, pars[i].c_str() + 1); } else { throw(std::runtime_error(m_className + "::" + method + ": " + "Invalid type")); } } ResultSet *rset = stmt->executeQuery(); while (rset->next()) { int seq_id = rset->getInt(1); LMFSeqDat s; s.setConnection(m_env, m_conn); s.setByID(seq_id); l[s.getSequenceNumber()] = s; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error(m_className + "::" + method + ": " + e.getMessage())); } return l; }
std::map< int, LMFSeqDat > LMFSeqDat::fetchByRunNumber | ( | int | runno | ) |
Definition at line 291 of file LMFSeqDat.cc.
References fetchByRunIOV().
Referenced by fetchByRunNumber().
{ return fetchByRunIOV(runno, "SELECT SEQ_ID FROM LMF_SEQ_DAT D JOIN RUN_IOV R ON " "D.RUN_IOV_ID = R.IOV_ID WHERE RUN_NUM = :1", "fetchByRunNumber"); }
LMFSeqDat LMFSeqDat::fetchByRunNumber | ( | int | runno, |
int | seq_num | ||
) | [inline] |
Definition at line 70 of file LMFSeqDat.h.
References fetchByRunNumber().
{ return fetchByRunNumber(runno)[seq_num]; }
Definition at line 298 of file LMFSeqDat.cc.
References fetchByRunNumber(), and Tm::str().
{ return fetchByRunNumber(runno, taken_at.str()); }
LMFSeqDat LMFSeqDat::fetchByRunNumber | ( | int | runno, |
std::string | taken_at | ||
) |
Definition at line 302 of file LMFSeqDat.cc.
References gather_cfg::cout, fetchByRunIOV(), i, prof2calltree::l, lumiQueryAPI::q, runTheMatrix::ret, and ExpressReco_HICollisions_FallBack::x.
{ std::map<int, LMFSeqDat> l; std::vector<std::string> pars; std::stringstream ss; ss << "I" << runno; pars.push_back(ss.str()); ss.str(std::string()); ss << "S" << taken_at; pars.push_back(ss.str()); std::string q = "SELECT SEQ_ID FROM LMF_SEQ_DAT D JOIN RUN_IOV R ON " "D.RUN_IOV_ID = R.IOV_ID WHERE RUN_NUM = :1 AND " "SEQ_START >= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS') " "AND SEQ_STOP <= TO_DATE(:2, 'YYYY-MM-DD HH24:MI:SS')"; l = fetchByRunIOV(pars, q, "fetchByRunNumberAt"); LMFSeqDat ret; if (l.size() == 1) { std::map<int, LMFSeqDat>::const_iterator x = l.begin(); ret = x->second; } else if (l.size() > 1) { std::cout << "WARNING: Your query returned more than one result. " << std::endl; std::cout << " This was not expected. Please check the DB!!!" << std::endl; std::cout << "Your query: " << std::endl << q << std::endl; std::cout << "Your parameters: " << std::endl; for (unsigned int i = 0; i < pars.size(); i++) { std::cout << i << ": " << pars[i] << std::endl; } } return ret; }
std::string LMFSeqDat::fetchIdSql | ( | Statement * | stmt | ) | [private, virtual] |
Reimplemented from LMFUnique.
Definition at line 75 of file LMFSeqDat.cc.
References gather_cfg::cout, RunIOV::getID(), getSequenceNumber(), getVmax(), getVmin(), LMFUnique::m_className, LMFUnique::m_debug, and m_runIOV.
{ int runIOVID = m_runIOV.getID(); if (!runIOVID) { if (m_debug) { std::cout << m_className << ": RunIOV not set" << endl; } return ""; } if (m_debug) { std::cout << "Run IOV ID: " << runIOVID << std::endl; std::cout << "SEQ # : " << getSequenceNumber() << std::endl; std::cout << "Versions : " << getVmin() << " - " << getVmax() << endl; } std::string sql = "SELECT SEQ_ID FROM LMF_SEQ_DAT " "WHERE " "RUN_IOV_ID = :1 AND " "SEQ_NUM = :2 AND " "VMIN = :3 "; if (getVmax() > 0) { sql += "AND VMAX = :4"; } else { sql += "ORDER BY VMAX DESC"; } stmt->setSQL(sql); stmt->setInt(1, runIOVID); stmt->setInt(2, getSequenceNumber()); stmt->setInt(3, getVmin()); if (getVmax() > 0) { stmt->setInt(4, getVmax()); } return sql; }
LMFSeqDat LMFSeqDat::fetchLast | ( | ) |
Definition at line 251 of file LMFSeqDat.cc.
References fetchByRunIOV(), m, and runTheMatrix::ret.
Referenced by fetchLastRun().
{ LMFSeqDat ret; std::map<int, LMFSeqDat> m = fetchByRunIOV("SELECT SEQ_ID FROM LMF_SEQ_DAT WHERE SEQ_ID = " "(SELECT MAX(SEQ_ID) FROM LMF_SEQ_DAT)", "fetchLast"); if (m.size() > 0) { ret = m.begin()->second; } return ret; }
RunIOV LMFSeqDat::fetchLastRun | ( | ) |
Definition at line 262 of file LMFSeqDat.cc.
References fetchLast(), and getRunIOV().
Referenced by EcalCondDBInterface::fetchLMFLastRun().
void LMFSeqDat::fetchParentIDs | ( | ) | throw (std::runtime_error) [private, virtual] |
Reimplemented from LMFUnique.
Definition at line 181 of file LMFSeqDat.cc.
References RunIOV::getID(), IDBObject::m_conn, IDBObject::m_env, m_runIOV, RunIOV::setByID(), and IDBObject::setConnection().
void LMFSeqDat::getParameters | ( | ResultSet * | rset | ) | [private, virtual] |
Reimplemented from LMFUnique.
Definition at line 118 of file LMFSeqDat.cc.
References DateHandler::dateToTm(), IDBObject::m_conn, IDBObject::m_env, m_runIOV, RunIOV::setByID(), IDBObject::setConnection(), LMFUnique::setInt(), LMFUnique::setString(), and Tm::str().
{ DateHandler dh(m_env, m_conn); int runIOVID = rset->getInt(1); setInt("seq_num", rset->getInt(2)); Date startDate = rset->getDate(3); Date endDate = rset->getDate(4); setInt("vmin", rset->getInt(5)); setInt("vmax", rset->getInt(6)); setString("seq_start", dh.dateToTm( startDate ).str()); setString("seq_stop", dh.dateToTm( endDate ).str()); m_runIOV.setConnection(m_env, m_conn); m_runIOV.setByID(runIOVID); }
RunIOV LMFSeqDat::getRunIOV | ( | ) | const |
Definition at line 61 of file LMFSeqDat.cc.
References m_runIOV.
Referenced by fetchLastRun(), and operator==().
{ return m_runIOV; }
int LMFSeqDat::getSequenceNumber | ( | ) | const [inline] |
Definition at line 41 of file LMFSeqDat.h.
References LMFUnique::getInt().
Referenced by fetchByRunIOV(), fetchIdSql(), operator==(), and writeDBSql().
{ return getInt("seq_num"); }
Tm LMFSeqDat::getSequenceStart | ( | ) | const [inline] |
Definition at line 42 of file LMFSeqDat.h.
References LMFUnique::getString(), Tm::setToString(), and matplotRender::t.
Referenced by isValid(), operator==(), and writeDBSql().
{ Tm t; t.setToString(getString("seq_start")); return t; }
Tm LMFSeqDat::getSequenceStop | ( | ) | const |
Definition at line 55 of file LMFSeqDat.cc.
References LMFUnique::getString(), Tm::setToString(), and matplotRender::t.
Referenced by isValid(), operator==(), and writeDBSql().
{ Tm t; t.setToString(getString("seq_stop")); return t; }
int LMFSeqDat::getVmax | ( | ) | const [inline] |
Definition at line 49 of file LMFSeqDat.h.
References LMFUnique::getInt().
Referenced by fetchIdSql(), operator==(), and writeDBSql().
{ return getInt("vmax"); }
int LMFSeqDat::getVmin | ( | ) | const [inline] |
Definition at line 48 of file LMFSeqDat.h.
References LMFUnique::getInt().
Referenced by fetchIdSql(), operator==(), and writeDBSql().
{ return getInt("vmin"); }
bool LMFSeqDat::isValid | ( | void | ) | const [virtual] |
Reimplemented from LMFUnique.
Definition at line 134 of file LMFSeqDat.cc.
References getSequenceStart(), getSequenceStop(), and runTheMatrix::ret.
Referenced by writeDBSql().
{ bool ret = true; if (getSequenceStart().isNull()) { ret = false; } if ((getSequenceStop().str().length() > 0) && (getSequenceStop().microsTime() < getSequenceStart().microsTime())) { ret = false; } if (getSequenceStop() == Tm().plusInfinity()) { ret = false; } return ret; }
bool LMFSeqDat::operator!= | ( | const LMFSeqDat & | m | ) | const [inline] |
bool LMFSeqDat::operator== | ( | const LMFSeqDat & | m | ) | const [inline] |
Definition at line 53 of file LMFSeqDat.h.
References getRunIOV(), getSequenceNumber(), getSequenceStart(), getSequenceStop(), getVmax(), and getVmin().
{ return ( getSequenceNumber() == m.getSequenceNumber() && getRunIOV() == m.getRunIOV() && getSequenceStart() == m.getSequenceStart() && getSequenceStop() == m.getSequenceStop() && getVmin() == m.getVmin() && getVmax() == m.getVmax()); }
std::string LMFSeqDat::setByIDSql | ( | Statement * | stmt, |
int | id | ||
) | [private, virtual] |
Reimplemented from LMFUnique.
Definition at line 110 of file LMFSeqDat.cc.
{ std::string sql = "SELECT RUN_IOV_ID, SEQ_NUM, SEQ_START, SEQ_STOP, " "VMIN, VMAX FROM LMF_SEQ_DAT WHERE SEQ_ID = :1"; stmt->setSQL(sql); stmt->setInt(1, id); return sql; }
Definition at line 66 of file LMFSeqDat.cc.
References o2o::iov, IUniqueDBObject::m_ID, and m_runIOV.
LMFSeqDat& LMFSeqDat::setSequenceNumber | ( | int | n | ) | [inline] |
Definition at line 26 of file LMFSeqDat.h.
References LMFUnique::setInt().
Definition at line 27 of file LMFSeqDat.h.
References LMFUnique::setString(), and Tm::str().
Definition at line 31 of file LMFSeqDat.h.
References LMFUnique::setString(), and Tm::str().
Referenced by writeDBSql().
LMFSeqDat& LMFSeqDat::setVersions | ( | int | vmin, |
int | vmax | ||
) | [inline] |
void LMFSeqDat::setVmax | ( | int | v | ) | [inline, private] |
Definition at line 84 of file LMFSeqDat.h.
References LMFUnique::setInt().
Referenced by setVersions().
void LMFSeqDat::setVmin | ( | int | v | ) | [inline, private] |
Definition at line 81 of file LMFSeqDat.h.
References LMFUnique::setInt().
Referenced by setVersions().
std::string LMFSeqDat::writeDBSql | ( | Statement * | stmt | ) | [private, virtual] |
Reimplemented from LMFUnique.
Definition at line 149 of file LMFSeqDat.cc.
References gather_cfg::cout, LMFUnique::dump(), RunIOV::getID(), DateHandler::getPlusInfTm(), getSequenceNumber(), getSequenceStart(), getSequenceStop(), getVmax(), getVmin(), isValid(), IDBObject::m_conn, IDBObject::m_env, m_runIOV, LMFUnique::sequencePostfix(), setSequenceStop(), and DateHandler::tmToDate().
{ // Validate the data, use infinity-till convention DateHandler dh(m_env, m_conn); if (!isValid()) { dump(); throw(std::runtime_error("LMFSeqDat::writeDB: not valid")); } if (getSequenceStop().str().length() == 0) { setSequenceStop(dh.getPlusInfTm()); } int runIOVID = m_runIOV.getID(); if (runIOVID == 0) { throw(std::runtime_error("LMFSeqDat::writeDB: RunIOV not set")); } std::string sp = sequencePostfix(getSequenceStart()); std::string sql = "INSERT INTO LMF_SEQ_DAT (SEQ_ID, RUN_IOV_ID, SEQ_NUM, " "SEQ_START, SEQ_STOP, VMIN, VMAX) " "VALUES (SEQ_ID_" + sp + "_SQ.NextVal, :1, :2, :3, :4, :5, :6)"; cout << sql << endl; stmt->setSQL(sql); stmt->setInt(1, runIOVID); stmt->setInt(2, getSequenceNumber()); stmt->setDate(3, dh.tmToDate(getSequenceStart())); stmt->setDate(4, dh.tmToDate(getSequenceStop())); stmt->setInt(5, getVmin()); stmt->setInt(6, getVmax()); return sql; }
friend class EcalCondDBInterface [friend] |
Reimplemented from LMFUnique.
Definition at line 16 of file LMFSeqDat.h.
RunIOV LMFSeqDat::m_runIOV [private] |
Definition at line 79 of file LMFSeqDat.h.
Referenced by fetchIdSql(), fetchParentIDs(), getParameters(), getRunIOV(), LMFSeqDat(), setRunIOV(), and writeDBSql().