CMS 3D CMS Logo

RunCommentDat.cc
Go to the documentation of this file.
1 #include <stdexcept>
2 #include <string>
4 
7 
10 
11 using namespace std;
12 using namespace oracle::occi;
13 
15  m_env = nullptr;
16  m_conn = nullptr;
17  m_writeStmt = nullptr;
18  m_source = "";
19  m_comment = "";
20  m_time = Tm();
21 }
22 
24 
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 }
39 
40 void RunCommentDat::writeDB(const EcalLogicID* ecid, const RunCommentDat* item, RunIOV* iov) noexcept(false) {
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 }
59 
60 void RunCommentDat::fetchData(map<EcalLogicID, RunCommentDat>* fillMap, RunIOV* iov) noexcept(false) {
61  this->checkConnection();
62  fillMap->clear();
63 
64  DateHandler dh(m_env, m_conn);
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 }
RunIOV
Definition: RunIOV.h:13
funct::false
false
Definition: Factorize.h:34
RunIOV.h
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
RunCommentDat::~RunCommentDat
~RunCommentDat() override
Definition: RunCommentDat.cc:23
RunCommentDat::setSource
void setSource(std::string x)
Definition: RunCommentDat.h:20
RunCommentDat.h
RunCommentDat::RunCommentDat
RunCommentDat()
Definition: RunCommentDat.cc:14
oracle::occi
Definition: ConnectionManager.h:7
EcalLogicID
Definition: EcalLogicID.h:7
Tm
Definition: Tm.h:13
RunCommentDat
Definition: RunCommentDat.h:11
Tm.h
RunCommentDat::setComment
void setComment(std::string x)
Definition: RunCommentDat.h:22
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
EcalLogicID::NULLID
static const int NULLID
Definition: EcalLogicID.h:35
std
Definition: JetResolutionObject.h:76
RunCommentDat::prepareWrite
void prepareWrite() noexcept(false) override
Definition: RunCommentDat.cc:25
Oracle.h
DateHandler.h
DateHandler
Definition: DateHandler.h:7
RunCommentDat::fetchData
void fetchData(std::map< EcalLogicID, RunCommentDat > *fillMap, RunIOV *iov) noexcept(false)
Definition: RunCommentDat.cc:60
cuy.dh
dh
Definition: cuy.py:355
RunCommentDat::writeDB
void writeDB(const EcalLogicID *ecid, const RunCommentDat *item, RunIOV *iov) noexcept(false)
Definition: RunCommentDat.cc:40
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37