File indexing completed on 2024-04-06 12:23:05
0001 #include "OnlineDB/EcalCondDB/interface/LMFIOV.h"
0002
0003 using namespace std;
0004 using namespace oracle::occi;
0005
0006 LMFIOV::LMFIOV() {
0007
0008 m_env = nullptr;
0009 m_conn = nullptr;
0010 m_className = "LMFIOV";
0011 m_ID = 0;
0012
0013 m_iov_start = Tm();
0014 m_iov_stop = Tm();
0015 m_vmin = 0;
0016 m_vmax = 0;
0017 }
0018
0019 LMFIOV::LMFIOV(EcalDBConnection *c) {
0020
0021 setConnection(c->getEnv(), c->getConn());
0022 m_className = "LMFIOV";
0023 m_ID = 0;
0024
0025 m_iov_start = Tm();
0026 m_iov_stop = Tm();
0027 m_vmin = 0;
0028 m_vmax = 0;
0029 }
0030
0031 LMFIOV::~LMFIOV() {}
0032
0033 LMFIOV &LMFIOV::setStart(const Tm &start) {
0034 m_iov_start = start;
0035 return *this;
0036 }
0037
0038 LMFIOV &LMFIOV::setStop(const Tm &stop) {
0039 m_iov_stop = stop;
0040 return *this;
0041 }
0042
0043 LMFIOV &LMFIOV::setIOV(const Tm &start, const Tm &stop) {
0044 setStart(start);
0045 return setStop(stop);
0046 }
0047
0048 LMFIOV &LMFIOV::setVmin(int vmin) {
0049 m_vmin = vmin;
0050 return *this;
0051 }
0052
0053 LMFIOV &LMFIOV::setVmax(int vmax) {
0054 m_vmax = vmax;
0055 return *this;
0056 }
0057
0058 LMFIOV &LMFIOV::setVersions(int vmin, int vmax) {
0059 setVmin(vmin);
0060 return setVmax(vmax);
0061 }
0062
0063 Tm LMFIOV::getStart() const { return m_iov_start; }
0064
0065 Tm LMFIOV::getStop() const { return m_iov_stop; }
0066
0067 int LMFIOV::getVmin() const { return m_vmin; }
0068
0069 int LMFIOV::getVmax() const { return m_vmax; }
0070
0071 std::string LMFIOV::fetchIdSql(Statement *stmt) {
0072 std::string sql =
0073 "SELECT IOV_ID FROM CMS_ECAL_LASER_COND.LMF_IOV "
0074 "WHERE IOV_START = :1 AND IOV_STOP = :2 AND "
0075 "VMIN = :3 AND VMIN = :4";
0076 DateHandler dm(m_env, m_conn);
0077 stmt->setSQL(sql);
0078 stmt->setDate(1, dm.tmToDate(m_iov_start));
0079 stmt->setDate(2, dm.tmToDate(m_iov_stop));
0080 stmt->setInt(3, m_vmin);
0081 stmt->setInt(4, m_vmax);
0082 return sql;
0083 }
0084
0085 std::string LMFIOV::setByIDSql(Statement *stmt, int id) {
0086 std::string sql =
0087 "SELECT IOV_START, IOV_STOP, VMIN, VMAX FROM "
0088 "CMS_ECAL_LASER_COND.LMF_IOV "
0089 "WHERE IOV_ID = :1";
0090 stmt->setSQL(sql);
0091 stmt->setInt(1, id);
0092 return sql;
0093 }
0094
0095 void LMFIOV::getParameters(ResultSet *rset) {
0096 Date d = rset->getDate(1);
0097 DateHandler dh(m_env, m_conn);
0098 m_iov_start = dh.dateToTm(d);
0099 d = rset->getDate(2);
0100 m_iov_stop = dh.dateToTm(d);
0101 m_vmin = rset->getInt(3);
0102 m_vmax = rset->getInt(4);
0103 }
0104
0105 LMFUnique *LMFIOV::createObject() const {
0106 LMFIOV *t = new LMFIOV;
0107 t->setConnection(m_env, m_conn);
0108 return t;
0109 }
0110
0111 void LMFIOV::dump() const {
0112 cout << "################# LMFIOV ######################" << endl;
0113 cout << "id : " << m_ID << endl;
0114 cout << "Start: " << m_iov_start.str() << endl;
0115 cout << "Stop : " << m_iov_stop.str() << endl;
0116 cout << "Vers.: " << m_vmin << " - " << m_vmax << endl;
0117 cout << "################# LMFIOV ######################" << endl;
0118 }
0119
0120 std::string LMFIOV::writeDBSql(Statement *stmt) {
0121
0122 std::string seqName = sequencePostfix(m_iov_start);
0123 std::string sql =
0124 "INSERT INTO LMF_IOV (IOV_ID, IOV_START, IOV_STOP, "
0125 "VMIN, VMAX) VALUES "
0126 "(lmf_iov_" +
0127 seqName + "_sq.NextVal, :1, :2, :3, :4)";
0128 stmt->setSQL(sql);
0129 DateHandler dm(m_env, m_conn);
0130 stmt->setDate(1, dm.tmToDate(m_iov_start));
0131 stmt->setDate(2, dm.tmToDate(m_iov_stop));
0132 stmt->setInt(3, m_vmin);
0133 stmt->setInt(4, m_vmax);
0134 if (m_debug) {
0135 dump();
0136 }
0137 return sql;
0138 }