CMS 3D CMS Logo

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 14 of file ODRunConfigCycleInfo.h.

Constructor & Destructor Documentation

ODRunConfigCycleInfo::ODRunConfigCycleInfo ( )

Definition at line 12 of file ODRunConfigCycleInfo.cc.

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

Definition at line 29 of file ODRunConfigCycleInfo.cc.

29 {}

Member Function Documentation

void ODRunConfigCycleInfo::clear ( void  )
private

Definition at line 32 of file ODRunConfigCycleInfo.cc.

32  {
33  m_sequence_id =0;
34  m_cycle_num =0;
35  m_tag = "";
36  m_description="";
37 
38 }
void ODRunConfigCycleInfo::fetchData ( ODRunConfigCycleInfo result)
privatenoexcept

Definition at line 191 of file ODRunConfigCycleInfo.cc.

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

193 {
194  this->checkConnection();
195  result->clear();
196  if(result->getId()==0){
197  throw(std::runtime_error("ODRunConfigCycleInfo::fetchData(): no Id defined for this ODRunConfigCycleInfo "));
198  }
199 
200  try {
201  m_readStmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
202 
203  m_readStmt->setInt(1, result->getId());
204  ResultSet* rset = m_readStmt->executeQuery();
205 
206  rset->next();
207 
208  result->setSequenceID( rset->getInt(1) );
209  result->setCycleNumber( rset->getInt(2) );
210  result->setTag( getOraString(rset,3) );
211  result->setDescription( getOraString(rset,4) );
212 
213  } catch (SQLException &e) {
214  throw(std::runtime_error(std::string("ODRunConfigCycleInfo::fetchData(): ")+getOraMessage(&e)));
215  }
216 }
void setDescription(std::string x)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setTag(std::string x)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
int ODRunConfigCycleInfo::fetchID ( )
privatenoexcept

Definition at line 92 of file ODRunConfigCycleInfo.cc.

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

94 {
95  // Return from memory if available
96  if (m_ID>0) {
97  return m_ID;
98  }
99 
100  this->checkConnection();
101 
102 
104 
105  try {
106  Statement* stmt = m_conn->createStatement();
107  stmt->setSQL("SELECT cycle_id from ECAL_cycle_DAT "
108  "WHERE sequence_id = :id1 "
109  " and cycle_num = :id2 " );
110  stmt->setInt(1, m_sequence_id);
111  stmt->setInt(2, m_cycle_num);
112 
113  ResultSet* rset = stmt->executeQuery();
114 
115  if (rset->next()) {
116  m_ID = rset->getInt(1);
117  } else {
118  m_ID = 0;
119  }
120  m_conn->terminateStatement(stmt);
121  } catch (SQLException &e) {
122  throw(std::runtime_error(std::string("ODRunConfigCycleInfo::fetchID: ")+getOraMessage(&e)));
123  }
124  setByID(m_ID);
125 
126  return m_ID;
127 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
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
void setByID(int id) noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
dh
Definition: cuy.py:355
int ODRunConfigCycleInfo::fetchIDLast ( )
privatenoexcept

Definition at line 131 of file ODRunConfigCycleInfo.cc.

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

133 {
134 
135  this->checkConnection();
136 
138 
139  try {
140  Statement* stmt = m_conn->createStatement();
141  stmt->setSQL("SELECT max(cycle_id) FROM ecal_cycle_dat " );
142  ResultSet* rset = stmt->executeQuery();
143 
144  if (rset->next()) {
145  m_ID = rset->getInt(1);
146  } else {
147  m_ID = 0;
148  }
149  m_conn->terminateStatement(stmt);
150  } catch (SQLException &e) {
151  throw(std::runtime_error(std::string("ODRunConfigCycleInfo::fetchIDLast: ")+getOraMessage(&e)));
152  }
153 
154  setByID(m_ID);
155  return m_ID;
156 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
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
void setByID(int id) noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
dh
Definition: cuy.py:355
int ODRunConfigCycleInfo::getCycleNumber ( ) const
inline

Definition at line 40 of file ODRunConfigCycleInfo.h.

References m_cycle_num.

std::string ODRunConfigCycleInfo::getDescription ( ) const
inline

Definition at line 31 of file ODRunConfigCycleInfo.h.

References m_description.

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

Definition at line 26 of file ODRunConfigCycleInfo.h.

References m_ID.

Referenced by ODEcalCycle::writeDB().

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

Definition at line 37 of file ODRunConfigCycleInfo.h.

References m_sequence_id.

std::string ODRunConfigCycleInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODRunConfigCycleInfo.h.

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

Definition at line 34 of file ODRunConfigCycleInfo.h.

References m_tag.

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

Definition at line 218 of file ODRunConfigCycleInfo.cc.

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

Referenced by ODEcalCycle::writeDB().

220 {
221  try {
222 
223  prepareWrite();
224  writeDB();
225  m_conn->commit();
227  } catch (std::runtime_error &e) {
228  m_conn->rollback();
229  throw(e);
230  } catch (...) {
231  m_conn->rollback();
232  throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught"));
233  }
234 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void writeDB() noexcept(false)
void terminateWriteStatement() noexcept(false)
Definition: IODConfig.h:46
void prepareWrite() noexcept(false) override
bool ODRunConfigCycleInfo::operator!= ( const ODRunConfigCycleInfo r) const
inline

Definition at line 47 of file ODRunConfigCycleInfo.h.

References alignCSCRings::r.

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

Definition at line 46 of file ODRunConfigCycleInfo.h.

References m_ID.

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

Implements IODConfig.

Definition at line 40 of file ODRunConfigCycleInfo.cc.

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

42 {
43  this->checkConnection();
44 
45  try {
46  m_writeStmt = m_conn->createStatement();
47  m_writeStmt->setSQL("INSERT INTO ECAL_CYCLE_DAT ( sequence_id , cycle_num, tag, description ) "
48  "VALUES (:1, :2, :3 , :4 )");
49 
50  } catch (SQLException &e) {
51  throw(std::runtime_error(std::string("ODRunConfigCycleInfo::prepareWrite(): ")+getOraMessage(&e)));
52  }
53 }
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 ODRunConfigCycleInfo::setByID ( int  id)
privatenoexcept

Definition at line 159 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, triggerObjects_cff::id, and AlCaHLTBitMon_QueryRunRegistry::string.

161 {
162  this->checkConnection();
163 
165 
166  cout<< "ODRunConfigCycleInfo::setByID called for id "<<id<<endl;
167 
168  try {
169  Statement* stmt = m_conn->createStatement();
170 
171  stmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
172  stmt->setInt(1, id);
173 
174  ResultSet* rset = stmt->executeQuery();
175  if (rset->next()) {
176  m_sequence_id=rset->getInt(1);
177  m_cycle_num=rset->getInt(2);
178  m_tag = getOraString(rset,3);
179  m_description= getOraString(rset,4);
180  m_ID = id;
181  } else {
182  throw(std::runtime_error("ODRunConfigCycleInfo::setByID: Given cycle_id is not in the database"));
183  }
184  m_conn->terminateStatement(stmt);
185  } catch (SQLException &e) {
186  throw(std::runtime_error(std::string("ODRunConfigCycleInfo::setByID: ")+getOraMessage(&e)));
187  }
188 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
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
dh
Definition: cuy.py:355
void ODRunConfigCycleInfo::setCycleNumber ( int  n)
inline

Definition at line 39 of file ODRunConfigCycleInfo.h.

References m_cycle_num, and gen::n.

Referenced by ODEcalCycle::writeDB().

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

Definition at line 30 of file ODRunConfigCycleInfo.h.

References m_description, and x.

Referenced by ODEcalCycle::writeDB().

void ODRunConfigCycleInfo::setId ( int  id)
inline
void ODRunConfigCycleInfo::setSequenceID ( int  x)
inline

Definition at line 36 of file ODRunConfigCycleInfo.h.

References m_sequence_id, and x.

Referenced by ODEcalCycle::writeDB().

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

Definition at line 33 of file ODRunConfigCycleInfo.h.

References m_tag, and x.

Referenced by ODEcalCycle::writeDB().

void ODRunConfigCycleInfo::writeDB ( )
privatenoexcept

Definition at line 56 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout, cuy::dh, MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

58 {
59  this->checkConnection();
60  this->checkPrepare();
61 
62  // Validate the data, use infinity-till convention
64 
65  try {
66 
67  m_writeStmt->setInt(1, this->getSequenceID());
68  m_writeStmt->setInt(2, this->getCycleNumber());
69  m_writeStmt->setString(3, this->getTag());
70  m_writeStmt->setString(4, this->getDescription());
71  m_writeStmt->executeUpdate();
72 
73 
74 
75  } catch (SQLException &e) {
76  throw(std::runtime_error(std::string("ODRunConfigCycleInfo::writeDB: ")+getOraMessage(&e)));
77  }
78  // Now get the ID
79  if (!this->fetchID()) {
80  throw(std::runtime_error("ODRunConfigCycleInfo::writeDB: Failed to write"));
81  }
82 
83  cout<< "ODRunConfigCycleInfo::writeDB>> done inserting ODRunConfigCycleInfo with id="<<m_ID<<endl;
84 
85 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getDescription() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)
std::string getTag() const
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
dh
Definition: cuy.py:355
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 16 of file ODRunConfigCycleInfo.h.

friend class ODEcalCycle
friend

Definition at line 17 of file ODRunConfigCycleInfo.h.

Member Data Documentation

int ODRunConfigCycleInfo::m_cycle_num
private

Definition at line 53 of file ODRunConfigCycleInfo.h.

Referenced by getCycleNumber(), and setCycleNumber().

std::string ODRunConfigCycleInfo::m_description
private

Definition at line 55 of file ODRunConfigCycleInfo.h.

Referenced by getDescription(), and setDescription().

int ODRunConfigCycleInfo::m_ID
private

Definition at line 51 of file ODRunConfigCycleInfo.h.

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

int ODRunConfigCycleInfo::m_sequence_id
private

Definition at line 52 of file ODRunConfigCycleInfo.h.

Referenced by getSequenceID(), and setSequenceID().

std::string ODRunConfigCycleInfo::m_tag
private

Definition at line 54 of file ODRunConfigCycleInfo.h.

Referenced by getTag(), and setTag().