19 if (tag != m_runTag) {
24 if (tag != m_monrunTag) {
35 this->checkConnection();
38 m_runTag.setConnection(m_env, m_conn);
39 int tagID = m_runTag.fetchID();
40 cout <<
"tag id=" << tagID << endl;
44 m_monrunTag.setConnection(m_env, m_conn);
45 int montagID = m_monrunTag.fetchID();
46 cout <<
"mon tag id=" << montagID << endl;
52 Statement* stmt0 = m_conn->createStatement();
54 "SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov " 55 "WHERE mon_run_iov.run_iov_id= run_iov.iov_id and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id ");
56 stmt0->setInt(1, tagID);
57 stmt0->setInt(2, montagID);
59 ResultSet* rset0 = stmt0->executeQuery();
61 nruns = rset0->getInt(1);
63 m_conn->terminateStatement(stmt0);
65 cout <<
"nruns=" << nruns << endl;
67 m_vec_monruniov.reserve(nruns);
69 Statement* stmt = m_conn->createStatement();
71 "SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, " 72 "mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, " 74 "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id order by run_iov.run_num, " 75 "mon_run_iov.subrun_num ASC ");
76 stmt->setInt(1, tagID);
84 ResultSet* rset = stmt->executeQuery();
88 int runNum = rset->getInt(1);
89 Date startDate = rset->getDate(2);
90 Date endDate = rset->getDate(3);
92 int lid = rset->getInt(5);
93 int subrun = rset->getInt(6);
94 Date monstartDate = rset->getDate(7);
95 Date monendDate = rset->getDate(8);
96 int liov_id = rset->getInt(9);
100 lrunStart = dh.
dateToTm(monstartDate);
118 m_vec_monruniov.push_back(lr);
123 m_conn->terminateStatement(stmt);
124 }
catch (SQLException&
e) {
125 throw(std::runtime_error(
"RunIOV::fetchID: " + e.getMessage()));
130 this->checkConnection();
133 m_runTag.setConnection(m_env, m_conn);
134 int tagID = m_runTag.fetchID();
135 cout <<
"tag id=" << tagID << endl;
139 m_monrunTag.setConnection(m_env, m_conn);
140 int montagID = m_monrunTag.fetchID();
141 cout <<
"mon tag id=" << montagID << endl;
146 int my_min_run = min_run - 1;
147 int my_max_run = max_run + 1;
149 Statement* stmt0 = m_conn->createStatement();
151 "SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov " 152 "WHERE mon_run_iov.run_iov_id= run_iov.iov_id " 153 "and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id " 154 " and run_iov.run_num> :min_run and run_iov.run_num< :max_run ");
155 stmt0->setInt(1, tagID);
156 stmt0->setInt(2, montagID);
157 stmt0->setInt(3, my_min_run);
158 stmt0->setInt(4, my_max_run);
160 ResultSet* rset0 = stmt0->executeQuery();
162 nruns = rset0->getInt(1);
164 m_conn->terminateStatement(stmt0);
166 cout <<
"nruns=" << nruns << endl;
168 m_vec_monruniov.reserve(nruns);
170 Statement* stmt = m_conn->createStatement();
172 "SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, " 173 "mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, " 175 "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id " 176 " and mon_run_iov.tag_id=:montag_id " 177 " and run_iov.run_num> :min_run and run_iov.run_num< :max_run " 178 " order by run_iov.run_num, mon_run_iov.subrun_num ASC ");
179 stmt->setInt(1, tagID);
180 stmt->setInt(2, montagID);
181 stmt->setInt(3, my_min_run);
182 stmt->setInt(4, my_max_run);
190 ResultSet* rset = stmt->executeQuery();
194 int runNum = rset->getInt(1);
195 Date startDate = rset->getDate(2);
196 Date endDate = rset->getDate(3);
198 int lid = rset->getInt(5);
199 int subrun = rset->getInt(6);
200 Date monstartDate = rset->getDate(7);
201 Date monendDate = rset->getDate(8);
202 int liov_id = rset->getInt(9);
206 lrunStart = dh.
dateToTm(monstartDate);
224 m_vec_monruniov.push_back(lr);
229 m_conn->terminateStatement(stmt);
230 }
catch (SQLException&
e) {
231 throw(std::runtime_error(
"RunIOV::fetchID: " + e.getMessage()));
238 this->checkConnection();
240 m_runTag.setConnection(m_env, m_conn);
241 int tagID = m_runTag.fetchID();
242 cout <<
"tag id=" << tagID << endl;
246 m_monrunTag.setConnection(m_env, m_conn);
247 int montagID = m_monrunTag.fetchID();
248 cout <<
"mon tag id=" << montagID << endl;
253 int my_max_run = max_run + 1;
256 m_vec_monruniov.reserve(nruns);
258 Statement* stmt = m_conn->createStatement();
260 "select run_num, run_start, run_end, tag_id, run_iov_id, subrun_num, subrun_start, subrun_end, mon_iov_id from " 261 "(SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, " 262 "mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id as mon_iov_id " 263 "FROM run_iov, mon_run_iov " 264 "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id " 265 " and mon_run_iov.tag_id=:montag_id " 266 " and run_iov.run_num< :max_run " 267 " order by run_iov.run_num DESC ) where rownum< :n_runs order by run_num DESC ");
268 stmt->setInt(1, tagID);
269 stmt->setInt(2, montagID);
270 stmt->setInt(3, my_max_run);
271 stmt->setInt(4, n_runs);
279 ResultSet* rset = stmt->executeQuery();
283 int runNum = rset->getInt(1);
284 Date startDate = rset->getDate(2);
285 Date endDate = rset->getDate(3);
287 int lid = rset->getInt(5);
288 int subrun = rset->getInt(6);
289 Date monstartDate = rset->getDate(7);
290 Date monendDate = rset->getDate(8);
291 int liov_id = rset->getInt(9);
295 lrunStart = dh.
dateToTm(monstartDate);
313 m_vec_monruniov.push_back(lr);
318 m_conn->terminateStatement(stmt);
319 }
catch (SQLException&
e) {
320 throw(std::runtime_error(
"MonRunList::fetchLastNRuns: " + e.getMessage()));
void setRunStart(const Tm &start)
void setRunIOV(const RunIOV &iov)
void fetchLastNRuns(int max_run, int n_runs) noexcept(false)
void setRunTag(const RunTag &tag)
void setRunTag(const RunTag &tag)
void setRunNumber(run_t run)
void setSubRunEnd(const Tm &end)
void setSubRunNumber(subrun_t subrun)
MonRunTag getMonRunTag() const
void setSubRunStart(const Tm &start)
std::vector< MonRunIOV > getRuns()
void fetchRuns() noexcept(false)
void setMonRunTag(const MonRunTag &tag)
void setMonRunTag(const MonRunTag &tag)
void setRunEnd(const Tm &end)
Tm dateToTm(oracle::occi::Date &date) const