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

#include <ODRunConfigSeqInfo.h>

Inheritance diagram for ODRunConfigSeqInfo:
IODConfig IDBObject

Public Member Functions

std::string getDescription () const
 
int getEcalConfigId () const
 
int getId () const
 
int getNumberOfCycles () const
 
RunSeqDef getRunSeqDef () const
 
int getSequenceId () const
 
int getSequenceNumber () const
 
std::string getTable ()
 
 ODRunConfigSeqInfo ()
 
bool operator!= (const ODRunConfigSeqInfo &r) const
 
bool operator== (const ODRunConfigSeqInfo &r) const
 
void setDescription (std::string x)
 
void setEcalConfigId (int x)
 
void setId (int id)
 
void setNumberOfCycles (int x)
 
void setRunSeqDef (const RunSeqDef &runSeqDef)
 
void setSequenceId (int x)
 
void setSequenceNumber (int x)
 
 ~ODRunConfigSeqInfo ()
 
- 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 (ODRunConfigSeqInfo *result) throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
int fetchIDLast () 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_cycles
 
std::string m_description
 
int m_ecal_config_id
 
int m_ID
 
RunSeqDef m_run_seq
 
int m_seq_num
 
int m_sequence_id
 

Friends

class EcalCondDBInterface
 

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 15 of file ODRunConfigSeqInfo.h.

Constructor & Destructor Documentation

ODRunConfigSeqInfo::ODRunConfigSeqInfo ( )

Definition at line 12 of file ODRunConfigSeqInfo.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  //
22  m_seq_num =0;
23  m_cycles =0;
24  m_run_seq = RunSeqDef();
25  m_description="";
26 }
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
ODRunConfigSeqInfo::~ODRunConfigSeqInfo ( )

Definition at line 28 of file ODRunConfigSeqInfo.cc.

28 {}

Member Function Documentation

void ODRunConfigSeqInfo::clear ( void  )
private

Definition at line 197 of file ODRunConfigSeqInfo.cc.

197  {
198  // m_ecal_config_id =0;
199  // m_seq_num =0;
200  m_ID =0;
201  m_cycles =0;
202  m_run_seq = RunSeqDef();
203  m_description="";
204 }
void ODRunConfigSeqInfo::fetchData ( ODRunConfigSeqInfo result)
throw (std::runtime_error
)
private

Definition at line 207 of file ODRunConfigSeqInfo.cc.

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

209 {
210  this->checkConnection();
211  // result->clear();
212  if(result->getId()==0){
213  // throw(std::runtime_error("ODRunConfigSeqInfo::fetchData(): no Id defined for this record "));
214  result->fetchID();
215  }
216 
217  try {
218 
219  m_readStmt->setSQL("SELECT ecal_config_id, sequence_num, num_of_cycles, "
220  "sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
221 
222  m_readStmt->setInt(1, result->getId());
223  ResultSet* rset = m_readStmt->executeQuery();
224 
225  rset->next();
226 
227  result->setEcalConfigId( rset->getInt(1) );
228  result->setSequenceNumber( rset->getInt(2) );
229  result->setNumberOfCycles( rset->getInt(3) );
230  int seq_def_id=rset->getInt(4);
231 
233  m_run_seq.setByID(seq_def_id);
234  result->setDescription( rset->getString(5) );
235 
236 
237  } catch (SQLException &e) {
238  throw(std::runtime_error("ODRunConfigSeqInfo::fetchData(): "+e.getMessage()));
239  }
240 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setSequenceNumber(int x)
void setDescription(std::string x)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setNumberOfCycles(int x)
void setEcalConfigId(int x)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setByID(int id)
Definition: RunSeqDef.cc:86
void checkConnection() const
Definition: IDBObject.h:41
int ODRunConfigSeqInfo::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 43 of file ODRunConfigSeqInfo.cc.

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

45 {
46  // Return from memory if available
47  if (m_ID>0) {
48  return m_ID;
49  }
50 
51  this->checkConnection();
52 
53 
55 
56  try {
57  Statement* stmt = m_conn->createStatement();
58  stmt->setSQL("SELECT sequence_id from ECAL_sequence_DAT "
59  "WHERE ecal_config_id = :id1 "
60  " and sequence_num = :id2 " );
61  stmt->setInt(1, m_ecal_config_id);
62  stmt->setInt(2, m_seq_num);
63 
64  ResultSet* rset = stmt->executeQuery();
65 
66  if (rset->next()) {
67  m_ID = rset->getInt(1);
68  } else {
69  m_ID = 0;
70  }
71  m_conn->terminateStatement(stmt);
72  } catch (SQLException &e) {
73  throw(std::runtime_error("ODRunConfigSeqInfo::fetchID: "+e.getMessage()));
74  }
75  setByID(m_ID);
76  return m_ID;
77 }
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:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353
int ODRunConfigSeqInfo::fetchIDLast ( )
throw (std::runtime_error
)
private

Definition at line 81 of file ODRunConfigSeqInfo.cc.

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

83 {
84 
85  this->checkConnection();
86 
88 
89  try {
90  Statement* stmt = m_conn->createStatement();
91  stmt->setSQL("SELECT max(sequence_id) FROM ecal_sequence_dat " );
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("ODRunConfigSeqInfo::fetchIDLast: "+e.getMessage()));
102  }
103 
104  setByID(m_ID);
105  return m_ID;
106 }
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:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353
std::string ODRunConfigSeqInfo::getDescription ( ) const
inline

Definition at line 31 of file ODRunConfigSeqInfo.h.

References m_description.

31 { return m_description;}
int ODRunConfigSeqInfo::getEcalConfigId ( ) const
inline

Definition at line 33 of file ODRunConfigSeqInfo.h.

References m_ecal_config_id.

33 { return m_ecal_config_id;}
int ODRunConfigSeqInfo::getId ( ) const
inline

Definition at line 28 of file ODRunConfigSeqInfo.h.

References m_ID.

28 { return m_ID; }
int ODRunConfigSeqInfo::getNumberOfCycles ( ) const
inline

Definition at line 37 of file ODRunConfigSeqInfo.h.

References m_cycles.

37 {return m_cycles;}
RunSeqDef ODRunConfigSeqInfo::getRunSeqDef ( ) const

Definition at line 31 of file ODRunConfigSeqInfo.cc.

31 { return m_run_seq;}
int ODRunConfigSeqInfo::getSequenceId ( ) const
inline

Definition at line 36 of file ODRunConfigSeqInfo.h.

References m_ID.

Referenced by popcon::EcalSRPHandler::getNewObjects().

36 { return m_ID;}
int ODRunConfigSeqInfo::getSequenceNumber ( ) const
inline

Definition at line 39 of file ODRunConfigSeqInfo.h.

References m_seq_num.

39 {return m_seq_num;}
std::string ODRunConfigSeqInfo::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 22 of file ODRunConfigSeqInfo.h.

22 { return "ECAL_SEQUENCE_DAT"; }
bool ODRunConfigSeqInfo::operator!= ( const ODRunConfigSeqInfo r) const
inline

Definition at line 46 of file ODRunConfigSeqInfo.h.

References alignCSCRings::r.

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

Definition at line 45 of file ODRunConfigSeqInfo.h.

References m_ID.

45 { return (m_ID == r.m_ID ); }
void ODRunConfigSeqInfo::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 143 of file ODRunConfigSeqInfo.cc.

References alignCSCRings::e.

145 {
146  this->checkConnection();
147 
148  try {
149  m_writeStmt = m_conn->createStatement();
150  m_writeStmt->setSQL("INSERT INTO ECAL_SEQUENCE_DAT ( ecal_config_id, "
151  "sequence_num, num_of_cycles, sequence_type_def_id, description ) "
152  "VALUES (:1, :2, :3 , :4, :5 )");
153  } catch (SQLException &e) {
154  throw(std::runtime_error("ODRunConfigSeqInfo::prepareWrite(): "+e.getMessage()));
155  }
156 }
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 ODRunConfigSeqInfo::setByID ( int  id)
throw (std::runtime_error
)
private

Definition at line 109 of file ODRunConfigSeqInfo.cc.

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

111 {
112  this->checkConnection();
113 
115 
116  cout<< "ODRunConfigSeqInfo::setByID called for id "<<id<<endl;
117 
118  try {
119  Statement* stmt = m_conn->createStatement();
120 
121  stmt->setSQL("SELECT ecal_config_id, sequence_num, num_of_cycles, sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
122  stmt->setInt(1, id);
123 
124  ResultSet* rset = stmt->executeQuery();
125  if (rset->next()) {
126  m_ecal_config_id= rset->getInt(1);
127  m_seq_num=rset->getInt(2);
128  m_cycles=rset->getInt(3);
129  int seq_def_id=rset->getInt(4);
130  m_description= rset->getString(5);
131  m_ID = id;
133  m_run_seq.setByID(seq_def_id);
134  } else {
135  throw(std::runtime_error("ODRunConfigSeqInfo::setByID: Given config_id is not in the database"));
136  }
137  m_conn->terminateStatement(stmt);
138  } catch (SQLException &e) {
139  throw(std::runtime_error("ODRunConfigSeqInfo::setByID: "+e.getMessage()));
140  }
141 }
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:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple cout
Definition: gather_cfg.py:121
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setByID(int id)
Definition: RunSeqDef.cc:86
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353
void ODRunConfigSeqInfo::setDescription ( std::string  x)
inline

Definition at line 30 of file ODRunConfigSeqInfo.h.

References m_description, and x.

30 { m_description = x; }
Definition: DDAxes.h:10
void ODRunConfigSeqInfo::setEcalConfigId ( int  x)
inline

Definition at line 32 of file ODRunConfigSeqInfo.h.

References m_ecal_config_id, and x.

Referenced by popcon::EcalSRPHandler::getNewObjects().

32 { m_ecal_config_id = x; }
Definition: DDAxes.h:10
void ODRunConfigSeqInfo::setId ( int  id)
inline

Definition at line 27 of file ODRunConfigSeqInfo.h.

References m_ID.

27 { m_ID = id; }
void ODRunConfigSeqInfo::setNumberOfCycles ( int  x)
inline

Definition at line 34 of file ODRunConfigSeqInfo.h.

References m_cycles, and x.

34 { m_cycles = x; }
Definition: DDAxes.h:10
void ODRunConfigSeqInfo::setRunSeqDef ( const RunSeqDef runSeqDef)

Definition at line 32 of file ODRunConfigSeqInfo.cc.

33 {
34  if (run_seq != m_run_seq) {
35  m_run_seq = run_seq;
36  }
37 }
void ODRunConfigSeqInfo::setSequenceId ( int  x)
inline

Definition at line 35 of file ODRunConfigSeqInfo.h.

References m_ID, and x.

35 { m_ID = x; }
Definition: DDAxes.h:10
void ODRunConfigSeqInfo::setSequenceNumber ( int  x)
inline

Definition at line 38 of file ODRunConfigSeqInfo.h.

References m_seq_num, and x.

Referenced by popcon::EcalSRPHandler::getNewObjects().

void ODRunConfigSeqInfo::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 157 of file ODRunConfigSeqInfo.cc.

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

159 {
160  this->checkConnection();
161  this->checkPrepare();
162 
163 
164 
165  // Validate the data, use infinity-till convention
167 
168  try {
169 
170  // get the run mode
171 
172 
173 
175  int seq_def_id = m_run_seq.writeDB();
176 
177 
178  m_writeStmt->setInt(1, this->getEcalConfigId());
179  m_writeStmt->setInt(2, this->getSequenceNumber());
180  m_writeStmt->setInt(3, this->getNumberOfCycles());
181  m_writeStmt->setInt(4,seq_def_id );
182  m_writeStmt->setString(5,this->getDescription() );
183 
184  m_writeStmt->executeUpdate();
185 
186  } catch (SQLException &e) {
187  throw(std::runtime_error("ODRunConfigSeqInfo::writeDB(): "+e.getMessage()));
188  }
189  if (!this->fetchID()) {
190  throw(std::runtime_error("ODRunConfigSeqInfo::writeDB: Failed to write"));
191  }
192  cout<< "ODRunConfigSeqInfo::writeDB>> done inserting ODRunConfigSeqInfo with id="<<m_ID<<endl;
193 
194 }
int getNumberOfCycles() const
int getSequenceNumber() const
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
int getEcalConfigId() const
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int writeDB()
Definition: RunSeqDef.cc:139
std::string getDescription() const
void checkPrepare()
Definition: IODConfig.h:39
tuple cout
Definition: gather_cfg.py:121
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
tuple dh
Definition: cuy.py:353

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODRunConfigSeqInfo.h.

Member Data Documentation

int ODRunConfigSeqInfo::m_cycles
private

Definition at line 53 of file ODRunConfigSeqInfo.h.

Referenced by getNumberOfCycles(), and setNumberOfCycles().

std::string ODRunConfigSeqInfo::m_description
private

Definition at line 55 of file ODRunConfigSeqInfo.h.

Referenced by getDescription(), and setDescription().

int ODRunConfigSeqInfo::m_ecal_config_id
private

Definition at line 50 of file ODRunConfigSeqInfo.h.

Referenced by getEcalConfigId(), and setEcalConfigId().

int ODRunConfigSeqInfo::m_ID
private

Definition at line 49 of file ODRunConfigSeqInfo.h.

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

RunSeqDef ODRunConfigSeqInfo::m_run_seq
private

Definition at line 54 of file ODRunConfigSeqInfo.h.

int ODRunConfigSeqInfo::m_seq_num
private

Definition at line 51 of file ODRunConfigSeqInfo.h.

Referenced by getSequenceNumber(), and setSequenceNumber().

int ODRunConfigSeqInfo::m_sequence_id
private

Definition at line 52 of file ODRunConfigSeqInfo.h.