25 if (tag != m_runTag) {
31 if (tag != m_monrunTag) {
48 return m_vec_monruniov;
57 this->checkConnection();
60 m_runTag.setConnection(m_env, m_conn);
61 int tagID = m_runTag.fetchID();
62 cout <<
"tag id="<< tagID << endl;
66 m_monrunTag.setConnection(m_env, m_conn);
67 int montagID = m_monrunTag.fetchID();
68 cout <<
"mon tag id="<< montagID << endl;
74 Statement* stmt0 = m_conn->createStatement();
75 stmt0->setSQL(
"SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov " 76 "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 " );
77 stmt0->setInt(1, tagID);
78 stmt0->setInt(2, montagID);
80 ResultSet* rset0 = stmt0->executeQuery();
82 nruns = rset0->getInt(1);
84 m_conn->terminateStatement(stmt0);
86 cout <<
"nruns="<< nruns << endl;
88 m_vec_monruniov.reserve(nruns);
90 Statement* stmt = m_conn->createStatement();
91 stmt->setSQL(
"SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, mon_run_iov " 92 "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id order by run_iov.run_num, mon_run_iov.subrun_num ASC " );
93 stmt->setInt(1, tagID);
101 ResultSet* rset = stmt->executeQuery();
105 int runNum = rset->getInt(1);
106 Date startDate = rset->getDate(2);
107 Date endDate = rset->getDate(3);
109 int lid=rset->getInt(5);
110 int subrun=rset->getInt(6);
111 Date monstartDate = rset->getDate(7);
112 Date monendDate = rset->getDate(8);
113 int liov_id=rset->getInt(9);
115 runStart = dh.
dateToTm( startDate );
117 lrunStart = dh.
dateToTm( monstartDate );
118 lrunEnd = dh.
dateToTm( monendDate );
135 m_vec_monruniov.push_back(lr);
141 m_conn->terminateStatement(stmt);
142 }
catch (SQLException &
e) {
143 throw(std::runtime_error(
std::string(
"RunIOV::fetchID: ")+e.getMessage()));
154 this->checkConnection();
157 m_runTag.setConnection(m_env, m_conn);
158 int tagID = m_runTag.fetchID();
159 cout <<
"tag id="<< tagID << endl;
163 m_monrunTag.setConnection(m_env, m_conn);
164 int montagID = m_monrunTag.fetchID();
165 cout <<
"mon tag id="<< montagID << endl;
170 int my_min_run=min_run-1;
171 int my_max_run=max_run+1;
173 Statement* stmt0 = m_conn->createStatement();
174 stmt0->setSQL(
"SELECT count(mon_run_iov.iov_id) FROM mon_run_iov, run_iov " 175 "WHERE mon_run_iov.run_iov_id= run_iov.iov_id " 176 "and run_iov.tag_id = :tag_id and mon_run_iov.tag_id=:montag_id " 177 " and run_iov.run_num> :min_run and run_iov.run_num< :max_run " 179 stmt0->setInt(1, tagID);
180 stmt0->setInt(2, montagID);
181 stmt0->setInt(3, my_min_run);
182 stmt0->setInt(4, my_max_run);
184 ResultSet* rset0 = stmt0->executeQuery();
186 nruns = rset0->getInt(1);
188 m_conn->terminateStatement(stmt0);
190 cout <<
"nruns="<< nruns << endl;
192 m_vec_monruniov.reserve(nruns);
194 Statement* stmt = m_conn->createStatement();
195 stmt->setSQL(
"SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id FROM run_iov, mon_run_iov " 196 "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id " 197 " and mon_run_iov.tag_id=:montag_id " 198 " and run_iov.run_num> :min_run and run_iov.run_num< :max_run " 199 " order by run_iov.run_num, mon_run_iov.subrun_num ASC " );
200 stmt->setInt(1, tagID);
201 stmt->setInt(2, montagID);
202 stmt->setInt(3, my_min_run);
203 stmt->setInt(4, my_max_run);
211 ResultSet* rset = stmt->executeQuery();
215 int runNum = rset->getInt(1);
216 Date startDate = rset->getDate(2);
217 Date endDate = rset->getDate(3);
219 int lid=rset->getInt(5);
220 int subrun=rset->getInt(6);
221 Date monstartDate = rset->getDate(7);
222 Date monendDate = rset->getDate(8);
223 int liov_id=rset->getInt(9);
225 runStart = dh.
dateToTm( startDate );
227 lrunStart = dh.
dateToTm( monstartDate );
228 lrunEnd = dh.
dateToTm( monendDate );
245 m_vec_monruniov.push_back(lr);
251 m_conn->terminateStatement(stmt);
252 }
catch (SQLException &
e) {
253 throw(std::runtime_error(
std::string(
"RunIOV::fetchID: ")+e.getMessage()));
265 this->checkConnection();
268 m_runTag.setConnection(m_env, m_conn);
269 int tagID = m_runTag.fetchID();
270 cout <<
"tag id="<< tagID << endl;
274 m_monrunTag.setConnection(m_env, m_conn);
275 int montagID = m_monrunTag.fetchID();
276 cout <<
"mon tag id="<< montagID << endl;
281 int my_max_run=max_run+1;
285 m_vec_monruniov.reserve(nruns);
287 Statement* stmt = m_conn->createStatement();
288 stmt->setSQL(
"select run_num, run_start, run_end, tag_id, run_iov_id, subrun_num, subrun_start, subrun_end, mon_iov_id from (SELECT run_iov.run_num, run_iov.run_start, run_iov.run_end, mon_run_iov.tag_id, mon_run_iov.run_iov_id, mon_run_iov.subrun_num, mon_run_iov.subrun_start, mon_run_iov.subrun_end, mon_run_iov.iov_id as mon_iov_id FROM run_iov, mon_run_iov " 289 "WHERE mon_run_iov.run_iov_id=run_iov.iov_id and run_iov.tag_id = :tag_id " 290 " and mon_run_iov.tag_id=:montag_id " 291 " and run_iov.run_num< :max_run " 292 " order by run_iov.run_num DESC ) where rownum< :n_runs order by run_num DESC " );
293 stmt->setInt(1, tagID);
294 stmt->setInt(2, montagID);
295 stmt->setInt(3, my_max_run);
296 stmt->setInt(4, n_runs);
304 ResultSet* rset = stmt->executeQuery();
308 int runNum = rset->getInt(1);
309 Date startDate = rset->getDate(2);
310 Date endDate = rset->getDate(3);
312 int lid=rset->getInt(5);
313 int subrun=rset->getInt(6);
314 Date monstartDate = rset->getDate(7);
315 Date monendDate = rset->getDate(8);
316 int liov_id=rset->getInt(9);
318 runStart = dh.
dateToTm( startDate );
320 lrunStart = dh.
dateToTm( monstartDate );
321 lrunEnd = dh.
dateToTm( monendDate );
338 m_vec_monruniov.push_back(lr);
344 m_conn->terminateStatement(stmt);
345 }
catch (SQLException &
e) {
346 throw(std::runtime_error(
std::string(
"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