CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LMFIOV.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace oracle::occi;
5 
7 {
8  //standard
9  m_env = NULL;
10  m_conn = NULL;
11  m_className = "LMFIOV";
12  m_ID = 0;
13  // custom
14  m_iov_start = Tm();
15  m_iov_stop = Tm();
16  m_vmin = 0;
17  m_vmax = 0;
18 }
19 
21 {
22  //standard
23  setConnection(c->getEnv(), c->getConn());
24  m_className = "LMFIOV";
25  m_ID = 0;
26  // custom
27  m_iov_start = Tm();
28  m_iov_stop = Tm();
29  m_vmin = 0;
30  m_vmax = 0;
31 }
32 
34 {
35 }
36 
37 LMFIOV& LMFIOV::setStart(const Tm &start) {
38  m_iov_start = start;
39  return *this;
40 }
41 
42 LMFIOV& LMFIOV::setStop(const Tm &stop) {
43  m_iov_stop = stop;
44  return *this;
45 }
46 
47 LMFIOV& LMFIOV::setIOV(const Tm &start, const Tm &stop) {
48  setStart(start);
49  return setStop(stop);
50 }
51 
52 LMFIOV& LMFIOV::setVmin(int vmin) {
53  m_vmin = vmin;
54  return *this;
55 }
56 
57 LMFIOV& LMFIOV::setVmax(int vmax) {
58  m_vmax = vmax;
59  return *this;
60 }
61 
62 LMFIOV& LMFIOV::setVersions(int vmin, int vmax) {
63  setVmin(vmin);
64  return setVmax(vmax);
65 }
66 
68  return m_iov_start;
69 }
70 
72  return m_iov_stop;
73 }
74 
75 int LMFIOV::getVmin() const {
76  return m_vmin;
77 }
78 
79 int LMFIOV::getVmax() const {
80  return m_vmax;
81 }
82 
83 std::string LMFIOV::fetchIdSql(Statement *stmt) {
84  std::string sql = "SELECT IOV_ID FROM LMF_IOV "
85  "WHERE IOV_START = :1 AND IOV_STOP = :2 AND "
86  "VMIN = :3 AND VMIN = :4";
87  DateHandler dm(m_env, m_conn);
88  stmt->setSQL(sql);
89  stmt->setDate(1, dm.tmToDate(m_iov_start));
90  stmt->setDate(2, dm.tmToDate(m_iov_stop));
91  stmt->setInt(3, m_vmin);
92  stmt->setInt(4, m_vmax);
93  return sql;
94 }
95 
96 std::string LMFIOV::setByIDSql(Statement *stmt, int id)
97 {
98  std::string sql = "SELECT IOV_START, IOV_STOP, VMIN, VMAX FROM LMF_IOV "
99  "WHERE IOV_ID = :1";
100  stmt->setSQL(sql);
101  stmt->setInt(1, id);
102  return sql;
103 }
104 
106  Date d = rset->getDate(1);
107  DateHandler dh(m_env, m_conn);
108  m_iov_start = dh.dateToTm(d);
109  d = rset->getDate(2);
110  m_iov_stop = dh.dateToTm(d);
111  m_vmin = rset->getInt(3);
112  m_vmax = rset->getInt(4);
113 }
114 
116  LMFIOV *t = new LMFIOV;
117  t->setConnection(m_env, m_conn);
118  return t;
119 }
120 
121 void LMFIOV::dump() const {
122  cout << "################# LMFIOV ######################" << endl;
123  cout << "id : " << m_ID << endl;
124  cout << "Start: " << m_iov_start.str() << endl;
125  cout << "Stop : " << m_iov_stop.str() << endl;
126  cout << "Vers.: " << m_vmin << " - " << m_vmax << endl;
127  cout << "################# LMFIOV ######################" << endl;
128 }
129 
130 std::string LMFIOV::writeDBSql(Statement *stmt)
131 {
132  // check that everything has been setup
133  std::string seqName = sequencePostfix(m_iov_start);
134  std::string sql = "INSERT INTO LMF_IOV (IOV_ID, IOV_START, IOV_STOP, "
135  "VMIN, VMAX) VALUES "
136  "(lmf_iov_" + seqName + "_sq.NextVal, :1, :2, :3, :4)";
137  stmt->setSQL(sql);
138  DateHandler dm(m_env, m_conn);
139  stmt->setDate(1, dm.tmToDate(m_iov_start));
140  stmt->setDate(2, dm.tmToDate(m_iov_stop));
141  stmt->setInt(3, m_vmin);
142  stmt->setInt(4, m_vmax);
143  if (m_debug) {
144  dump();
145  }
146  return sql;
147 }
void getParameters(ResultSet *rset)
Definition: LMFIOV.cc:105
LMFIOV & setVmin(int vmin)
Definition: LMFIOV.cc:52
LMFIOV & setStop(const Tm &stop)
Definition: LMFIOV.cc:42
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:19
#define NULL
Definition: scimark2.h:8
LMFIOV & setVersions(int vmin, int vmax)
Definition: LMFIOV.cc:62
oracle::occi::Environment * getEnv() const
oracle::occi::Connection * getConn() const
LMFIOV & setVmax(int vmax)
Definition: LMFIOV.cc:57
int getVmin() const
Definition: LMFIOV.cc:75
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
LMFIOV & setStart(const Tm &start)
Definition: LMFIOV.cc:37
std::string setByIDSql(Statement *stmt, int id)
Definition: LMFIOV.cc:96
oracle::occi::Date tmToDate(const Tm &inTm) const
Definition: DateHandler.cc:20
Definition: LMFIOV.h:17
int getVmax() const
Definition: LMFIOV.cc:79
LMFIOV & setIOV(const Tm &start, const Tm &stop)
Definition: LMFIOV.cc:47
Tm getStop() const
Definition: LMFIOV.cc:71
~LMFIOV()
Definition: LMFIOV.cc:33
Tm getStart() const
Definition: LMFIOV.cc:67
LMFUnique * createObject() const
Definition: LMFIOV.cc:115
tuple cout
Definition: gather_cfg.py:41
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
std::string writeDBSql(Statement *stmt)
Definition: LMFIOV.cc:130
void dump() const
Definition: LMFIOV.cc:121
std::string fetchIdSql(Statement *stmt)
Definition: LMFIOV.cc:83
LMFIOV()
Definition: LMFIOV.cc:6
Tm dateToTm(oracle::occi::Date &date) const
Definition: DateHandler.cc:31
Definition: Tm.h:14