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 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 LMF_IOV "
00099 "WHERE IOV_ID = :1";
00100 stmt->setSQL(sql);
00101 stmt->setInt(1, id);
00102 return sql;
00103 }
00104
00105 void LMFIOV::getParameters(ResultSet *rset) {
00106 Date d = rset->getDate(1);
00107 DateHandler dh(m_env, m_conn);
00108 m_iov_start = dh.dateToTm(d);
00109 d = rset->getDate(2);
00110 m_iov_stop = dh.dateToTm(d);
00111 m_vmin = rset->getInt(3);
00112 m_vmax = rset->getInt(4);
00113 }
00114
00115 LMFUnique * LMFIOV::createObject() const {
00116 LMFIOV *t = new LMFIOV;
00117 t->setConnection(m_env, m_conn);
00118 return t;
00119 }
00120
00121 void LMFIOV::dump() const {
00122 cout << "################# LMFIOV ######################" << endl;
00123 cout << "id : " << m_ID << endl;
00124 cout << "Start: " << m_iov_start.str() << endl;
00125 cout << "Stop : " << m_iov_stop.str() << endl;
00126 cout << "Vers.: " << m_vmin << " - " << m_vmax << endl;
00127 cout << "################# LMFIOV ######################" << endl;
00128 }
00129
00130 std::string LMFIOV::writeDBSql(Statement *stmt)
00131 {
00132
00133 std::string seqName = sequencePostfix(m_iov_start);
00134 std::string sql = "INSERT INTO LMF_IOV (IOV_ID, IOV_START, IOV_STOP, "
00135 "VMIN, VMAX) VALUES "
00136 "(lmf_iov_" + seqName + "_sq.NextVal, :1, :2, :3, :4)";
00137 stmt->setSQL(sql);
00138 DateHandler dm(m_env, m_conn);
00139 stmt->setDate(1, dm.tmToDate(m_iov_start));
00140 stmt->setDate(2, dm.tmToDate(m_iov_stop));
00141 stmt->setInt(3, m_vmin);
00142 stmt->setInt(4, m_vmax);
00143 if (m_debug) {
00144 dump();
00145 }
00146 return sql;
00147 }