CMS 3D CMS Logo

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

#include <RunCommentDat.h>

Inheritance diagram for RunCommentDat:
IDataItem IDBObject

Public Member Functions

std::string getComment () const
 
Tm getDBTime () const
 
std::string getSource () const
 
std::string getTable () override
 
 RunCommentDat ()
 
void setComment (std::string x)
 
void setDBTime (const Tm &x)
 
void setSource (std::string x)
 
 ~RunCommentDat () override
 
- Public Member Functions inherited from IDataItem
 IDataItem ()
 
- 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 fetchData (std::map< EcalLogicID, RunCommentDat > *fillMap, RunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB (const EcalLogicID *ecid, const RunCommentDat *item, RunIOV *iov) noexcept(false)
 

Private Attributes

std::string m_comment
 
std::string m_source
 
Tm m_time
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IDataItem
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IDataItem
oracle::occi::Statement * m_readStmt
 
oracle::occi::Statement * m_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 11 of file RunCommentDat.h.

Constructor & Destructor Documentation

◆ RunCommentDat()

RunCommentDat::RunCommentDat ( )

Definition at line 14 of file RunCommentDat.cc.

14  {
15  m_env = nullptr;
16  m_conn = nullptr;
17  m_writeStmt = nullptr;
18  m_source = "";
19  m_comment = "";
20  m_time = Tm();
21 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string m_source
Definition: RunCommentDat.h:35
std::string m_comment
Definition: RunCommentDat.h:36
Definition: Tm.h:13

◆ ~RunCommentDat()

RunCommentDat::~RunCommentDat ( )
override

Definition at line 23 of file RunCommentDat.cc.

23 {}

Member Function Documentation

◆ fetchData()

void RunCommentDat::fetchData ( std::map< EcalLogicID, RunCommentDat > *  fillMap,
RunIOV iov 
)
privatenoexcept

Definition at line 60 of file RunCommentDat.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, EcalLogicID::NULLID, AlCaHLTBitMon_ParallelJobs::p, setComment(), and setSource().

60  {
61  this->checkConnection();
62  fillMap->clear();
63 
65 
66  iov->setConnection(m_env, m_conn);
67  int iovID = iov->fetchID();
68  if (!iovID) {
69  // throw(std::runtime_error("RunCommentDat::writeDB: IOV not in DB"));
70  return;
71  }
72 
73  try {
74  Statement* stmt = m_conn->createStatement();
75  stmt->setSQL(
76  "SELECT d.comment_id, "
77  "d.source, d.user_comment, d.db_timestamp "
78  "FROM run_comment_dat d "
79  "WHERE d.iov_id = :iov_id order by d.logic_id ");
80  stmt->setInt(1, iovID);
81  ResultSet* rset = stmt->executeQuery();
82 
83  std::pair<EcalLogicID, RunCommentDat> p;
84  RunCommentDat dat;
85  while (rset->next()) {
86  p.first = EcalLogicID("Comment_order",
87  rset->getInt(1),
88  rset->getInt(1),
90  EcalLogicID::NULLID, // comment number
91  "Comment_order");
92 
93  dat.setSource(rset->getString(2));
94  dat.setComment(rset->getString(3));
95 
96  Date startDate = rset->getDate(4);
97  m_time = dh.dateToTm(startDate);
98 
99  p.second = dat;
100  fillMap->insert(p);
101  }
102  m_conn->terminateStatement(stmt);
103  } catch (SQLException& e) {
104  throw(std::runtime_error("RunCommentDat::fetchData(): " + e.getMessage()));
105  }
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
void setSource(std::string x)
Definition: RunCommentDat.h:20
static const int NULLID
Definition: EcalLogicID.h:35
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
dh
Definition: cuy.py:354
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60
void setComment(std::string x)
Definition: RunCommentDat.h:22

◆ getComment()

std::string RunCommentDat::getComment ( ) const
inline

Definition at line 23 of file RunCommentDat.h.

References m_comment.

23 { return m_comment; }
std::string m_comment
Definition: RunCommentDat.h:36

◆ getDBTime()

Tm RunCommentDat::getDBTime ( ) const
inline

Definition at line 25 of file RunCommentDat.h.

References m_time.

25 { return m_time; }

◆ getSource()

std::string RunCommentDat::getSource ( ) const
inline

Definition at line 21 of file RunCommentDat.h.

References m_source.

21 { return m_source; }
std::string m_source
Definition: RunCommentDat.h:35

◆ getTable()

std::string RunCommentDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file RunCommentDat.h.

18 { return "RUN_COMMENT_DAT"; }

◆ prepareWrite()

void RunCommentDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 25 of file RunCommentDat.cc.

References MillePedeFileConverter_cfg::e.

25  {
26  this->checkConnection();
27 
28  try {
29  m_writeStmt = m_conn->createStatement();
30  m_writeStmt->setSQL(
31  "INSERT INTO run_comment_dat (iov_id, "
32  "source, user_comment) "
33  "VALUES (:iov_id, "
34  ":source, :user_comment)");
35  } catch (SQLException& e) {
36  throw(std::runtime_error("RunCommentDat::prepareWrite(): " + e.getMessage()));
37  }
38 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36

◆ setComment()

void RunCommentDat::setComment ( std::string  x)
inline

Definition at line 22 of file RunCommentDat.h.

References m_comment, and x.

Referenced by ConfigToolBase.ConfigToolBase::apply(), and fetchData().

22 { m_comment = x; }
std::string m_comment
Definition: RunCommentDat.h:36

◆ setDBTime()

void RunCommentDat::setDBTime ( const Tm x)
inline

Definition at line 24 of file RunCommentDat.h.

References m_time, and x.

◆ setSource()

void RunCommentDat::setSource ( std::string  x)
inline

Definition at line 20 of file RunCommentDat.h.

References m_source, and x.

Referenced by fetchData().

20 { m_source = x; }
std::string m_source
Definition: RunCommentDat.h:35

◆ writeDB()

void RunCommentDat::writeDB ( const EcalLogicID ecid,
const RunCommentDat item,
RunIOV iov 
)
privatenoexcept

Definition at line 40 of file RunCommentDat.cc.

References MillePedeFileConverter_cfg::e, and B2GTnPMonitor_cfi::item.

40  {
41  this->checkConnection();
42  this->checkPrepare();
43 
44  int iovID = iov->fetchID();
45  if (!iovID) {
46  throw(std::runtime_error("RunCommentDat::writeDB: IOV not in DB"));
47  }
48 
49  try {
50  m_writeStmt->setInt(1, iovID);
51  m_writeStmt->setString(2, item->getSource());
52  m_writeStmt->setString(3, item->getComment());
53 
54  m_writeStmt->executeUpdate();
55  } catch (SQLException& e) {
56  throw(std::runtime_error("RunCommentDat::writeDB(): " + e.getMessage()));
57  }
58 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:23
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void checkPrepare() noexcept(false)
Definition: IDataItem.h:26
int fetchID() noexcept(false) override
Definition: RunIOV.cc:60

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file RunCommentDat.h.

Member Data Documentation

◆ m_comment

std::string RunCommentDat::m_comment
private

Definition at line 36 of file RunCommentDat.h.

Referenced by getComment(), and setComment().

◆ m_source

std::string RunCommentDat::m_source
private

Definition at line 35 of file RunCommentDat.h.

Referenced by getSource(), and setSource().

◆ m_time

Tm RunCommentDat::m_time
private

Definition at line 37 of file RunCommentDat.h.

Referenced by getDBTime(), and setDBTime().