test
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
ODFEDelaysInfo Class Reference

#include <ODFEDelaysInfo.h>

Inheritance diagram for ODFEDelaysInfo:
IODConfig IDBObject

Public Member Functions

int fetchID () throw (std::runtime_error)
 
int fetchNextId () throw (std::runtime_error)
 
int getId () const
 
std::string getTable ()
 
int getVersion () const
 
 ODFEDelaysInfo ()
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setVersion (int id)
 
 ~ODFEDelaysInfo ()
 
- 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 (ODFEDelaysInfo *result) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

Private Attributes

int m_ID
 
int m_version
 

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 9 of file ODFEDelaysInfo.h.

Constructor & Destructor Documentation

ODFEDelaysInfo::ODFEDelaysInfo ( )

Definition at line 12 of file ODFEDelaysInfo.cc.

References hitfit::clear(), and NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
18  m_config_tag="";
19  m_version=0;
20  m_ID=0;
21  clear();
22 }
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
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODFEDelaysInfo::~ODFEDelaysInfo ( )

Definition at line 31 of file ODFEDelaysInfo.cc.

32 {
33 }

Member Function Documentation

void ODFEDelaysInfo::clear ( void  )
private

Definition at line 25 of file ODFEDelaysInfo.cc.

25  {
26 
27 }
void ODFEDelaysInfo::fetchData ( ODFEDelaysInfo result)
throw (std::runtime_error
)
private

Definition at line 131 of file ODFEDelaysInfo.cc.

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

133 {
134 
135  this->checkConnection();
136 
137  result->clear();
138  if(result->getId()==0 && (result->getConfigTag()=="") ){
139  throw(std::runtime_error("ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
140  }
141 
142  try {
143  if(result->getId()!=0) {
144  m_readStmt->setSQL("SELECT * FROM " + getTable() +
145  " where rec_id = :1 ");
146  m_readStmt->setInt(1, result->getId());
147  } else if (result->getConfigTag()!="") {
148  m_readStmt->setSQL("SELECT * FROM " + getTable() +
149  " where tag=:1 AND version=:2 " );
150  m_readStmt->setString(1, result->getConfigTag());
151  m_readStmt->setInt(2, result->getVersion());
152  } else {
153  // we should never pass here
154  throw(std::runtime_error("ODFEDelaysInfo::fetchData(): no Id defined for this ODFEDelaysInfo "));
155  }
156 
157  ResultSet* rset = m_readStmt->executeQuery();
158  rset->next();
159 
160  // 1 is the id and 2 is the config tag and 3 is the version
161 
162  result->setId(rset->getInt(1));
163  result->setConfigTag(rset->getString(2));
164  result->setVersion(rset->getInt(3));
165 
166  } catch (SQLException &e) {
167  throw(std::runtime_error("ODFEDelaysInfo::fetchData(): "+e.getMessage()));
168  }
169 }
std::string getTable()
int getId() const
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void setVersion(int id)
int getVersion() const
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setId(int id)
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
int ODFEDelaysInfo::fetchID ( )
throw (std::runtime_error
)

Definition at line 171 of file ODFEDelaysInfo.cc.

References alignCSCRings::e.

172 {
173  // Return from memory if available
174  if (m_ID!=0) {
175  return m_ID;
176  }
177 
178  this->checkConnection();
179 
180  try {
181  Statement* stmt = m_conn->createStatement();
182  stmt->setSQL("SELECT rec_id FROM "+ getTable()+
183  "WHERE tag=:1 and version=:2 " );
184 
185  stmt->setString(1, getConfigTag() );
186  stmt->setInt(2, getVersion() );
187 
188  ResultSet* rset = stmt->executeQuery();
189 
190  if (rset->next()) {
191  m_ID = rset->getInt(1);
192  } else {
193  m_ID = 0;
194  }
195  m_conn->terminateStatement(stmt);
196  } catch (SQLException &e) {
197  throw(std::runtime_error("ODFEDelaysInfo::fetchID: "+e.getMessage()));
198  }
199 
200  return m_ID;
201 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getVersion() const
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
int ODFEDelaysInfo::fetchNextId ( )
throw (std::runtime_error
)

Definition at line 37 of file ODFEDelaysInfo.cc.

References gather_cfg::cout, alignCSCRings::e, and mps_fire::result.

37  {
38 
39  int result=0;
40  try {
41  this->checkConnection();
42 
43  m_readStmt = m_conn->createStatement();
44  m_readStmt->setSQL("select COND2CONF_INFO_SQ.NextVal from DUAL ");
45  ResultSet* rset = m_readStmt->executeQuery();
46  while (rset->next ()){
47  result= rset->getInt(1);
48  }
49  result++;
50  m_conn->terminateStatement(m_readStmt);
51  std::cout << " the id is going to be : "<< result<< endl;
52  return result;
53 
54  } catch (SQLException &e) {
55  throw(std::runtime_error("ODFEDelaysInfo::fetchNextId(): "+e.getMessage()));
56  }
57 
58 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple result
Definition: mps_fire.py:84
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
tuple cout
Definition: gather_cfg.py:145
void checkConnection() const
Definition: IDBObject.h:41
int ODFEDelaysInfo::getId ( ) const
inline

Definition at line 19 of file ODFEDelaysInfo.h.

References m_ID.

19 { return m_ID; }
std::string ODFEDelaysInfo::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 16 of file ODFEDelaysInfo.h.

16 { return "DELAYS_INFO"; }
int ODFEDelaysInfo::getVersion ( ) const
inline

Definition at line 24 of file ODFEDelaysInfo.h.

References m_version.

24 { return m_version; }
void ODFEDelaysInfo::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 60 of file ODFEDelaysInfo.cc.

References alignCSCRings::e, and getId().

62 {
63  this->checkConnection();
64 
65  int next_id=0;
66  if(getId()==0){
67  next_id=fetchNextId();
68  }
69 
70  try {
71  m_writeStmt = m_conn->createStatement();
72  m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( rec_id, tag, version) "
73  " VALUES ( :1, :2, :3 ) " );
74 
75  m_writeStmt->setInt(1, next_id);
76  m_ID=next_id;
77 
78  } catch (SQLException &e) {
79  throw(std::runtime_error("ODFEDelaysInfo::prepareWrite(): "+e.getMessage()));
80  }
81 
82 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
Statement * m_writeStmt
Definition: IODConfig.h:36
int getId() const
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void ODFEDelaysInfo::setId ( int  id)
inline

Definition at line 18 of file ODFEDelaysInfo.h.

References m_ID.

18 { m_ID = id; }
void ODFEDelaysInfo::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 84 of file ODFEDelaysInfo.cc.

84  {
85 
86  // parses the result of the XML parser that is a map of
87  // string string with variable name variable value
88 
89  for( std::map<std::string, std::string >::const_iterator ci=
90  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
91 
92  if(ci->first== "VERSION") setVersion(atoi(ci->second.c_str()) );
93  if(ci->first== "TAG") setConfigTag(ci->second);
94 
95  }
96 
97 }
void setVersion(int id)
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void ODFEDelaysInfo::setVersion ( int  id)
inline

Definition at line 23 of file ODFEDelaysInfo.h.

References m_version.

23 { m_version = id; }
void ODFEDelaysInfo::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 99 of file ODFEDelaysInfo.cc.

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

101 {
102  this->checkConnection();
103  this->checkPrepare();
104 
105  try {
106 
107  // number 1 is the id
108  m_writeStmt->setString(2, this->getConfigTag());
109  m_writeStmt->setInt(3, this->getVersion());
110 
111  m_writeStmt->executeUpdate();
112 
113 
114  } catch (SQLException &e) {
115  throw(std::runtime_error("ODFEDelaysInfo::writeDB(): "+e.getMessage()));
116  }
117 
118  // Now get the ID
119  if (!this->fetchID()) {
120  throw(std::runtime_error("ODFEDelaysInfo::writeDB: Failed to write"));
121  } else {
122  int old_version=this->getVersion();
123  m_readStmt = m_conn->createStatement();
124  this->fetchData (this);
125  m_conn->terminateStatement(m_readStmt);
126  if(this->getVersion()!=old_version) std::cout << "ODFEDelaysInfo>>WARNING version is "<< getVersion()<< endl;
127  }
128 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void fetchData(ODFEDelaysInfo *result)
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getVersion() const
void checkPrepare()
Definition: IODConfig.h:39
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
tuple cout
Definition: gather_cfg.py:145
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODFEDelaysInfo.h.

Member Data Documentation

int ODFEDelaysInfo::m_ID
private

Definition at line 42 of file ODFEDelaysInfo.h.

Referenced by getId(), and setId().

int ODFEDelaysInfo::m_version
private

Definition at line 43 of file ODFEDelaysInfo.h.

Referenced by getVersion(), and setVersion().