CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
RunIOV Class Reference

#include <RunIOV.h>

Inheritance diagram for RunIOV:
IIOV IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false) override
 
int fetchIDByRunAndTag () noexcept(false)
 
Tm getDBInsertionTime ()
 
int getID ()
 
Tm getRunEnd () const
 
run_t getRunNumber () const
 
Tm getRunStart () const
 
RunTag getRunTag () const
 
bool operator!= (const RunIOV &r) const
 
bool operator== (const RunIOV &r) const
 
 RunIOV ()
 
void setByID (int id) noexcept(false) override
 
void setDBInsertionTime (const Tm &dbtime)
 
void setID (int id)
 
void setRunEnd (const Tm &end)
 
void setRunNumber (run_t run)
 
void setRunStart (const Tm &start)
 
void setRunTag (const RunTag &tag)
 
 ~RunIOV () override
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Private Member Functions

void setByRecentData (std::string dataTable, RunTag *tag, run_t run=(unsigned int)-1) noexcept(false)
 
void setByRecentData (std::string dataTable, std::string location, run_t run) noexcept(false)
 
void setByRun (RunTag *tag, run_t run) noexcept(false)
 
void setByRun (std::string location, run_t run) noexcept(false)
 
void setByTime (std::string location, const Tm &t) noexcept(false)
 
int updateEndTimeDB () noexcept(false)
 
int updateStartTimeDB () noexcept(false)
 
int writeDB () noexcept(false)
 

Private Attributes

Tm m_dbtime
 
Tm m_runEnd
 
run_t m_runNum
 
Tm m_runStart
 
RunTag m_runTag
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 13 of file RunIOV.h.

Constructor & Destructor Documentation

RunIOV::RunIOV ( )

Definition at line 12 of file RunIOV.cc.

12  {
13  m_conn = nullptr;
14  m_ID = 0;
15  m_runNum = 0;
16  m_runStart = Tm();
17  m_runEnd = Tm();
18 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Tm m_runStart
Definition: RunIOV.h:51
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
Definition: Tm.h:13
RunIOV::~RunIOV ( )
override

Definition at line 20 of file RunIOV.cc.

20 {}

Member Function Documentation

int RunIOV::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 60 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

Referenced by getID().

60  {
61  // Return from memory if available
62  if (m_ID) {
63  return m_ID;
64  }
65 
66  this->checkConnection();
67 
69  int tagID = m_runTag.fetchID();
70  if (!tagID) {
71  return 0;
72  }
73 
75 
76  if (m_runEnd.isNull()) {
77  m_runEnd = dh.getPlusInfTm();
78  }
79 
80  try {
81  Statement* stmt = m_conn->createStatement();
82  stmt->setSQL(
83  "SELECT iov_id FROM run_iov "
84  "WHERE tag_id = :tag_id AND "
85  "run_num = :run_num AND "
86  "run_start = :run_start ");
87  stmt->setInt(1, tagID);
88  stmt->setInt(2, m_runNum);
89  stmt->setDate(3, dh.tmToDate(m_runStart));
90 
91  ResultSet* rset = stmt->executeQuery();
92 
93  if (rset->next()) {
94  m_ID = rset->getInt(1);
95  } else {
96  m_ID = 0;
97  }
98  m_conn->terminateStatement(stmt);
99  } catch (SQLException& e) {
100  throw(std::runtime_error("RunIOV::fetchID: " + e.getMessage()));
101  }
102 
103  return m_ID;
104 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Tm m_runStart
Definition: RunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
int fetchID() noexcept(false) override
Definition: RunTag.cc:49
int isNull() const
Definition: Tm.cc:46
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
int RunIOV::fetchIDByRunAndTag ( )
noexcept

Definition at line 229 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, and DateHandler::getPlusInfTm().

Referenced by getID().

229  {
230  // Return from memory if available
231  if (m_ID) {
232  return m_ID;
233  }
234 
235  this->checkConnection();
236 
238  int tagID = m_runTag.fetchID();
239  if (!tagID) {
240  return 0;
241  }
242 
244 
245  if (m_runEnd.isNull()) {
246  m_runEnd = dh.getPlusInfTm();
247  }
248 
249  try {
250  Statement* stmt = m_conn->createStatement();
251  stmt->setSQL(
252  "SELECT iov_id FROM run_iov "
253  "WHERE tag_id = :tag_id AND "
254  "run_num = :run_num ");
255  stmt->setInt(1, tagID);
256  stmt->setInt(2, m_runNum);
257 
258  ResultSet* rset = stmt->executeQuery();
259 
260  if (rset->next()) {
261  m_ID = rset->getInt(1);
262  } else {
263  m_ID = 0;
264  }
265  m_conn->terminateStatement(stmt);
266  } catch (SQLException& e) {
267  throw(std::runtime_error("RunIOV::fetchID: " + e.getMessage()));
268  }
269 
270  return m_ID;
271 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
int fetchID() noexcept(false) override
Definition: RunTag.cc:49
int isNull() const
Definition: Tm.cc:46
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
Tm RunIOV::getDBInsertionTime ( )
inline

Definition at line 32 of file RunIOV.h.

References m_dbtime.

32 { return m_dbtime; }
Tm m_dbtime
Definition: RunIOV.h:54
int RunIOV::getID ( )
inline
Tm RunIOV::getRunEnd ( ) const

Definition at line 49 of file RunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), and EcalTPGDBApp::printIOV().

49 { return m_runEnd; }
Tm m_runEnd
Definition: RunIOV.h:52
run_t RunIOV::getRunNumber ( ) const
Tm RunIOV::getRunStart ( ) const

Definition at line 40 of file RunIOV.cc.

Referenced by EcalCondDBWriter::dqmEndJob(), and EcalTPGDBApp::printIOV().

40 { return m_runStart; }
Tm m_runStart
Definition: RunIOV.h:51
RunTag RunIOV::getRunTag ( ) const
bool RunIOV::operator!= ( const RunIOV r) const
inline

Definition at line 46 of file RunIOV.h.

References alignCSCRings::r.

46 { return !(*this == r); }
bool RunIOV::operator== ( const RunIOV r) const
inline

Definition at line 42 of file RunIOV.h.

References m_runEnd, m_runNum, m_runStart, and m_runTag.

42  {
43  return (m_runNum == r.m_runNum && m_runStart == r.m_runStart && m_runEnd == r.m_runEnd && m_runTag == r.m_runTag);
44  }
Tm m_runStart
Definition: RunIOV.h:51
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
RunTag m_runTag
Definition: RunIOV.h:53
void RunIOV::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 106 of file RunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, and triggerObjects_cff::id.

Referenced by LMFCorrCoefDat::fetchLastInsertedRun(), LMFSeqDat::fetchParentIDs(), getID(), and LMFSeqDat::getParameters().

106  {
107  this->checkConnection();
108 
110 
111  try {
112  Statement* stmt = m_conn->createStatement();
113 
114  stmt->setSQL("SELECT tag_id, run_num, run_start, run_end FROM run_iov WHERE iov_id = :1");
115  stmt->setInt(1, id);
116 
117  ResultSet* rset = stmt->executeQuery();
118  if (rset->next()) {
119  int tagID = rset->getInt(1);
120  m_runNum = rset->getInt(2);
121  Date startDate = rset->getDate(3);
122  Date endDate = rset->getDate(4);
123 
124  m_runStart = dh.dateToTm(startDate);
125  m_runEnd = dh.dateToTm(endDate);
126 
128  m_runTag.setByID(tagID);
129  m_ID = id;
130  } else {
131  throw(std::runtime_error("RunIOV::setByID: Given tag_id is not in the database"));
132  }
133 
134  m_conn->terminateStatement(stmt);
135  } catch (SQLException& e) {
136  throw(std::runtime_error("RunIOV::setByID: " + e.getMessage()));
137  }
138 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setByID(int id) noexcept(false) override
Definition: RunTag.cc:88
Tm m_runStart
Definition: RunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
void RunIOV::setByRecentData ( std::string  dataTable,
RunTag tag,
run_t  run = (unsigned int)-1 
)
privatenoexcept

Definition at line 429 of file RunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, writedatasetfile::run, and GlobalPosition_Frontier_DevDB_cff::tag.

429  {
430  this->checkConnection();
431 
432  tag->setConnection(m_env, m_conn);
433  int tagID = tag->fetchID();
434  if (!tagID) {
435  throw(std::runtime_error("RunIOV::setByRecentData: Given tag is not in the database"));
436  }
437 
439 
440  try {
441  Statement* stmt = m_conn->createStatement();
442 
443  stmt->setSQL(
444  "SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end "
445  "FROM run_iov riov "
446  "JOIN " +
447  dataTable +
448  " dat on dat.iov_id = riov.iov_id "
449  "WHERE tag_id = :1 AND riov.run_num <= :run ORDER BY riov.run_num DESC) WHERE rownum = 1");
450 
451  stmt->setInt(1, tagID);
452  stmt->setInt(2, run);
453 
454  ResultSet* rset = stmt->executeQuery();
455  if (rset->next()) {
456  m_runTag = *tag;
457 
458  m_ID = rset->getInt(1);
459  m_runNum = rset->getInt(2);
460  Date startDate = rset->getDate(3);
461  Date endDate = rset->getDate(4);
462 
463  m_runStart = dh.dateToTm(startDate);
464  m_runEnd = dh.dateToTm(endDate);
465  } else {
466  throw(std::runtime_error("RunIOV::setByRecentData: No data exists for given tag and run"));
467  }
468 
469  m_conn->terminateStatement(stmt);
470  } catch (SQLException& e) {
471  throw(std::runtime_error("RunIOV::setByRecentData: " + e.getMessage()));
472  }
473 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Tm m_runStart
Definition: RunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
int fetchID() noexcept(false) override
Definition: RunTag.cc:49
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
void RunIOV::setByRecentData ( std::string  dataTable,
std::string  location,
run_t  run 
)
privatenoexcept

Definition at line 475 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, EcalCondDBWriter_cfi::location, and writedatasetfile::run.

475  {
476  this->checkConnection();
477 
479 
480  try {
481  Statement* stmt = m_conn->createStatement();
482 
483  stmt->setSQL(
484  "SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end "
485  "FROM run_iov riov "
486  "JOIN " +
487  dataTable +
488  " dat on dat.iov_id = riov.iov_id "
489  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
490  "JOIN location_def loc ON rtag.location_id = loc.def_id "
491  "WHERE loc.location = :1 AND riov.run_num <= :2 ORDER BY riov.run_num DESC ) WHERE rownum = 1");
492 
493  stmt->setString(1, location);
494  stmt->setInt(2, run);
495 
496  ResultSet* rset = stmt->executeQuery();
497 
498  if (rset->next()) {
499  int id = rset->getInt(1);
500  this->setByID(id);
501  } else {
502  throw(std::runtime_error("RunIOV::setByRecentData(datatable, loc, run): Given run is not in the database"));
503  }
504 
505  m_conn->terminateStatement(stmt);
506  } catch (SQLException& e) {
507  throw(std::runtime_error("RunIOV::setByRecentData: " + e.getMessage()));
508  }
509 }
void setByID(int id) noexcept(false) override
Definition: RunIOV.cc:106
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
dh
Definition: cuy.py:355
void RunIOV::setByRun ( RunTag tag,
run_t  run 
)
privatenoexcept

Definition at line 314 of file RunIOV.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, writedatasetfile::run, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by EcalCondDBInterface::fetchRunIOV().

314  {
315  this->checkConnection();
316 
317  tag->setConnection(m_env, m_conn);
318  int tagID = tag->fetchID();
319  if (!tagID) {
320  throw(std::runtime_error("RunIOV::setByRun: Given tag is not in the database"));
321  }
322 
324 
325  try {
326  Statement* stmt = m_conn->createStatement();
327 
328  stmt->setSQL("SELECT iov_id, run_start, run_end FROM run_iov WHERE tag_id = :1 AND run_num = :2");
329  stmt->setInt(1, tagID);
330  stmt->setInt(2, run);
331 
332  ResultSet* rset = stmt->executeQuery();
333  if (rset->next()) {
334  m_runTag = *tag;
335  m_runNum = run;
336 
337  m_ID = rset->getInt(1);
338  Date startDate = rset->getDate(2);
339  Date endDate = rset->getDate(3);
340 
341  m_runStart = dh.dateToTm(startDate);
342  m_runEnd = dh.dateToTm(endDate);
343  } else {
344  throw(std::runtime_error("RunIOV::setByRun: Given run is not in the database"));
345  }
346 
347  m_conn->terminateStatement(stmt);
348  } catch (SQLException& e) {
349  throw(std::runtime_error("RunIOV::setByRun: " + e.getMessage()));
350  }
351 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Tm m_runStart
Definition: RunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
int fetchID() noexcept(false) override
Definition: RunTag.cc:49
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
void RunIOV::setByRun ( std::string  location,
run_t  run 
)
privatenoexcept

Definition at line 393 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, EcalCondDBWriter_cfi::location, and writedatasetfile::run.

393  {
394  this->checkConnection();
395 
397 
398  try {
399  Statement* stmt = m_conn->createStatement();
400 
401  stmt->setSQL(
402  "SELECT iov_id FROM run_iov riov "
403  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
404  "JOIN location_def loc ON rtag.location_id = loc.def_id "
405  "WHERE loc.location = :1 AND riov.run_num = :2 "
406  "AND rtag.gen_tag != 'INVALID'");
407  stmt->setString(1, location);
408  stmt->setInt(2, run);
409 
410  ResultSet* rset = stmt->executeQuery();
411  if (rset->next()) {
412  int id = rset->getInt(1);
413  this->setByID(id);
414  } else {
415  throw(std::runtime_error("RunIOV::setByRun(loc, run): Given run is not in the database"));
416  }
417 
418  // Check for uniqueness of run
419  if (rset->next()) {
420  throw(std::runtime_error("RunIOV::setByRun(loc, run): Run is nonunique for given location."));
421  }
422 
423  m_conn->terminateStatement(stmt);
424  } catch (SQLException& e) {
425  throw(std::runtime_error("RunIOV::setByRun(loc, run): " + e.getMessage()));
426  }
427 }
void setByID(int id) noexcept(false) override
Definition: RunIOV.cc:106
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
dh
Definition: cuy.py:355
void RunIOV::setByTime ( std::string  location,
const Tm t 
)
privatenoexcept

Definition at line 353 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, EcalCondDBWriter_cfi::location, and OrderedSet::t.

Referenced by EcalCondDBInterface::fetchRunIOV().

353  {
354  this->checkConnection();
355 
357 
358  try {
359  Statement* stmt = m_conn->createStatement();
360 
361  stmt->setSQL(
362  "SELECT iov_id FROM (SELECT iov_id FROM run_iov riov "
363  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
364  "JOIN location_def loc ON rtag.location_id = loc.def_id "
365  "WHERE loc.location = :1 AND "
366  "run_start <= to_date(:2, 'YYYY-MM-DD HH24:MI:SS') AND "
367  "run_end >= to_date(:3, 'YYYY-MM-DD HH24:MI:SS') "
368  "AND rtag.gen_tag != 'INVALID' ORDER BY iov_id DESC) "
369  "where ROWNUM <=1");
370  stmt->setString(1, location);
371  stmt->setString(2, t.str());
372  stmt->setString(3, t.str());
373 
374  ResultSet* rset = stmt->executeQuery();
375  if (rset->next()) {
376  int id = rset->getInt(1);
377  this->setByID(id);
378  } else {
379  throw(std::runtime_error("RunIOV::setByTime(loc, run): Given run is not in the database"));
380  }
381 
382  // Check for uniqueness of run
383  if (rset->next()) {
384  throw(std::runtime_error("RunIOV::setByTime(loc, run): Run is nonunique for given location."));
385  }
386 
387  m_conn->terminateStatement(stmt);
388  } catch (SQLException& e) {
389  throw(std::runtime_error("RunIOV::setByTime(loc, run): " + e.getMessage()));
390  }
391 }
void setByID(int id) noexcept(false) override
Definition: RunIOV.cc:106
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string str() const
Definition: Tm.cc:66
dh
Definition: cuy.py:355
void RunIOV::setDBInsertionTime ( const Tm dbtime)
inline

Definition at line 31 of file RunIOV.h.

References m_dbtime.

Referenced by RunList::fetchGlobalRunsByLocation(), RunList::fetchLastNRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().

31 { m_dbtime = dbtime; }
Tm m_dbtime
Definition: RunIOV.h:54
void RunIOV::setID ( int  id)
void RunIOV::setRunEnd ( const Tm end)

Definition at line 42 of file RunIOV.cc.

References end.

Referenced by RunList::fetchGlobalRunsByLocation(), MonRunList::fetchLastNRuns(), RunList::fetchLastNRuns(), MonRunList::fetchRuns(), RunList::fetchRuns(), and RunList::fetchRunsByLocation().

42  {
43  if (end != m_runEnd) {
44  m_ID = 0;
45  m_runEnd = end;
46  }
47 }
#define end
Definition: vmac.h:39
Tm m_runEnd
Definition: RunIOV.h:52
void RunIOV::setRunNumber ( run_t  run)
void RunIOV::setRunStart ( const Tm start)
void RunIOV::setRunTag ( const RunTag tag)
int RunIOV::updateEndTimeDB ( )
privatenoexcept

Definition at line 188 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DateHandler::getPlusInfTm(), DateHandler::tmToDate(), and GlobalTrackerMuonAlignment_cfi::writeDB.

188  {
189  this->checkConnection();
190 
191  // Check if this IOV has already been written
192  if (!this->fetchID()) {
193  this->writeDB();
194  }
195 
197  // int tagID = m_runTag.writeDB();
198 
199  // Validate the data, use infinity-till convention
201 
202  // we only update the run end here
203  if (m_runEnd.isNull()) {
204  m_runEnd = dh.getPlusInfTm();
205  }
206 
207  try {
208  Statement* stmt = m_conn->createStatement();
209 
210  stmt->setSQL("UPDATE run_iov set run_end=:1 where iov_id=:2 ");
211  stmt->setDate(1, dh.tmToDate(m_runEnd));
212  stmt->setInt(2, m_ID);
213 
214  stmt->executeUpdate();
215 
216  m_conn->terminateStatement(stmt);
217  } catch (SQLException& e) {
218  throw(std::runtime_error("RunIOV::writeDB: " + e.getMessage()));
219  }
220 
221  // Now get the ID
222  if (!this->fetchID()) {
223  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
224  }
225 
226  return m_ID;
227 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
int writeDB() noexcept(false)
Definition: RunIOV.cc:140
int isNull() const
Definition: Tm.cc:46
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
int RunIOV::updateStartTimeDB ( )
privatenoexcept

Definition at line 273 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DateHandler::getPlusInfTm(), DateHandler::tmToDate(), and GlobalTrackerMuonAlignment_cfi::writeDB.

273  {
274  this->checkConnection();
275 
276  // Check if this IOV has already been written
277  if (!this->fetchIDByRunAndTag()) {
278  this->writeDB();
279  }
280 
281  // m_runTag.setConnection(m_env, m_conn);
282  // int tagID = m_runTag.writeDB();
283 
284  // Validate the data, use infinity-till convention
286 
287  // we only update the run start here
288  if (m_runEnd.isNull()) {
289  m_runEnd = dh.getPlusInfTm();
290  }
291 
292  try {
293  Statement* stmt = m_conn->createStatement();
294 
295  stmt->setSQL("UPDATE run_iov set run_start=:1 where iov_id=:2 ");
296  stmt->setDate(1, dh.tmToDate(m_runStart));
297  stmt->setInt(2, m_ID);
298 
299  stmt->executeUpdate();
300 
301  m_conn->terminateStatement(stmt);
302  } catch (SQLException& e) {
303  throw(std::runtime_error("RunIOV::writeDB: " + e.getMessage()));
304  }
305 
306  // Now get the ID
307  if (!this->fetchID()) {
308  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
309  }
310 
311  return m_ID;
312 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int fetchIDByRunAndTag() noexcept(false)
Definition: RunIOV.cc:229
Tm m_runStart
Definition: RunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
int writeDB() noexcept(false)
Definition: RunIOV.cc:140
int isNull() const
Definition: Tm.cc:46
dh
Definition: cuy.py:355
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
int RunIOV::writeDB ( )
privatenoexcept

Definition at line 140 of file RunIOV.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

140  {
141  this->checkConnection();
142 
143  // Check if this IOV has already been written
144  if (this->fetchID()) {
145  return m_ID;
146  }
147 
149  int tagID = m_runTag.writeDB();
150 
151  // Validate the data, use infinity-till convention
153 
154  if (m_runStart.isNull()) {
155  throw(std::runtime_error("RunIOV::writeDB: Must setRunStart before writing"));
156  }
157 
158  if (m_runEnd.isNull()) {
159  m_runEnd = dh.getPlusInfTm();
160  }
161 
162  try {
163  Statement* stmt = m_conn->createStatement();
164 
165  stmt->setSQL(
166  "INSERT INTO run_iov (iov_id, tag_id, run_num, run_start, run_end) "
167  "VALUES (run_iov_sq.NextVal, :1, :2, :3, :4)");
168  stmt->setInt(1, tagID);
169  stmt->setInt(2, m_runNum);
170  stmt->setDate(3, dh.tmToDate(m_runStart));
171  stmt->setDate(4, dh.tmToDate(m_runEnd));
172 
173  stmt->executeUpdate();
174 
175  m_conn->terminateStatement(stmt);
176  } catch (SQLException& e) {
177  throw(std::runtime_error("RunIOV::writeDB: " + e.getMessage()));
178  }
179 
180  // Now get the ID
181  if (!this->fetchID()) {
182  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
183  }
184 
185  return m_ID;
186 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
int writeDB() noexcept(false)
Definition: RunTag.cc:120
Tm m_runStart
Definition: RunIOV.h:51
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
Tm m_runEnd
Definition: RunIOV.h:52
run_t m_runNum
Definition: RunIOV.h:50
int isNull() const
Definition: Tm.cc:46
RunTag m_runTag
Definition: RunIOV.h:53
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:355
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 15 of file RunIOV.h.

Member Data Documentation

Tm RunIOV::m_dbtime
private

Definition at line 54 of file RunIOV.h.

Referenced by getDBInsertionTime(), and setDBInsertionTime().

Tm RunIOV::m_runEnd
private

Definition at line 52 of file RunIOV.h.

Referenced by operator==().

run_t RunIOV::m_runNum
private

Definition at line 50 of file RunIOV.h.

Referenced by operator==().

Tm RunIOV::m_runStart
private

Definition at line 51 of file RunIOV.h.

Referenced by operator==().

RunTag RunIOV::m_runTag
private

Definition at line 53 of file RunIOV.h.

Referenced by operator==().