CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 () throw (std::runtime_error)
 
int fetchIDByRunAndTag () throw (std::runtime_error)
 
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) throw (std::runtime_error)
 
void setDBInsertionTime (Tm dbtime)
 
void setID (int id)
 
void setRunEnd (Tm end)
 
void setRunNumber (run_t run)
 
void setRunStart (Tm start)
 
void setRunTag (RunTag tag)
 
 ~RunIOV ()
 
- 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) throw (std::runtime_error)
 
void setByRecentData (std::string dataTable, std::string location, run_t run) throw (std::runtime_error)
 
void setByRun (RunTag *tag, run_t run) throw (std::runtime_error)
 
void setByRun (std::string location, run_t run) throw (std::runtime_error)
 
int updateEndTimeDB () throw (std::runtime_error)
 
int updateStartTimeDB () throw (std::runtime_error)
 
int writeDB () throw (std::runtime_error)
 

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 throw (std::runtime_error)
 
- 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.

References NULL.

13 {
14  m_conn = NULL;
15  m_ID = 0;
16  m_runNum = 0;
17  m_runStart = Tm();
18  m_runEnd = Tm();
19 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
#define NULL
Definition: scimark2.h:8
Tm m_runEnd
Definition: RunIOV.h:57
run_t m_runNum
Definition: RunIOV.h:55
Definition: Tm.h:14
RunIOV::~RunIOV ( )

Definition at line 23 of file RunIOV.cc.

24 {
25 }

Member Function Documentation

int RunIOV::fetchID ( )
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 103 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

105 {
106  // Return from memory if available
107  if (m_ID) {
108  return m_ID;
109  }
110 
111  this->checkConnection();
112 
114  int tagID = m_runTag.fetchID();
115  if (!tagID) {
116  return 0;
117  }
118 
119  DateHandler dh(m_env, m_conn);
120 
121  if (m_runEnd.isNull()) {
122  m_runEnd = dh.getPlusInfTm();
123  }
124 
125  try {
126  Statement* stmt = m_conn->createStatement();
127  stmt->setSQL("SELECT iov_id FROM run_iov "
128  "WHERE tag_id = :tag_id AND "
129  "run_num = :run_num AND "
130  "run_start = :run_start " );
131  stmt->setInt(1, tagID);
132  stmt->setInt(2, m_runNum);
133  stmt->setDate(3, dh.tmToDate(m_runStart));
134 
135  ResultSet* rset = stmt->executeQuery();
136 
137  if (rset->next()) {
138  m_ID = rset->getInt(1);
139  } else {
140  m_ID = 0;
141  }
142  m_conn->terminateStatement(stmt);
143  } catch (SQLException &e) {
144  throw(std::runtime_error("RunIOV::fetchID: "+e.getMessage()));
145  }
146 
147  return m_ID;
148 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int fetchID()
Definition: RunTag.cc:80
Tm m_runEnd
Definition: RunIOV.h:57
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
run_t m_runNum
Definition: RunIOV.h:55
int isNull() const
Definition: Tm.cc:56
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
int RunIOV::fetchIDByRunAndTag ( )
throw (std::runtime_error
)

Definition at line 284 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, and DateHandler::getPlusInfTm().

286 {
287  // Return from memory if available
288  if (m_ID) {
289  return m_ID;
290  }
291 
292  this->checkConnection();
293 
295  int tagID = m_runTag.fetchID();
296  if (!tagID) {
297  return 0;
298  }
299 
300  DateHandler dh(m_env, m_conn);
301 
302  if (m_runEnd.isNull()) {
303  m_runEnd = dh.getPlusInfTm();
304  }
305 
306  try {
307  Statement* stmt = m_conn->createStatement();
308  stmt->setSQL("SELECT iov_id FROM run_iov "
309  "WHERE tag_id = :tag_id AND "
310  "run_num = :run_num " );
311  stmt->setInt(1, tagID);
312  stmt->setInt(2, m_runNum);
313 
314  ResultSet* rset = stmt->executeQuery();
315 
316  if (rset->next()) {
317  m_ID = rset->getInt(1);
318  } else {
319  m_ID = 0;
320  }
321  m_conn->terminateStatement(stmt);
322  } catch (SQLException &e) {
323  throw(std::runtime_error("RunIOV::fetchID: "+e.getMessage()));
324  }
325 
326  return m_ID;
327 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int fetchID()
Definition: RunTag.cc:80
Tm m_runEnd
Definition: RunIOV.h:57
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
run_t m_runNum
Definition: RunIOV.h:55
int isNull() const
Definition: Tm.cc:56
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
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:59
int RunIOV::getID ( )
inline
Tm RunIOV::getRunEnd ( ) const

Definition at line 79 of file RunIOV.cc.

Referenced by EcalTPGDBApp::printIOV().

80 {
81  return m_runEnd;
82 }
Tm m_runEnd
Definition: RunIOV.h:57
run_t RunIOV::getRunNumber ( ) const
Tm RunIOV::getRunStart ( ) const

Definition at line 62 of file RunIOV.cc.

Referenced by EcalTPGDBApp::printIOV().

63 {
64  return m_runStart;
65 }
Tm m_runStart
Definition: RunIOV.h:56
RunTag RunIOV::getRunTag ( ) const

Definition at line 96 of file RunIOV.cc.

Referenced by EcalTPGDBApp::printIOV(), and EcalPedOffset::writeDb().

97 {
98  return m_runTag;
99 }
RunTag m_runTag
Definition: RunIOV.h:58
bool RunIOV::operator!= ( const RunIOV r) const
inline

Definition at line 51 of file RunIOV.h.

References csvReporter::r.

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

Definition at line 43 of file RunIOV.h.

References m_runEnd, m_runNum, m_runStart, and m_runTag.

44  {
45  return (m_runNum == r.m_runNum &&
46  m_runStart == r.m_runStart &&
47  m_runEnd == r.m_runEnd &&
48  m_runTag == r.m_runTag);
49  }
Tm m_runStart
Definition: RunIOV.h:56
Tm m_runEnd
Definition: RunIOV.h:57
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void RunIOV::setByID ( int  id)
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 152 of file RunIOV.cc.

References DateHandler::dateToTm(), ExpressReco_HICollisions_FallBack::e, and ExpressReco_HICollisions_FallBack::id.

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

154 {
155  this->checkConnection();
156 
157  DateHandler dh(m_env, m_conn);
158 
159  try {
160  Statement* stmt = m_conn->createStatement();
161 
162  stmt->setSQL("SELECT tag_id, run_num, run_start, run_end FROM run_iov WHERE iov_id = :1");
163  stmt->setInt(1, id);
164 
165  ResultSet* rset = stmt->executeQuery();
166  if (rset->next()) {
167  int tagID = rset->getInt(1);
168  m_runNum = rset->getInt(2);
169  Date startDate = rset->getDate(3);
170  Date endDate = rset->getDate(4);
171 
172  m_runStart = dh.dateToTm( startDate );
173  m_runEnd = dh.dateToTm( endDate );
174 
176  m_runTag.setByID(tagID);
177  m_ID = id;
178  } else {
179  throw(std::runtime_error("RunIOV::setByID: Given tag_id is not in the database"));
180  }
181 
182  m_conn->terminateStatement(stmt);
183  } catch (SQLException &e) {
184  throw(std::runtime_error("RunIOV::setByID: "+e.getMessage()));
185  }
186 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setByID(int id)
Definition: RunTag.cc:127
Tm m_runEnd
Definition: RunIOV.h:57
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
void RunIOV::setByRecentData ( std::string  dataTable,
RunTag tag,
run_t  run = (unsigned int)-1 
)
throw (std::runtime_error
)
private

Definition at line 457 of file RunIOV.cc.

References DateHandler::dateToTm(), ExpressReco_HICollisions_FallBack::e, CrabTask::run, and GlobalPosition_Frontier_DevDB_cff::tag.

459 {
460  this->checkConnection();
461 
462  tag->setConnection(m_env, m_conn);
463  int tagID = tag->fetchID();
464  if (!tagID) {
465  throw(std::runtime_error("RunIOV::setByRecentData: Given tag is not in the database"));
466  }
467 
468  DateHandler dh(m_env, m_conn);
469 
470  try {
471  Statement* stmt = m_conn->createStatement();
472 
473  stmt->setSQL("SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end "
474  "FROM run_iov riov "
475  "JOIN "+dataTable+" dat on dat.iov_id = riov.iov_id "
476  "WHERE tag_id = :1 AND riov.run_num <= :run ORDER BY riov.run_num DESC) WHERE rownum = 1");
477 
478  stmt->setInt(1, tagID);
479  stmt->setInt(2, run);
480 
481  ResultSet* rset = stmt->executeQuery();
482  if (rset->next()) {
483  m_runTag = *tag;
484 
485  m_ID = rset->getInt(1);
486  m_runNum = rset->getInt(2);
487  Date startDate = rset->getDate(3);
488  Date endDate = rset->getDate(4);
489 
490  m_runStart = dh.dateToTm( startDate );
491  m_runEnd = dh.dateToTm( endDate );
492  } else {
493  throw(std::runtime_error("RunIOV::setByRecentData: No data exists for given tag and run"));
494  }
495 
496  m_conn->terminateStatement(stmt);
497  } catch (SQLException &e) {
498  throw(std::runtime_error("RunIOV::setByRecentData: "+e.getMessage()));
499  }
500 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int fetchID()
Definition: RunTag.cc:80
Tm m_runEnd
Definition: RunIOV.h:57
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
void RunIOV::setByRecentData ( std::string  dataTable,
std::string  location,
run_t  run 
)
throw (std::runtime_error
)
private

Definition at line 507 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, and CrabTask::run.

509 {
510  this->checkConnection();
511 
512  DateHandler dh(m_env, m_conn);
513 
514  try {
515  Statement* stmt = m_conn->createStatement();
516 
517  stmt->setSQL("SELECT * FROM (SELECT riov.iov_id, riov.run_num, riov.run_start, riov.run_end "
518  "FROM run_iov riov "
519  "JOIN "+dataTable+" dat on dat.iov_id = riov.iov_id "
520  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
521  "JOIN location_def loc ON rtag.location_id = loc.def_id "
522  "WHERE loc.location = :1 AND riov.run_num <= :2 ORDER BY riov.run_num DESC ) WHERE rownum = 1");
523 
524  stmt->setString(1, location);
525  stmt->setInt(2, run);
526 
527  ResultSet* rset = stmt->executeQuery();
528 
529 
530  if (rset->next()) {
531  int id = rset->getInt(1);
532  this->setByID(id);
533  } else {
534  throw(std::runtime_error("RunIOV::setByRecentData(datatable, loc, run): Given run is not in the database"));
535  }
536 
537 
538  m_conn->terminateStatement(stmt);
539  } catch (SQLException &e) {
540  throw(std::runtime_error("RunIOV::setByRecentData: "+e.getMessage()));
541  }
542 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setByID(int id)
Definition: RunIOV.cc:152
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
void RunIOV::setByRun ( RunTag tag,
run_t  run 
)
throw (std::runtime_error
)
private

Definition at line 376 of file RunIOV.cc.

References DateHandler::dateToTm(), ExpressReco_HICollisions_FallBack::e, CrabTask::run, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by EcalCondDBInterface::fetchRunIOV().

378 {
379  this->checkConnection();
380 
381  tag->setConnection(m_env, m_conn);
382  int tagID = tag->fetchID();
383  if (!tagID) {
384  throw(std::runtime_error("RunIOV::setByRun: Given tag is not in the database"));
385  }
386 
387  DateHandler dh(m_env, m_conn);
388 
389  try {
390  Statement* stmt = m_conn->createStatement();
391 
392  stmt->setSQL("SELECT iov_id, run_start, run_end FROM run_iov WHERE tag_id = :1 AND run_num = :2");
393  stmt->setInt(1, tagID);
394  stmt->setInt(2, run);
395 
396  ResultSet* rset = stmt->executeQuery();
397  if (rset->next()) {
398  m_runTag = *tag;
399  m_runNum = run;
400 
401  m_ID = rset->getInt(1);
402  Date startDate = rset->getDate(2);
403  Date endDate = rset->getDate(3);
404 
405  m_runStart = dh.dateToTm( startDate );
406  m_runEnd = dh.dateToTm( endDate );
407  } else {
408  throw(std::runtime_error("RunIOV::setByRun: Given run is not in the database"));
409  }
410 
411  m_conn->terminateStatement(stmt);
412  } catch (SQLException &e) {
413  throw(std::runtime_error("RunIOV::setByRun: "+e.getMessage()));
414  }
415 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int fetchID()
Definition: RunTag.cc:80
Tm m_runEnd
Definition: RunIOV.h:57
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
run_t m_runNum
Definition: RunIOV.h:55
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
void RunIOV::setByRun ( std::string  location,
run_t  run 
)
throw (std::runtime_error
)
private

Definition at line 419 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, and CrabTask::run.

421 {
422  this->checkConnection();
423 
424  DateHandler dh(m_env, m_conn);
425 
426  try {
427  Statement* stmt = m_conn->createStatement();
428 
429  stmt->setSQL("SELECT iov_id FROM run_iov riov "
430  "JOIN run_tag rtag ON riov.tag_id = rtag.tag_id "
431  "JOIN location_def loc ON rtag.location_id = loc.def_id "
432  "WHERE loc.location = :1 AND riov.run_num = :2 "
433  "AND rtag.gen_tag != 'INVALID'");
434  stmt->setString(1, location);
435  stmt->setInt(2, run);
436 
437  ResultSet* rset = stmt->executeQuery();
438  if (rset->next()) {
439  int id = rset->getInt(1);
440  this->setByID(id);
441  } else {
442  throw(std::runtime_error("RunIOV::setByRun(loc, run): Given run is not in the database"));
443  }
444 
445  // Check for uniqueness of run
446  if (rset->next()) {
447  throw(std::runtime_error("RunIOV::setByRun(loc, run): Run is nonunique for given location."));
448  }
449 
450  m_conn->terminateStatement(stmt);
451  } catch (SQLException &e) {
452  throw(std::runtime_error("RunIOV::setByRun(loc, run): "+e.getMessage()));
453  }
454 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setByID(int id)
Definition: RunIOV.cc:152
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
void RunIOV::setDBInsertionTime ( Tm  dbtime)
inline
void RunIOV::setID ( int  id)
void RunIOV::setRunEnd ( Tm  end)

Definition at line 69 of file RunIOV.cc.

References end.

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

70 {
71  if (end != m_runEnd) {
72  m_ID = 0;
73  m_runEnd = end;
74  }
75 }
#define end
Definition: vmac.h:38
Tm m_runEnd
Definition: RunIOV.h:57
void RunIOV::setRunNumber ( run_t  run)
void RunIOV::setRunStart ( Tm  start)
void RunIOV::setRunTag ( RunTag  tag)
int RunIOV::updateEndTimeDB ( )
throw (std::runtime_error
)
private

Definition at line 240 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

242 {
243  this->checkConnection();
244 
245  // Check if this IOV has already been written
246  if(!this->fetchID()){
247  this->writeDB();
248  }
249 
250 
252  // int tagID = m_runTag.writeDB();
253 
254  // Validate the data, use infinity-till convention
255  DateHandler dh(m_env, m_conn);
256 
257  // we only update the run end here
258  if (m_runEnd.isNull()) {
259  m_runEnd = dh.getPlusInfTm();
260  }
261 
262  try {
263  Statement* stmt = m_conn->createStatement();
264 
265  stmt->setSQL("UPDATE run_iov set run_end=:1 where iov_id=:2 " );
266  stmt->setDate(1, dh.tmToDate(m_runEnd));
267  stmt->setInt(2, m_ID);
268 
269  stmt->executeUpdate();
270 
271  m_conn->terminateStatement(stmt);
272  } catch (SQLException &e) {
273  throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage()));
274  }
275 
276  // Now get the ID
277  if (!this->fetchID()) {
278  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
279  }
280 
281  return m_ID;
282 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID()
Definition: RunIOV.cc:103
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
Tm m_runEnd
Definition: RunIOV.h:57
int isNull() const
Definition: Tm.cc:56
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int writeDB()
Definition: RunIOV.cc:190
void checkConnection() const
Definition: IDBObject.h:41
int RunIOV::updateStartTimeDB ( )
throw (std::runtime_error
)
private

Definition at line 330 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

332 {
333  this->checkConnection();
334 
335  // Check if this IOV has already been written
336  if(!this->fetchIDByRunAndTag()){
337  this->writeDB();
338  }
339 
340 
341  // m_runTag.setConnection(m_env, m_conn);
342  // int tagID = m_runTag.writeDB();
343 
344  // Validate the data, use infinity-till convention
345  DateHandler dh(m_env, m_conn);
346 
347  // we only update the run start here
348  if (m_runEnd.isNull()) {
349  m_runEnd = dh.getPlusInfTm();
350  }
351 
352  try {
353  Statement* stmt = m_conn->createStatement();
354 
355  stmt->setSQL("UPDATE run_iov set run_start=:1 where iov_id=:2 " );
356  stmt->setDate(1, dh.tmToDate(m_runStart));
357  stmt->setInt(2, m_ID);
358 
359  stmt->executeUpdate();
360 
361  m_conn->terminateStatement(stmt);
362  } catch (SQLException &e) {
363  throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage()));
364  }
365 
366  // Now get the ID
367  if (!this->fetchID()) {
368  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
369  }
370 
371  return m_ID;
372 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
int fetchID()
Definition: RunIOV.cc:103
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int fetchIDByRunAndTag()
Definition: RunIOV.cc:284
Tm m_runEnd
Definition: RunIOV.h:57
int isNull() const
Definition: Tm.cc:56
int writeDB()
Definition: RunIOV.cc:190
void checkConnection() const
Definition: IDBObject.h:41
int RunIOV::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 190 of file RunIOV.cc.

References ExpressReco_HICollisions_FallBack::e, DateHandler::getPlusInfTm(), and DateHandler::tmToDate().

192 {
193  this->checkConnection();
194 
195  // Check if this IOV has already been written
196  if (this->fetchID()) {
197  return m_ID;
198  }
199 
201  int tagID = m_runTag.writeDB();
202 
203  // Validate the data, use infinity-till convention
204  DateHandler dh(m_env, m_conn);
205 
206  if (m_runStart.isNull()) {
207  throw(std::runtime_error("RunIOV::writeDB: Must setRunStart before writing"));
208  }
209 
210  if (m_runEnd.isNull()) {
211  m_runEnd = dh.getPlusInfTm();
212  }
213 
214  try {
215  Statement* stmt = m_conn->createStatement();
216 
217  stmt->setSQL("INSERT INTO run_iov (iov_id, tag_id, run_num, run_start, run_end) "
218  "VALUES (run_iov_sq.NextVal, :1, :2, :3, :4)");
219  stmt->setInt(1, tagID);
220  stmt->setInt(2, m_runNum);
221  stmt->setDate(3, dh.tmToDate(m_runStart));
222  stmt->setDate(4, dh.tmToDate(m_runEnd));
223 
224  stmt->executeUpdate();
225 
226  m_conn->terminateStatement(stmt);
227  } catch (SQLException &e) {
228  throw(std::runtime_error("RunIOV::writeDB: "+e.getMessage()));
229  }
230 
231  // Now get the ID
232  if (!this->fetchID()) {
233  throw(std::runtime_error("RunIOV::writeDB: Failed to write"));
234  }
235 
236  return m_ID;
237 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Tm m_runStart
Definition: RunIOV.h:56
int fetchID()
Definition: RunIOV.cc:103
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int writeDB()
Definition: RunTag.cc:162
Tm m_runEnd
Definition: RunIOV.h:57
run_t m_runNum
Definition: RunIOV.h:55
int isNull() const
Definition: Tm.cc:56
RunTag m_runTag
Definition: RunIOV.h:58
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41

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 59 of file RunIOV.h.

Referenced by getDBInsertionTime(), and setDBInsertionTime().

Tm RunIOV::m_runEnd
private

Definition at line 57 of file RunIOV.h.

Referenced by operator==().

run_t RunIOV::m_runNum
private

Definition at line 55 of file RunIOV.h.

Referenced by operator==().

Tm RunIOV::m_runStart
private

Definition at line 56 of file RunIOV.h.

Referenced by operator==().

RunTag RunIOV::m_runTag
private

Definition at line 58 of file RunIOV.h.

Referenced by operator==().