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

#include <FEConfigSpikeInfo.h>

Inheritance diagram for FEConfigSpikeInfo:
IODConfig IDBObject

Public Member Functions

 FEConfigSpikeInfo ()
 
int fetchID () throw (std::runtime_error)
 
int fetchNextId () throw (std::runtime_error)
 
Tm getDBTime () const
 
int getId () const
 
int getID ()
 
std::string getTable ()
 
int getVersion () const
 
bool operator!= (const FEConfigSpikeInfo &r) const
 
bool operator== (const FEConfigSpikeInfo &r) const
 
void setByID (int id) throw (std::runtime_error)
 
void setDBTime (Tm x)
 
void setId (int id)
 
void setID (int id)
 
void setParameters (std::map< std::string, std::string > my_keys_map)
 
void setVersion (int id)
 
 ~FEConfigSpikeInfo ()
 
- 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 (FEConfigSpikeInfo *result) throw (std::runtime_error)
 
void fetchLastData (FEConfigSpikeInfo *result) throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

Private Attributes

Tm m_db_time
 
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 11 of file FEConfigSpikeInfo.h.

Constructor & Destructor Documentation

FEConfigSpikeInfo::FEConfigSpikeInfo ( )

Definition at line 13 of file FEConfigSpikeInfo.cc.

References hitfit::clear(), and NULL.

14 {
15  m_env = NULL;
16  m_conn = NULL;
17  m_writeStmt = NULL;
18  m_readStmt = NULL;
19  m_config_tag="";
20  m_version=0;
21  m_ID=0;
22  clear();
23 }
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
FEConfigSpikeInfo::~FEConfigSpikeInfo ( )

Definition at line 31 of file FEConfigSpikeInfo.cc.

32 {
33 }

Member Function Documentation

void FEConfigSpikeInfo::clear ( void  )
private

Definition at line 26 of file FEConfigSpikeInfo.cc.

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

Definition at line 125 of file FEConfigSpikeInfo.cc.

References DateHandler::dateToTm(), alignCSCRings::e, and query::result.

127 {
128  this->checkConnection();
129  result->clear();
130  if(result->getId()==0 && (result->getConfigTag()=="") ){
131  throw(std::runtime_error("FEConfigSpikeInfo::fetchData(): no Id defined for this FEConfigSpikeInfo "));
132  }
133 
134  try {
135  DateHandler dh(m_env, m_conn);
136 
137  m_readStmt->setSQL("SELECT * FROM " + getTable() +
138  " where ( spi_conf_id= :1 or (tag=:2 AND version=:3 ) )" );
139  m_readStmt->setInt(1, result->getId());
140  m_readStmt->setString(2, result->getConfigTag());
141  m_readStmt->setInt(3, result->getVersion());
142  ResultSet* rset = m_readStmt->executeQuery();
143 
144  rset->next();
145 
146  // 1 is the id and 2 is the config tag and 3 is the version
147 
148  result->setId(rset->getInt(1));
149  result->setConfigTag(rset->getString(2));
150  result->setVersion(rset->getInt(3));
151  Date dbdate = rset->getDate(4);
152  result->setDBTime( dh.dateToTm( dbdate ));
153 
154  } catch (SQLException &e) {
155  throw(std::runtime_error("FEConfigSpikeInfo::fetchData(): "+e.getMessage()));
156  }
157 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setVersion(int id)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
int FEConfigSpikeInfo::fetchID ( )
throw (std::runtime_error
)

Definition at line 184 of file FEConfigSpikeInfo.cc.

References alignCSCRings::e.

185 {
186  // Return from memory if available
187  if (m_ID!=0) {
188  return m_ID;
189  }
190 
191  this->checkConnection();
192 
193  try {
194  Statement* stmt = m_conn->createStatement();
195  stmt->setSQL("SELECT spi_conf_id FROM "+ getTable()+
196  " WHERE tag=:1 and version=:2 " );
197 
198  stmt->setString(1, getConfigTag() );
199  stmt->setInt(2, getVersion() );
200 
201  ResultSet* rset = stmt->executeQuery();
202 
203  if (rset->next()) {
204  m_ID = rset->getInt(1);
205  } else {
206  m_ID = 0;
207  }
208  m_conn->terminateStatement(stmt);
209  } catch (SQLException &e) {
210  throw(std::runtime_error("FEConfigSpikeInfo::fetchID: "+e.getMessage()));
211  }
212 
213  return m_ID;
214 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
void FEConfigSpikeInfo::fetchLastData ( FEConfigSpikeInfo result)
throw (std::runtime_error
)
private

Definition at line 159 of file FEConfigSpikeInfo.cc.

References DateHandler::dateToTm(), alignCSCRings::e, and query::result.

161 {
162  this->checkConnection();
163  result->clear();
164  try {
165  DateHandler dh(m_env, m_conn);
166 
167  m_readStmt->setSQL("SELECT * FROM " + getTable() +
168  " where spi_conf_id = ( select max( spi_conf_id) from "+ getTable() +" ) " );
169  ResultSet* rset = m_readStmt->executeQuery();
170 
171  rset->next();
172 
173  result->setId(rset->getInt(1));
174  result->setConfigTag(rset->getString(2));
175  result->setVersion(rset->getInt(3));
176  Date dbdate = rset->getDate(4);
177  result->setDBTime( dh.dateToTm( dbdate ));
178 
179  } catch (SQLException &e) {
180  throw(std::runtime_error("FEConfigSpikeInfo::fetchData(): "+e.getMessage()));
181  }
182 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setVersion(int id)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
int FEConfigSpikeInfo::fetchNextId ( )
throw (std::runtime_error
)

Definition at line 37 of file FEConfigSpikeInfo.cc.

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

37  {
38 
39  int result=0;
40  try {
41  this->checkConnection();
42 
43  m_readStmt = m_conn->createStatement();
44  m_readStmt->setSQL("select FE_CONFIG_SPI_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  return result;
52 
53  } catch (SQLException &e) {
54  throw(std::runtime_error("FEConfigSpikeInfo::fetchNextId(): "+e.getMessage()));
55  }
56 
57 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
Tm FEConfigSpikeInfo::getDBTime ( ) const
inline

Definition at line 31 of file FEConfigSpikeInfo.h.

References m_db_time.

31 { return m_db_time;}
int FEConfigSpikeInfo::getId ( ) const
inline

Definition at line 22 of file FEConfigSpikeInfo.h.

References m_ID.

Referenced by getID(), and EcalTPGDBApp::writeToConfDB_Spike().

22 { return m_ID; }
int FEConfigSpikeInfo::getID ( )
inline

Definition at line 25 of file FEConfigSpikeInfo.h.

References getId().

25 { return getId() ;}
std::string FEConfigSpikeInfo::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigSpikeInfo.h.

19 { return "FE_CONFIG_SPIKE_INFO"; }
int FEConfigSpikeInfo::getVersion ( ) const
inline

Definition at line 28 of file FEConfigSpikeInfo.h.

References m_version.

28 { return m_version; }
bool FEConfigSpikeInfo::operator!= ( const FEConfigSpikeInfo r) const
inline

Definition at line 43 of file FEConfigSpikeInfo.h.

References alignCSCRings::r.

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

Definition at line 42 of file FEConfigSpikeInfo.h.

References m_ID.

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

Implements IODConfig.

Definition at line 59 of file FEConfigSpikeInfo.cc.

References alignCSCRings::e, and getId().

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

Definition at line 218 of file FEConfigSpikeInfo.cc.

References DateHandler::dateToTm(), and alignCSCRings::e.

220 {
221  this->checkConnection();
222 
223  DateHandler dh(m_env, m_conn);
224 
225  try {
226  Statement* stmt = m_conn->createStatement();
227 
228  stmt->setSQL("SELECT * FROM "+ getTable()+" WHERE spi_conf_id = :1");
229  stmt->setInt(1, id);
230 
231  ResultSet* rset = stmt->executeQuery();
232  if (rset->next()) {
233  this->setId(rset->getInt(1));
234  this->setConfigTag(rset->getString(2));
235  this->setVersion(rset->getInt(3));
236  Date dbdate = rset->getDate(4);
237  this->setDBTime( dh.dateToTm( dbdate ));
238  } else {
239  throw(std::runtime_error("FEConfigSpikeInfo::setByID: Given spi_conf_id is not in the database"));
240  }
241 
242  m_conn->terminateStatement(stmt);
243  } catch (SQLException &e) {
244  throw(std::runtime_error("FEConfigSpikeInfo::setByID: "+e.getMessage()));
245  }
246 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setVersion(int id)
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void checkConnection() const
Definition: IDBObject.h:41
void FEConfigSpikeInfo::setDBTime ( Tm  x)
inline

Definition at line 32 of file FEConfigSpikeInfo.h.

References m_db_time, and vdt::x.

void FEConfigSpikeInfo::setId ( int  id)
inline
void FEConfigSpikeInfo::setID ( int  id)
inline

Definition at line 24 of file FEConfigSpikeInfo.h.

References setId().

24 {setId(id);}
void FEConfigSpikeInfo::setParameters ( std::map< std::string, std::string >  my_keys_map)

Definition at line 83 of file FEConfigSpikeInfo.cc.

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

Definition at line 98 of file FEConfigSpikeInfo.cc.

References alignCSCRings::e.

100 {
101  this->checkConnection();
102  this->checkPrepare();
103 
104  try {
105 
106  // number 1 is the id
107  m_writeStmt->setString(2, this->getConfigTag());
108  m_writeStmt->setInt(3, this->getVersion());
109 
110  m_writeStmt->executeUpdate();
111 
112 
113  } catch (SQLException &e) {
114  throw(std::runtime_error("FEConfigSpikeInfo::writeDB(): "+e.getMessage()));
115  }
116  // Now get the ID
117  if (!this->fetchID()) {
118  throw(std::runtime_error("FEConfigSpikeInfo::writeDB: Failed to write"));
119  }
120 
121 
122 }
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkPrepare()
Definition: IODConfig.h:39
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigSpikeInfo.h.

Member Data Documentation

Tm FEConfigSpikeInfo::m_db_time
private

Definition at line 49 of file FEConfigSpikeInfo.h.

Referenced by getDBTime(), and setDBTime().

int FEConfigSpikeInfo::m_ID
private

Definition at line 48 of file FEConfigSpikeInfo.h.

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

int FEConfigSpikeInfo::m_version
private

Definition at line 50 of file FEConfigSpikeInfo.h.

Referenced by getVersion(), and setVersion().