CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 ()
 
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 ()
 
- 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) throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
int fetchIDLast () throw (std::runtime_error)
 
void insertConfig () throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void setByID (int id) throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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.

References NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
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
#define NULL
Definition: scimark2.h:8
Statement * m_readStmt
Definition: IODConfig.h:37
ODRunConfigCycleInfo::~ODRunConfigCycleInfo ( )

Definition at line 29 of file ODRunConfigCycleInfo.cc.

29 {}

Member Function Documentation

void ODRunConfigCycleInfo::clear ( void  )
private
void ODRunConfigCycleInfo::fetchData ( ODRunConfigCycleInfo result)
throw (std::runtime_error
)
private

Definition at line 191 of file ODRunConfigCycleInfo.cc.

References query::result.

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( rset->getString(3) );
211  result->setDescription( rset->getString(4) );
212 
213  } catch (SQLException &e) {
214  throw(std::runtime_error("ODRunConfigCycleInfo::fetchData(): "+e.getMessage()));
215  }
216 }
void setDescription(std::string x)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setTag(std::string x)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
int ODRunConfigCycleInfo::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 92 of file ODRunConfigCycleInfo.cc.

94 {
95  // Return from memory if available
96  if (m_ID>0) {
97  return m_ID;
98  }
99 
100  this->checkConnection();
101 
102 
103  DateHandler dh(m_env, m_conn);
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("ODRunConfigCycleInfo::fetchID: "+e.getMessage()));
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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
int ODRunConfigCycleInfo::fetchIDLast ( )
throw (std::runtime_error
)
private

Definition at line 131 of file ODRunConfigCycleInfo.cc.

133 {
134 
135  this->checkConnection();
136 
137  DateHandler dh(m_env, m_conn);
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("ODRunConfigCycleInfo::fetchIDLast: "+e.getMessage()));
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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
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 ( ) 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 ( )
inlinevirtual

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 ( )
throw (std::runtime_error
)
private

Definition at line 218 of file ODRunConfigCycleInfo.cc.

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 terminateWriteStatement()
Definition: IODConfig.h:47
bool ODRunConfigCycleInfo::operator!= ( const ODRunConfigCycleInfo r) const
inline

Definition at line 47 of file ODRunConfigCycleInfo.h.

References csvReporter::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 ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 40 of file ODRunConfigCycleInfo.cc.

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("ODRunConfigCycleInfo::prepareWrite(): "+e.getMessage()));
52  }
53 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
void ODRunConfigCycleInfo::setByID ( int  id)
throw (std::runtime_error
)
private

Definition at line 159 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout.

161 {
162  this->checkConnection();
163 
164  DateHandler dh(m_env, m_conn);
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 = rset->getString(3);
179  m_description= rset->getString(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("ODRunConfigCycleInfo::setByID: "+e.getMessage()));
187  }
188 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41
void checkConnection() const
Definition: IDBObject.h:41
void ODRunConfigCycleInfo::setCycleNumber ( int  n)
inline

Definition at line 39 of file ODRunConfigCycleInfo.h.

References m_cycle_num, and 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().

30 { m_description = x;}
Definition: DDAxes.h:10
void ODRunConfigCycleInfo::setId ( int  id)
inline

Definition at line 25 of file ODRunConfigCycleInfo.h.

References m_ID.

25 { m_ID = id; }
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().

33 { m_tag = x;}
Definition: DDAxes.h:10
void ODRunConfigCycleInfo::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 56 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout.

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("ODRunConfigCycleInfo::writeDB: "+e.getMessage()));
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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkPrepare()
Definition: IODConfig.h:39
std::string getTag() const
tuple cout
Definition: gather_cfg.py:41
void checkConnection() const
Definition: IDBObject.h:41

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().