CMS 3D CMS Logo

MonRunOutcomeDef.cc
Go to the documentation of this file.
1 #include <string>
3 
5 
6 using namespace std;
7 using namespace oracle::occi;
8 
10  m_env = nullptr;
11  m_conn = nullptr;
12  m_ID = 0;
13  m_shortDesc = "";
14  m_longDesc = "";
15 }
16 
18 
19 string MonRunOutcomeDef::getShortDesc() const { return m_shortDesc; }
20 
21 void MonRunOutcomeDef::setShortDesc(string desc) {
22  if (desc != m_shortDesc) {
23  m_ID = 0;
24  m_shortDesc = desc;
25  }
26 }
27 
28 string MonRunOutcomeDef::getLongDesc() const { return m_longDesc; }
29 
31  // Return def from memory if available
32  if (m_ID) {
33  return m_ID;
34  }
35 
36  this->checkConnection();
37 
38  try {
39  Statement* stmt = m_conn->createStatement();
40  stmt->setSQL(
41  "SELECT def_id FROM mon_run_outcome_def WHERE "
42  "short_desc = :1");
43  stmt->setString(1, m_shortDesc);
44 
45  ResultSet* rset = stmt->executeQuery();
46 
47  if (rset->next()) {
48  m_ID = rset->getInt(1);
49  } else {
50  m_ID = 0;
51  }
52  m_conn->terminateStatement(stmt);
53  } catch (SQLException& e) {
54  throw(std::runtime_error("MonRunOutcomeDef::fetchID: " + e.getMessage()));
55  }
56 
57  return m_ID;
58 }
59 
60 void MonRunOutcomeDef::setByID(int id) noexcept(false) {
61  this->checkConnection();
62 
63  try {
64  Statement* stmt = m_conn->createStatement();
65 
66  stmt->setSQL("SELECT short_desc, long_desc FROM mon_run_outcome_def WHERE def_id = :1");
67  stmt->setInt(1, id);
68 
69  ResultSet* rset = stmt->executeQuery();
70  if (rset->next()) {
71  m_shortDesc = rset->getString(1);
72  m_longDesc = rset->getString(2);
73  m_ID = id;
74  } else {
75  throw(std::runtime_error("MonRunOutcomeDef::setByID: Given def_id is not in the database"));
76  }
77 
78  m_conn->terminateStatement(stmt);
79  } catch (SQLException& e) {
80  throw(std::runtime_error("MonRunOutcomeDef::setByID: " + e.getMessage()));
81  }
82 }
83 
84 void MonRunOutcomeDef::fetchAllDefs(std::vector<MonRunOutcomeDef>* fillVec) noexcept(false) {
85  this->checkConnection();
86  try {
87  Statement* stmt = m_conn->createStatement();
88  stmt->setSQL("SELECT def_id FROM mon_run_outcome_def ORDER BY def_id");
89  ResultSet* rset = stmt->executeQuery();
90 
92  def.setConnection(m_env, m_conn);
93 
94  while (rset->next()) {
95  def.setByID(rset->getInt(1));
96  fillVec->push_back(def);
97  }
98  } catch (SQLException& e) {
99  throw(std::runtime_error("MonRunOutcomeDef::fetchAllDefs: " + e.getMessage()));
100  }
101 }
MonRunOutcomeDef.h
funct::false
false
Definition: Factorize.h:34
MonRunOutcomeDef::fetchID
int fetchID() noexcept(false) override
Definition: MonRunOutcomeDef.cc:30
MonRunOutcomeDef::getShortDesc
std::string getShortDesc() const
Definition: MonRunOutcomeDef.cc:19
MonRunOutcomeDef::getLongDesc
std::string getLongDesc() const
Definition: MonRunOutcomeDef.cc:28
oracle::occi
Definition: ConnectionManager.h:7
MonRunOutcomeDef::fetchAllDefs
void fetchAllDefs(std::vector< MonRunOutcomeDef > *fillVec) noexcept(false)
Definition: MonRunOutcomeDef.cc:84
MonRunOutcomeDef::setByID
void setByID(int id) noexcept(false) override
Definition: MonRunOutcomeDef.cc:60
MonRunOutcomeDef::~MonRunOutcomeDef
~MonRunOutcomeDef() override
Definition: MonRunOutcomeDef.cc:17
std
Definition: JetResolutionObject.h:76
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
Oracle.h
spu::def
int def(FILE *, FILE *, int)
Definition: SherpackUtilities.cc:14
MonRunOutcomeDef::MonRunOutcomeDef
MonRunOutcomeDef()
Definition: MonRunOutcomeDef.cc:9
MonRunOutcomeDef
Definition: MonRunOutcomeDef.h:12
MonRunOutcomeDef::setShortDesc
void setShortDesc(std::string desc)
Definition: MonRunOutcomeDef.cc:21
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37