CMS 3D CMS Logo

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

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

14 {
15  m_env = nullptr;
16  m_conn = nullptr;
17  m_writeStmt = nullptr;
18  m_readStmt = nullptr;
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
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
FEConfigSpikeInfo::~FEConfigSpikeInfo ( )
override

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)
privatenoexcept

Definition at line 125 of file FEConfigSpikeInfo.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

127 {
128  this->checkConnection();
129  result->clear();
130  if(result->getId()==0 && (result->getConfigTag().empty()) ){
131  throw(std::runtime_error("FEConfigSpikeInfo::fetchData(): no Id defined for this FEConfigSpikeInfo "));
132  }
133 
134  try {
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(getOraString(rset,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(std::string("FEConfigSpikeInfo::fetchData(): ")+getOraMessage(&e)));
156  }
157 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setVersion(int id)
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
dh
Definition: cuy.py:355
void setDBTime(const Tm &x)
int FEConfigSpikeInfo::fetchID ( )
noexcept

Definition at line 184 of file FEConfigSpikeInfo.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by setDBTime().

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(std::string("FEConfigSpikeInfo::fetchID: ")+getOraMessage(&e)));
211  }
212 
213  return m_ID;
214 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
void FEConfigSpikeInfo::fetchLastData ( FEConfigSpikeInfo result)
privatenoexcept

Definition at line 159 of file FEConfigSpikeInfo.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

161 {
162  this->checkConnection();
163  result->clear();
164  try {
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(getOraString(rset,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(std::string("FEConfigSpikeInfo::fetchData(): ")+getOraMessage(&e)));
181  }
182 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setVersion(int id)
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
dh
Definition: cuy.py:355
void setDBTime(const Tm &x)
int FEConfigSpikeInfo::fetchNextId ( )
noexcept

Definition at line 37 of file FEConfigSpikeInfo.cc.

References MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by setDBTime().

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(std::string("FEConfigSpikeInfo::fetchNextId(): ")+getOraMessage(&e)));
55  }
56 
57 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
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 ( void  ) 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 ( )
inlineoverridevirtual

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

Implements IODConfig.

Definition at line 59 of file FEConfigSpikeInfo.cc.

References MillePedeFileConverter_cfg::e, getId(), and AlCaHLTBitMon_QueryRunRegistry::string.

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(std::string("FEConfigSpikeInfo::prepareWrite(): ")+getOraMessage(&e)));
79  }
80 
81 }
int fetchNextId() noexcept(false)
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void FEConfigSpikeInfo::setByID ( int  id)
noexcept

Definition at line 218 of file FEConfigSpikeInfo.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by setDBTime().

220 {
221  this->checkConnection();
222 
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(getOraString(rset,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(std::string("FEConfigSpikeInfo::setByID: ")+getOraMessage(&e)));
245  }
246 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setVersion(int id)
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
dh
Definition: cuy.py:355
void setDBTime(const Tm &x)
void FEConfigSpikeInfo::setDBTime ( const Tm x)
inline
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 ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 83 of file FEConfigSpikeInfo.cc.

Referenced by setDBTime().

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 >::const_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 ( )
privatenoexcept

Definition at line 98 of file FEConfigSpikeInfo.cc.

References MillePedeFileConverter_cfg::e, and AlCaHLTBitMon_QueryRunRegistry::string.

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(std::string("FEConfigSpikeInfo::writeDB(): ")+getOraMessage(&e)));
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
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39
int fetchID() noexcept(false)

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