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 ( )

Definition at line 16 of file RunCommentDat.cc.

17 {
18  m_env = nullptr;
19  m_conn = nullptr;
20  m_writeStmt = nullptr;
21  m_source = "";
22  m_comment = "";
23  m_time = Tm();
24 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string m_source
Definition: RunCommentDat.h:38
std::string m_comment
Definition: RunCommentDat.h:39
Definition: Tm.h:13
RunCommentDat::~RunCommentDat ( )
override

Definition at line 28 of file RunCommentDat.cc.

29 {
30 }

Member Function Documentation

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

Definition at line 74 of file RunCommentDat.cc.

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

Referenced by getDBTime().

76 {
77  this->checkConnection();
78  fillMap->clear();
79 
81 
82  iov->setConnection(m_env, m_conn);
83  int iovID = iov->fetchID();
84  if (!iovID) {
85  // throw(std::runtime_error("RunCommentDat::writeDB: IOV not in DB"));
86  return;
87  }
88 
89  try {
90  Statement* stmt = m_conn->createStatement();
91  stmt->setSQL("SELECT d.comment_id, "
92  "d.source, d.user_comment, d.db_timestamp "
93  "FROM run_comment_dat d "
94  "WHERE d.iov_id = :iov_id order by d.logic_id ");
95  stmt->setInt(1, iovID);
96  ResultSet* rset = stmt->executeQuery();
97 
98  std::pair< EcalLogicID, RunCommentDat > p;
99  RunCommentDat dat;
100  while(rset->next()) {
101  p.first = EcalLogicID( "Comment_order",
102  rset->getInt(1), rset->getInt(1),
103  EcalLogicID::NULLID, EcalLogicID::NULLID, // comment number
104  "Comment_order");
105 
106  dat.setSource( rset->getString(2) );
107  dat.setComment( rset->getString(3) );
108 
109  Date startDate = rset->getDate(4);
110  m_time = dh.dateToTm( startDate );
111 
112  p.second = dat;
113  fillMap->insert(p);
114  }
115  m_conn->terminateStatement(stmt);
116  } catch (SQLException &e) {
117  throw(std::runtime_error("RunCommentDat::fetchData(): "+e.getMessage()));
118  }
119 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setSource(std::string x)
Definition: RunCommentDat.h:20
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
static const int NULLID
Definition: EcalLogicID.h:42
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:103
void setComment(std::string x)
Definition: RunCommentDat.h:22
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:39
Tm RunCommentDat::getDBTime ( ) const
inline

Definition at line 25 of file RunCommentDat.h.

References fetchData(), m_time, noexcept, prepareWrite(), and writeDB().

25 {return m_time;}
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:38
std::string RunCommentDat::getTable ( )
inlineoverridevirtual

Implements IDataItem.

Definition at line 18 of file RunCommentDat.h.

18 { return "RUN_COMMENT_DAT"; }
void RunCommentDat::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IDataItem.

Definition at line 34 of file RunCommentDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getDBTime().

36 {
37  this->checkConnection();
38 
39  try {
40  m_writeStmt = m_conn->createStatement();
41  m_writeStmt->setSQL("INSERT INTO run_comment_dat (iov_id, "
42  "source, user_comment) "
43  "VALUES (:iov_id, "
44  ":source, :user_comment)");
45  } catch (SQLException &e) {
46  throw(std::runtime_error("RunCommentDat::prepareWrite(): "+e.getMessage()));
47  }
48 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void RunCommentDat::setComment ( std::string  x)
inline

Definition at line 22 of file RunCommentDat.h.

References m_comment, and x.

Referenced by fetchData().

22 { m_comment = x; }
std::string m_comment
Definition: RunCommentDat.h:39
void RunCommentDat::setDBTime ( const Tm x)
inline

Definition at line 24 of file RunCommentDat.h.

References m_time, and x.

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:38
void RunCommentDat::writeDB ( const EcalLogicID ecid,
const RunCommentDat item,
RunIOV iov 
)
privatenoexcept

Definition at line 52 of file RunCommentDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getDBTime().

54 {
55  this->checkConnection();
56  this->checkPrepare();
57 
58  int iovID = iov->fetchID();
59  if (!iovID) { throw(std::runtime_error("RunCommentDat::writeDB: IOV not in DB")); }
60 
61  try {
62  m_writeStmt->setInt(1, iovID);
63  m_writeStmt->setString(2, item->getSource());
64  m_writeStmt->setString(3, item->getComment());
65 
66  m_writeStmt->executeUpdate();
67  } catch (SQLException &e) {
68  throw(std::runtime_error("RunCommentDat::writeDB(): "+e.getMessage()));
69  }
70 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
std::string getComment() const
Definition: RunCommentDat.h:23
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string getSource() const
Definition: RunCommentDat.h:21
int fetchID() noexcept(false) override
Definition: RunIOV.cc:103

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file RunCommentDat.h.

Member Data Documentation

std::string RunCommentDat::m_comment
private

Definition at line 39 of file RunCommentDat.h.

Referenced by getComment(), and setComment().

std::string RunCommentDat::m_source
private

Definition at line 38 of file RunCommentDat.h.

Referenced by getSource(), and setSource().

Tm RunCommentDat::m_time
private

Definition at line 40 of file RunCommentDat.h.

Referenced by getDBTime(), and setDBTime().