Go to the documentation of this file.00001 #include "OnlineDB/EcalCondDB/interface/LMFIOV.h"
00002
00003 using namespace std;
00004 using namespace oracle::occi;
00005
00006 LMFIOV::LMFIOV()
00007 {
00008
00009 m_env = NULL;
00010 m_conn = NULL;
00011 m_className = "LMFIOV";
00012 m_ID = 0;
00013
00014 m_iov_start = Tm();
00015 m_iov_stop = Tm();
00016 m_vmin = 0;
00017 m_vmax = 0;
00018 }
00019
00020 LMFIOV::LMFIOV(EcalDBConnection *c)
00021 {
00022
00023 setConnection(c->getEnv(), c->getConn());
00024 m_className = "LMFIOV";
00025 m_ID = 0;
00026
00027 m_iov_start = Tm();
00028 m_iov_stop = Tm();
00029 m_vmin = 0;
00030 m_vmax = 0;
00031 }
00032
00033 LMFIOV::~LMFIOV()
00034 {
00035 }
00036
00037 LMFIOV& LMFIOV::setStart(const Tm &start) {
00038 m_iov_start = start;
00039 return *this;
00040 }
00041
00042 LMFIOV& LMFIOV::setStop(const Tm &stop) {
00043 m_iov_stop = stop;
00044 return *this;
00045 }
00046
00047 LMFIOV& LMFIOV::setIOV(const Tm &start, const Tm &stop) {
00048 setStart(start);
00049 return setStop(stop);
00050 }
00051
00052 LMFIOV& LMFIOV::setVmin(int vmin) {
00053 m_vmin = vmin;
00054 return *this;
00055 }
00056
00057 LMFIOV& LMFIOV::setVmax(int vmax) {
00058 m_vmax = vmax;
00059 return *this;
00060 }
00061
00062 LMFIOV& LMFIOV::setVersions(int vmin, int vmax) {
00063 setVmin(vmin);
00064 return setVmax(vmax);
00065 }
00066
00067 Tm LMFIOV::getStart() const {
00068 return m_iov_start;
00069 }
00070
00071 Tm LMFIOV::getStop() const {
00072 return m_iov_stop;
00073 }
00074
00075 int LMFIOV::getVmin() const {
00076 return m_vmin;
00077 }
00078
00079 int LMFIOV::getVmax() const {
00080 return m_vmax;
00081 }
00082
00083 std::string LMFIOV::fetchIdSql(Statement *stmt) {
00084 std::string sql = "SELECT IOV_ID FROM CMS_ECAL_LASER_COND.LMF_IOV "
00085 "WHERE IOV_START = :1 AND IOV_STOP = :2 AND "
00086 "VMIN = :3 AND VMIN = :4";
00087 DateHandler dm(m_env, m_conn);
00088 stmt->setSQL(sql);
00089 stmt->setDate(1, dm.tmToDate(m_iov_start));
00090 stmt->setDate(2, dm.tmToDate(m_iov_stop));
00091 stmt->setInt(3, m_vmin);
00092 stmt->setInt(4, m_vmax);
00093 return sql;
00094 }
00095
00096 std::string LMFIOV::setByIDSql(Statement *stmt, int id)
00097 {
00098 std::string sql = "SELECT IOV_START, IOV_STOP, VMIN, VMAX FROM "
00099 "CMS_ECAL_LASER_COND.LMF_IOV "
00100 "WHERE IOV_ID = :1";
00101 stmt->setSQL(sql);
00102 stmt->setInt(1, id);
00103 return sql;
00104 }
00105
00106 void LMFIOV::getParameters(ResultSet *rset) {
00107 Date d = rset->getDate(1);
00108 DateHandler dh(m_env, m_conn);
00109 m_iov_start = dh.dateToTm(d);
00110 d = rset->getDate(2);
00111 m_iov_stop = dh.dateToTm(d);
00112 m_vmin = rset->getInt(3);
00113 m_vmax = rset->getInt(4);
00114 }
00115
00116 LMFUnique * LMFIOV::createObject() const {
00117 LMFIOV *t = new LMFIOV;
00118 t->setConnection(m_env, m_conn);
00119 return t;
00120 }
00121
00122 void LMFIOV::dump() const {
00123 cout << "################# LMFIOV ######################" << endl;
00124 cout << "id : " << m_ID << endl;
00125 cout << "Start: " << m_iov_start.str() << endl;
00126 cout << "Stop : " << m_iov_stop.str() << endl;
00127 cout << "Vers.: " << m_vmin << " - " << m_vmax << endl;
00128 cout << "################# LMFIOV ######################" << endl;
00129 }
00130
00131 std::string LMFIOV::writeDBSql(Statement *stmt)
00132 {
00133
00134 std::string seqName = sequencePostfix(m_iov_start);
00135 std::string sql = "INSERT INTO LMF_IOV (IOV_ID, IOV_START, IOV_STOP, "
00136 "VMIN, VMAX) VALUES "
00137 "(lmf_iov_" + seqName + "_sq.NextVal, :1, :2, :3, :4)";
00138 stmt->setSQL(sql);
00139 DateHandler dm(m_env, m_conn);
00140 stmt->setDate(1, dm.tmToDate(m_iov_start));
00141 stmt->setDate(2, dm.tmToDate(m_iov_stop));
00142 stmt->setInt(3, m_vmin);
00143 stmt->setInt(4, m_vmax);
00144 if (m_debug) {
00145 dump();
00146 }
00147 return sql;
00148 }