CMS 3D CMS Logo

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

#include <ODJBH4Cycle.h>

Inheritance diagram for ODJBH4Cycle:
IODConfig IDBObject

Public Member Functions

int getId () const
 
int getJBH4ConfigurationID () const
 
std::string getTable () override
 
 ODJBH4Cycle ()
 
bool operator!= (const ODJBH4Cycle &m) const
 
bool operator== (const ODJBH4Cycle &m) const
 
void setId (int id)
 
void setJBH4ConfigurationID (int x)
 
 ~ODJBH4Cycle () 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 (ODJBH4Cycle *result) noexcept(false)
 
int fetchID () 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_ID
 
int m_jbh4_config_id
 

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 11 of file ODJBH4Cycle.h.

Constructor & Destructor Documentation

ODJBH4Cycle::ODJBH4Cycle ( )

Definition at line 9 of file ODJBH4Cycle.cc.

10 {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15  //
16  m_ID = 0;
17  m_jbh4_config_id = 0;
18 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
int m_jbh4_config_id
Definition: ODJBH4Cycle.h:35
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
Statement * m_readStmt
Definition: IODConfig.h:37
ODJBH4Cycle::~ODJBH4Cycle ( )
override

Definition at line 21 of file ODJBH4Cycle.cc.

22 {
23 }

Member Function Documentation

void ODJBH4Cycle::clear ( void  )
private

Definition at line 66 of file ODJBH4Cycle.cc.

66  {
68 }
int m_jbh4_config_id
Definition: ODJBH4Cycle.h:35
void ODJBH4Cycle::fetchData ( ODJBH4Cycle result)
privatenoexcept

Definition at line 131 of file ODJBH4Cycle.cc.

References MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

133 {
134  this->checkConnection();
135  result->clear();
136 
137  if(result->getId()==0){
138  throw(std::runtime_error("ODJBH4Config::fetchData(): no Id defined for this ODJBH4Config "));
139  }
140 
141  try {
142 
143  m_readStmt->setSQL("SELECT jbh4_configuration_id FROM ecal_jbh4_cycle "
144  "WHERE cycle_id = :1 ");
145 
146  m_readStmt->setInt(1, result->getId());
147  ResultSet* rset = m_readStmt->executeQuery();
148 
149  rset->next();
150 
151  result->setJBH4ConfigurationID( rset->getInt(1) );
152 
153  } catch (SQLException &e) {
154  throw(std::runtime_error(std::string("ODJBH4Cycle::fetchData(): ")+getOraMessage(&e)));
155  }
156 }
void setJBH4ConfigurationID(int x)
Definition: ODJBH4Cycle.h:25
int getId() const
Definition: ODJBH4Cycle.h:22
void clear()
Definition: ODJBH4Cycle.cc:66
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
int ODJBH4Cycle::fetchID ( )
privatenoexcept

Definition at line 71 of file ODJBH4Cycle.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

73 {
74  // Return from memory if available
75  if (m_ID) {
76  return m_ID;
77  }
78 
79  this->checkConnection();
80 
81  try {
82  Statement* stmt = m_conn->createStatement();
83  stmt->setSQL("SELECT cycle_id, jbh4_configuration_id FROM ecal_jbh4_cycle "
84  "WHERE cycle_id = :1 ");
85  stmt->setInt(1, m_ID);
86  ResultSet* rset = stmt->executeQuery();
87 
88  if (rset->next()) {
89  m_ID = rset->getInt(1);
90  m_jbh4_config_id = rset->getInt(2);
91  } else {
92  m_ID = 0;
93  }
94  m_conn->terminateStatement(stmt);
95  } catch (SQLException &e) {
96  throw(std::runtime_error(std::string("ODJBH4Cycle::fetchID: ")+getOraMessage(&e)));
97  }
98 
99  return m_ID;
100 }
int m_jbh4_config_id
Definition: ODJBH4Cycle.h:35
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int ODJBH4Cycle::getId ( void  ) const
inline

Definition at line 22 of file ODJBH4Cycle.h.

References m_ID.

22 { return m_ID;} ;
int ODJBH4Cycle::getJBH4ConfigurationID ( ) const
inline

Definition at line 26 of file ODJBH4Cycle.h.

References m_jbh4_config_id.

26 {return m_jbh4_config_id;}
int m_jbh4_config_id
Definition: ODJBH4Cycle.h:35
std::string ODJBH4Cycle::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file ODJBH4Cycle.h.

19 { return "ECAL_JBH4_CYCLE"; }
void ODJBH4Cycle::insertConfig ( )
privatenoexcept

Definition at line 158 of file ODJBH4Cycle.cc.

References MillePedeFileConverter_cfg::e, and GlobalTrackerMuonAlignment_cfi::writeDB.

Referenced by ODEcalCycle::writeDB().

160 {
161  try {
162 
163  prepareWrite();
164  writeDB();
165  m_conn->commit();
167  } catch (std::runtime_error &e) {
168  m_conn->rollback();
169  throw(e);
170  } catch (...) {
171  m_conn->rollback();
172  throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught"));
173  }
174 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void terminateWriteStatement() noexcept(false)
Definition: IODConfig.h:46
void writeDB() noexcept(false)
Definition: ODJBH4Cycle.cc:41
void prepareWrite() noexcept(false) override
Definition: ODJBH4Cycle.cc:26
bool ODJBH4Cycle::operator!= ( const ODJBH4Cycle m) const
inline

Definition at line 30 of file ODJBH4Cycle.h.

References funct::m.

30 { return !(*this == m); }
bool ODJBH4Cycle::operator== ( const ODJBH4Cycle m) const
inline

Definition at line 29 of file ODJBH4Cycle.h.

References m_ID.

29 { return ( m_ID == m.m_ID); }
void ODJBH4Cycle::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 26 of file ODJBH4Cycle.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

28 {
29  this->checkConnection();
30 
31  try {
32  m_writeStmt = m_conn->createStatement();
33  m_writeStmt->setSQL("INSERT INTO ECAL_JBH4_Cycle (cycle_id, jbh4_configuration_id ) "
34  "VALUES (:1, :2 )");
35  } catch (SQLException &e) {
36  throw(std::runtime_error(std::string("ODJBH4Cycle::prepareWrite(): ")+getOraMessage(&e)));
37  }
38 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODJBH4Cycle::setByID ( int  id)
privatenoexcept

Definition at line 104 of file ODJBH4Cycle.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

106 {
107  this->checkConnection();
108 
109 
110  try {
111  Statement* stmt = m_conn->createStatement();
112  stmt->setSQL("SELECT cycle_id, jbh4_configuration_id FROM ecal_jbh4_cycle "
113  "WHERE cycle_id = :1 ");
114  stmt->setInt(1, id);
115  ResultSet* rset = stmt->executeQuery();
116 
117  if (rset->next()) {
118  m_ID = rset->getInt(1);
119  m_jbh4_config_id = rset->getInt(2);
120  } else {
121  m_ID = 0;
122  }
123  m_conn->terminateStatement(stmt);
124  } catch (SQLException &e) {
125  throw(std::runtime_error(std::string("ODJBH4Cycle::fetchID: ")+getOraMessage(&e)));
126  }
127 }
int m_jbh4_config_id
Definition: ODJBH4Cycle.h:35
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODJBH4Cycle::setId ( int  id)
inline

Definition at line 21 of file ODJBH4Cycle.h.

References triggerObjects_cff::id, and m_ID.

Referenced by ODEcalCycle::writeDB().

void ODJBH4Cycle::setJBH4ConfigurationID ( int  x)
inline

Definition at line 25 of file ODJBH4Cycle.h.

References m_jbh4_config_id, and x.

Referenced by ODEcalCycle::writeDB().

void ODJBH4Cycle::writeDB ( )
privatenoexcept

Definition at line 41 of file ODJBH4Cycle.cc.

References MillePedeFileConverter_cfg::e, getId(), and AlCaHLTBitMon_QueryRunRegistry::string.

42 {
43  this->checkConnection();
44  this->checkPrepare();
45 
46  try {
47 
48  m_writeStmt->setInt(1, this->getId());
49  m_writeStmt->setInt(2, this->getJBH4ConfigurationID());
50 
51  m_writeStmt->executeUpdate();
52 
53 
54  } catch (SQLException &e) {
55  throw(std::runtime_error(std::string("ODJBH4Cycle::writeDB: ")+getOraMessage(&e)));
56  }
57 
58  // Now get the ID
59  if (!this->fetchID()) {
60  throw(std::runtime_error("ODJBH4Cycle::writeDB: Failed to write"));
61  }
62 
63 
64 }
Statement * m_writeStmt
Definition: IODConfig.h:36
int fetchID() noexcept(false)
Definition: ODJBH4Cycle.cc:71
int getId() const
Definition: ODJBH4Cycle.h:22
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int getJBH4ConfigurationID() const
Definition: ODJBH4Cycle.h:26
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file ODJBH4Cycle.h.

friend class ODEcalCycle
friend

Definition at line 14 of file ODJBH4Cycle.h.

Member Data Documentation

int ODJBH4Cycle::m_ID
private

Definition at line 34 of file ODJBH4Cycle.h.

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

int ODJBH4Cycle::m_jbh4_config_id
private

Definition at line 35 of file ODJBH4Cycle.h.

Referenced by getJBH4ConfigurationID(), and setJBH4ConfigurationID().