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
ODCCSCycle Class Reference

#include <ODCCSCycle.h>

Inheritance diagram for ODCCSCycle:
IODConfig IDBObject

Public Member Functions

int getCCSConfigurationID () const
 
int getId () const
 
std::string getTable ()
 
 ODCCSCycle ()
 
bool operator!= (const ODCCSCycle &m) const
 
bool operator== (const ODCCSCycle &m) const
 
void setCCSConfigurationID (int x)
 
void setId (int id)
 
 ~ODCCSCycle ()
 
- 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 (ODCCSCycle *result) throw (std::runtime_error)
 
int fetchID () 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_ccs_config_id
 
int m_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 () 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 11 of file ODCCSCycle.h.

Constructor & Destructor Documentation

ODCCSCycle::ODCCSCycle ( )

Definition at line 9 of file ODCCSCycle.cc.

References NULL.

10 {
11  m_env = NULL;
12  m_conn = NULL;
13  m_writeStmt = NULL;
14  m_readStmt = NULL;
15  //
16  m_ID = 0;
17  m_ccs_config_id = 0;
18 }
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
int m_ccs_config_id
Definition: ODCCSCycle.h:37
#define NULL
Definition: scimark2.h:8
Statement * m_readStmt
Definition: IODConfig.h:37
ODCCSCycle::~ODCCSCycle ( )

Definition at line 21 of file ODCCSCycle.cc.

22 {
23 }

Member Function Documentation

void ODCCSCycle::clear ( void  )
private

Definition at line 66 of file ODCCSCycle.cc.

66  {
68 }
int m_ccs_config_id
Definition: ODCCSCycle.h:37
void ODCCSCycle::fetchData ( ODCCSCycle result)
throw (std::runtime_error
)
private

Definition at line 131 of file ODCCSCycle.cc.

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

133 {
134  this->checkConnection();
135  result->clear();
136 
137  if(result->getId()==0){
138  throw(std::runtime_error("ODCCSConfig::fetchData(): no Id defined for this ODCCSConfig "));
139  }
140 
141  try {
142 
143  m_readStmt->setSQL("SELECT ccs_configuration_id FROM ecal_ccs_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->setCCSConfigurationID( rset->getInt(1) );
152 
153  } catch (SQLException &e) {
154  throw(std::runtime_error("ODCCSCycle::fetchData(): "+e.getMessage()));
155  }
156 }
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void clear()
Definition: ODCCSCycle.cc:66
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
void setCCSConfigurationID(int x)
Definition: ODCCSCycle.h:25
int getId() const
Definition: ODCCSCycle.h:22
void checkConnection() const
Definition: IDBObject.h:41
int ODCCSCycle::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 71 of file ODCCSCycle.cc.

References alignCSCRings::e.

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, ccs_configuration_id FROM ecal_ccs_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_ccs_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("ODCCSCycle::fetchID: "+e.getMessage()));
97  }
98 
99  return m_ID;
100 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int m_ccs_config_id
Definition: ODCCSCycle.h:37
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
Definition: IDBObject.h:41
int ODCCSCycle::getCCSConfigurationID ( ) const
inline

Definition at line 26 of file ODCCSCycle.h.

References m_ccs_config_id.

26 {return m_ccs_config_id;}
int m_ccs_config_id
Definition: ODCCSCycle.h:37
int ODCCSCycle::getId ( ) const
inline

Definition at line 22 of file ODCCSCycle.h.

References m_ID.

22 { return m_ID;} ;
std::string ODCCSCycle::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 19 of file ODCCSCycle.h.

19 { return "ECAL_CCS_CYCLE"; }
void ODCCSCycle::insertConfig ( )
throw (std::runtime_error
)
private

Definition at line 158 of file ODCCSCycle.cc.

References alignCSCRings::e.

Referenced by ODEcalCycle::writeDB().

160 {
161  try {
162 
163  prepareWrite();
164  writeDB();
166  } catch (SQLException &e) {
167  throw(std::runtime_error("EcalCondDBInterface::insertDataSet: Unknown exception caught"));
168  }
169 }
void writeDB()
Definition: ODCCSCycle.cc:41
void terminateWriteStatement()
Definition: IODConfig.h:47
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void prepareWrite()
Definition: ODCCSCycle.cc:26
bool ODCCSCycle::operator!= ( const ODCCSCycle m) const
inline

Definition at line 30 of file ODCCSCycle.h.

References visualization-live-secondInstance_cfg::m.

bool ODCCSCycle::operator== ( const ODCCSCycle m) const
inline

Definition at line 29 of file ODCCSCycle.h.

References m_ID.

29 { return ( m_ID == m.m_ID); }
void ODCCSCycle::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 26 of file ODCCSCycle.cc.

References alignCSCRings::e.

28 {
29  this->checkConnection();
30 
31  try {
32  m_writeStmt = m_conn->createStatement();
33  m_writeStmt->setSQL("INSERT INTO ECAL_CCS_Cycle (cycle_id, ccs_configuration_id ) "
34  "VALUES (:1, :2 )");
35  } catch (SQLException &e) {
36  throw(std::runtime_error("ODCCSCycle::prepareWrite(): "+e.getMessage()));
37  }
38 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void ODCCSCycle::setByID ( int  id)
throw (std::runtime_error
)
private

Definition at line 104 of file ODCCSCycle.cc.

References alignCSCRings::e.

106 {
107  this->checkConnection();
108 
109 
110  try {
111  Statement* stmt = m_conn->createStatement();
112  stmt->setSQL("SELECT cycle_id, ccs_configuration_id FROM ecal_ccs_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_ccs_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("ODCCSCycle::fetchID: "+e.getMessage()));
126  }
127 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int m_ccs_config_id
Definition: ODCCSCycle.h:37
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
Definition: IDBObject.h:41
void ODCCSCycle::setCCSConfigurationID ( int  x)
inline

Definition at line 25 of file ODCCSCycle.h.

References m_ccs_config_id, and x.

Referenced by ODEcalCycle::writeDB().

void ODCCSCycle::setId ( int  id)
inline

Definition at line 21 of file ODCCSCycle.h.

References m_ID.

Referenced by ODEcalCycle::writeDB().

21 {m_ID=id;}
void ODCCSCycle::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 41 of file ODCCSCycle.cc.

References alignCSCRings::e, and getId().

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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file ODCCSCycle.h.

friend class ODEcalCycle
friend

Definition at line 14 of file ODCCSCycle.h.

Member Data Documentation

int ODCCSCycle::m_ccs_config_id
private

Definition at line 37 of file ODCCSCycle.h.

Referenced by getCCSConfigurationID(), and setCCSConfigurationID().

int ODCCSCycle::m_ID
private

Definition at line 36 of file ODCCSCycle.h.

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