CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODRunConfigCycleInfo Class Reference

#include <ODRunConfigCycleInfo.h>

Inheritance diagram for ODRunConfigCycleInfo:
IODConfig IDBObject

Public Member Functions

int getCycleNumber () const
 
std::string getDescription () const
 
int getId () const
 
int getSequenceID () const
 
std::string getTable () override
 
std::string getTag () const
 
 ODRunConfigCycleInfo ()
 
bool operator!= (const ODRunConfigCycleInfo &r) const
 
bool operator== (const ODRunConfigCycleInfo &r) const
 
void setCycleNumber (int n)
 
void setDescription (std::string x)
 
void setId (int id)
 
void setSequenceID (int x)
 
void setTag (std::string x)
 
 ~ODRunConfigCycleInfo () override
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- 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 clear ()
 
void fetchData (ODRunConfigCycleInfo *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchIDLast () noexcept(false)
 
void insertConfig () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void setByID (int id) noexcept(false)
 
void writeDB () noexcept(false)
 

Private Attributes

int m_cycle_num
 
std::string m_description
 
int m_ID
 
int m_sequence_id
 
std::string m_tag
 

Friends

class EcalCondDBInterface
 
class ODEcalCycle
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) 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 IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 12 of file ODRunConfigCycleInfo.h.

Constructor & Destructor Documentation

ODRunConfigCycleInfo::ODRunConfigCycleInfo ( )

Definition at line 11 of file ODRunConfigCycleInfo.cc.

11  {
12  m_env = nullptr;
13  m_conn = nullptr;
14  m_writeStmt = nullptr;
15  m_readStmt = nullptr;
16 
17  m_ID = 0;
18 
19  m_sequence_id = 0;
20  m_cycle_num = 0;
21  m_tag = "";
22  m_description = "";
23 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
Statement * m_readStmt
Definition: IODConfig.h:34
ODRunConfigCycleInfo::~ODRunConfigCycleInfo ( )
override

Definition at line 25 of file ODRunConfigCycleInfo.cc.

25 {}

Member Function Documentation

void ODRunConfigCycleInfo::clear ( void  )
private

Definition at line 27 of file ODRunConfigCycleInfo.cc.

27  {
28  m_sequence_id = 0;
29  m_cycle_num = 0;
30  m_tag = "";
31  m_description = "";
32 }
void ODRunConfigCycleInfo::fetchData ( ODRunConfigCycleInfo result)
privatenoexcept

Definition at line 161 of file ODRunConfigCycleInfo.cc.

References alignCSCRings::e, and mps_fire::result.

161  {
162  this->checkConnection();
163  result->clear();
164  if (result->getId() == 0) {
165  throw(std::runtime_error("ODRunConfigCycleInfo::fetchData(): no Id defined for this ODRunConfigCycleInfo "));
166  }
167 
168  try {
169  m_readStmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
170 
171  m_readStmt->setInt(1, result->getId());
172  ResultSet* rset = m_readStmt->executeQuery();
173 
174  rset->next();
175 
176  result->setSequenceID(rset->getInt(1));
177  result->setCycleNumber(rset->getInt(2));
178  result->setTag(rset->getString(3));
179  result->setDescription(rset->getString(4));
180 
181  } catch (SQLException& e) {
182  throw(std::runtime_error("ODRunConfigCycleInfo::fetchData(): " + e.getMessage()));
183  }
184 }
void setDescription(std::string x)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setTag(std::string x)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
int ODRunConfigCycleInfo::fetchID ( )
privatenoexcept

Definition at line 73 of file ODRunConfigCycleInfo.cc.

References cuy::dh, and alignCSCRings::e.

73  {
74  // Return from memory if available
75  if (m_ID > 0) {
76  return m_ID;
77  }
78 
79  this->checkConnection();
80 
82 
83  try {
84  Statement* stmt = m_conn->createStatement();
85  stmt->setSQL(
86  "SELECT cycle_id from ECAL_cycle_DAT "
87  "WHERE sequence_id = :id1 "
88  " and cycle_num = :id2 ");
89  stmt->setInt(1, m_sequence_id);
90  stmt->setInt(2, m_cycle_num);
91 
92  ResultSet* rset = stmt->executeQuery();
93 
94  if (rset->next()) {
95  m_ID = rset->getInt(1);
96  } else {
97  m_ID = 0;
98  }
99  m_conn->terminateStatement(stmt);
100  } catch (SQLException& e) {
101  throw(std::runtime_error("ODRunConfigCycleInfo::fetchID: " + e.getMessage()));
102  }
103  setByID(m_ID);
104 
105  return m_ID;
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
oracle::occi::Statement Statement
Definition: IODConfig.h:21
void setByID(int id) noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
tuple dh
Definition: cuy.py:354
int ODRunConfigCycleInfo::fetchIDLast ( )
privatenoexcept

Definition at line 108 of file ODRunConfigCycleInfo.cc.

References cuy::dh, and alignCSCRings::e.

108  {
109  this->checkConnection();
110 
112 
113  try {
114  Statement* stmt = m_conn->createStatement();
115  stmt->setSQL("SELECT max(cycle_id) FROM ecal_cycle_dat ");
116  ResultSet* rset = stmt->executeQuery();
117 
118  if (rset->next()) {
119  m_ID = rset->getInt(1);
120  } else {
121  m_ID = 0;
122  }
123  m_conn->terminateStatement(stmt);
124  } catch (SQLException& e) {
125  throw(std::runtime_error("ODRunConfigCycleInfo::fetchIDLast: " + e.getMessage()));
126  }
127 
128  setByID(m_ID);
129  return m_ID;
130 }
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
oracle::occi::Statement Statement
Definition: IODConfig.h:21
void setByID(int id) noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
tuple dh
Definition: cuy.py:354
int ODRunConfigCycleInfo::getCycleNumber ( ) const
inline

Definition at line 36 of file ODRunConfigCycleInfo.h.

References m_cycle_num.

36 { return m_cycle_num; }
std::string ODRunConfigCycleInfo::getDescription ( ) const
inline

Definition at line 27 of file ODRunConfigCycleInfo.h.

References m_description.

27 { return m_description; }
int ODRunConfigCycleInfo::getId ( void  ) const
inline

Definition at line 24 of file ODRunConfigCycleInfo.h.

References m_ID.

Referenced by ODEcalCycle::writeDB().

24 { return m_ID; }
int ODRunConfigCycleInfo::getSequenceID ( ) const
inline

Definition at line 33 of file ODRunConfigCycleInfo.h.

References m_sequence_id.

std::string ODRunConfigCycleInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 20 of file ODRunConfigCycleInfo.h.

20 { return "ECAL_CYCLE_DAT"; }
std::string ODRunConfigCycleInfo::getTag ( ) const
inline

Definition at line 30 of file ODRunConfigCycleInfo.h.

References m_tag.

30 { return m_tag; }
void ODRunConfigCycleInfo::insertConfig ( )
privatenoexcept

Definition at line 186 of file ODRunConfigCycleInfo.cc.

References alignCSCRings::e.

Referenced by ODEcalCycle::writeDB().

186  {
187  try {
188  prepareWrite();
189  writeDB();
190  m_conn->commit();
192  } catch (std::runtime_error& e) {
193  m_conn->rollback();
194  throw(e);
195  } catch (...) {
196  m_conn->rollback();
197  throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught"));
198  }
199 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void writeDB() noexcept(false)
void terminateWriteStatement() noexcept(false)
Definition: IODConfig.h:42
void prepareWrite() noexcept(false) override
bool ODRunConfigCycleInfo::operator!= ( const ODRunConfigCycleInfo r) const
inline

Definition at line 41 of file ODRunConfigCycleInfo.h.

References alignCSCRings::r.

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

Definition at line 40 of file ODRunConfigCycleInfo.h.

References m_ID.

40 { return (m_ID == r.m_ID); }
void ODRunConfigCycleInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 34 of file ODRunConfigCycleInfo.cc.

References alignCSCRings::e.

34  {
35  this->checkConnection();
36 
37  try {
38  m_writeStmt = m_conn->createStatement();
39  m_writeStmt->setSQL(
40  "INSERT INTO ECAL_CYCLE_DAT ( sequence_id , cycle_num, tag, description ) "
41  "VALUES (:1, :2, :3 , :4 )");
42 
43  } catch (SQLException& e) {
44  throw(std::runtime_error("ODRunConfigCycleInfo::prepareWrite(): " + e.getMessage()));
45  }
46 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
void ODRunConfigCycleInfo::setByID ( int  id)
privatenoexcept

Definition at line 132 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout, cuy::dh, alignCSCRings::e, and gpuClustering::id.

132  {
133  this->checkConnection();
134 
136 
137  cout << "ODRunConfigCycleInfo::setByID called for id " << id << endl;
138 
139  try {
140  Statement* stmt = m_conn->createStatement();
141 
142  stmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
143  stmt->setInt(1, id);
144 
145  ResultSet* rset = stmt->executeQuery();
146  if (rset->next()) {
147  m_sequence_id = rset->getInt(1);
148  m_cycle_num = rset->getInt(2);
149  m_tag = rset->getString(3);
150  m_description = rset->getString(4);
151  m_ID = id;
152  } else {
153  throw(std::runtime_error("ODRunConfigCycleInfo::setByID: Given cycle_id is not in the database"));
154  }
155  m_conn->terminateStatement(stmt);
156  } catch (SQLException& e) {
157  throw(std::runtime_error("ODRunConfigCycleInfo::setByID: " + e.getMessage()));
158  }
159 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
uint16_t *__restrict__ id
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
tuple cout
Definition: gather_cfg.py:144
tuple dh
Definition: cuy.py:354
void ODRunConfigCycleInfo::setCycleNumber ( int  n)
inline
void ODRunConfigCycleInfo::setDescription ( std::string  x)
inline

Definition at line 26 of file ODRunConfigCycleInfo.h.

References m_description, and x.

Referenced by ODEcalCycle::writeDB().

void ODRunConfigCycleInfo::setId ( int  id)
inline

Definition at line 23 of file ODRunConfigCycleInfo.h.

References gpuClustering::id, and m_ID.

23 { m_ID = id; }
uint16_t *__restrict__ id
void ODRunConfigCycleInfo::setSequenceID ( int  x)
inline

Definition at line 32 of file ODRunConfigCycleInfo.h.

References m_sequence_id, and x.

Referenced by ODEcalCycle::writeDB().

void ODRunConfigCycleInfo::setTag ( std::string  x)
inline

Definition at line 29 of file ODRunConfigCycleInfo.h.

References m_tag, and x.

Referenced by ODEcalCycle::writeDB().

29 { m_tag = x; }
void ODRunConfigCycleInfo::writeDB ( )
privatenoexcept

Definition at line 48 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout, cuy::dh, and alignCSCRings::e.

48  {
49  this->checkConnection();
50  this->checkPrepare();
51 
52  // Validate the data, use infinity-till convention
54 
55  try {
56  m_writeStmt->setInt(1, this->getSequenceID());
57  m_writeStmt->setInt(2, this->getCycleNumber());
58  m_writeStmt->setString(3, this->getTag());
59  m_writeStmt->setString(4, this->getDescription());
60  m_writeStmt->executeUpdate();
61 
62  } catch (SQLException& e) {
63  throw(std::runtime_error("ODRunConfigCycleInfo::writeDB: " + e.getMessage()));
64  }
65  // Now get the ID
66  if (!this->fetchID()) {
67  throw(std::runtime_error("ODRunConfigCycleInfo::writeDB: Failed to write"));
68  }
69 
70  cout << "ODRunConfigCycleInfo::writeDB>> done inserting ODRunConfigCycleInfo with id=" << m_ID << endl;
71 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getDescription() const
int fetchID() noexcept(false)
std::string getTag() const
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
tuple cout
Definition: gather_cfg.py:144
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
tuple dh
Definition: cuy.py:354

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file ODRunConfigCycleInfo.h.

friend class ODEcalCycle
friend

Definition at line 15 of file ODRunConfigCycleInfo.h.

Member Data Documentation

int ODRunConfigCycleInfo::m_cycle_num
private

Definition at line 47 of file ODRunConfigCycleInfo.h.

Referenced by getCycleNumber(), and setCycleNumber().

std::string ODRunConfigCycleInfo::m_description
private

Definition at line 49 of file ODRunConfigCycleInfo.h.

Referenced by getDescription(), and setDescription().

int ODRunConfigCycleInfo::m_ID
private

Definition at line 45 of file ODRunConfigCycleInfo.h.

Referenced by getId(), operator==(), and setId().

int ODRunConfigCycleInfo::m_sequence_id
private

Definition at line 46 of file ODRunConfigCycleInfo.h.

Referenced by getSequenceID(), and setSequenceID().

std::string ODRunConfigCycleInfo::m_tag
private

Definition at line 48 of file ODRunConfigCycleInfo.h.

Referenced by getTag(), and setTag().