CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
FEConfigTimingInfo Class Reference

#include <FEConfigTimingInfo.h>

Inheritance diagram for FEConfigTimingInfo:
IODConfig IDBObject

Public Member Functions

 FEConfigTimingInfo ()
 
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 FEConfigTimingInfo &r) const
 
bool operator== (const FEConfigTimingInfo &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)
 
 ~FEConfigTimingInfo () 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 (FEConfigTimingInfo *result) noexcept(false)
 
void fetchLastData (FEConfigTimingInfo *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 FEConfigTimingInfo.h.

Constructor & Destructor Documentation

FEConfigTimingInfo::FEConfigTimingInfo ( )

Definition at line 13 of file FEConfigTimingInfo.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
FEConfigTimingInfo::~FEConfigTimingInfo ( )
override

Definition at line 31 of file FEConfigTimingInfo.cc.

32 {
33 }

Member Function Documentation

void FEConfigTimingInfo::clear ( void  )
private

Definition at line 26 of file FEConfigTimingInfo.cc.

26  {
27 }
void FEConfigTimingInfo::fetchData ( FEConfigTimingInfo result)
privatenoexcept

Definition at line 125 of file FEConfigTimingInfo.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("FEConfigTimingInfo::fetchData(): no Id defined for this FEConfigTimingInfo "));
132  }
133 
134  try {
136 
137  m_readStmt->setSQL("SELECT * FROM " + getTable() +
138  " where ( tim_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("FEConfigTimingInfo::fetchData(): ")+getOraMessage(&e)));
156  }
157 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
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
void setDBTime(const Tm &x)
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
dh
Definition: cuy.py:353
int FEConfigTimingInfo::fetchID ( )
noexcept

Definition at line 184 of file FEConfigTimingInfo.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 tim_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("FEConfigTimingInfo::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
std::string getConfigTag()
Definition: IODConfig.h:32
void FEConfigTimingInfo::fetchLastData ( FEConfigTimingInfo result)
privatenoexcept

Definition at line 159 of file FEConfigTimingInfo.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 tim_conf_id = ( select max( tim_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("FEConfigTimingInfo::fetchData(): ")+getOraMessage(&e)));
181  }
182 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
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
void setDBTime(const Tm &x)
Statement * m_readStmt
Definition: IODConfig.h:37
dh
Definition: cuy.py:353
int FEConfigTimingInfo::fetchNextId ( )
noexcept

Definition at line 37 of file FEConfigTimingInfo.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_TIM_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("FEConfigTimingInfo::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 FEConfigTimingInfo::getDBTime ( ) const
inline

Definition at line 32 of file FEConfigTimingInfo.h.

References m_db_time.

32 { return m_db_time;}
int FEConfigTimingInfo::getId ( void  ) const
inline

Definition at line 23 of file FEConfigTimingInfo.h.

References m_ID.

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

23 { return m_ID; }
int FEConfigTimingInfo::getID ( )
inline

Definition at line 26 of file FEConfigTimingInfo.h.

References getId().

26 { return getId() ;}
std::string FEConfigTimingInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigTimingInfo.h.

19 { return "FE_CONFIG_TIME_INFO"; }
int FEConfigTimingInfo::getVersion ( ) const
inline

Definition at line 29 of file FEConfigTimingInfo.h.

References m_version.

29 { return m_version; }
bool FEConfigTimingInfo::operator!= ( const FEConfigTimingInfo r) const
inline

Definition at line 44 of file FEConfigTimingInfo.h.

References alignCSCRings::r.

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

Definition at line 43 of file FEConfigTimingInfo.h.

References m_ID.

43 { return (m_ID == r.m_ID ); }
void FEConfigTimingInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 59 of file FEConfigTimingInfo.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()+" ( tim_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("FEConfigTimingInfo::prepareWrite(): ")+getOraMessage(&e)));
79  }
80 
81 }
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
int fetchNextId() noexcept(false)
void FEConfigTimingInfo::setByID ( int  id)
noexcept

Definition at line 218 of file FEConfigTimingInfo.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 tim_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("FEConfigTimingInfo::setByID: Given tim_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("FEConfigTimingInfo::setByID: ")+getOraMessage(&e)));
245  }
246 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
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
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void setDBTime(const Tm &x)
dh
Definition: cuy.py:353
void FEConfigTimingInfo::setDBTime ( const Tm x)
inline
void FEConfigTimingInfo::setId ( int  id)
inline

Definition at line 22 of file FEConfigTimingInfo.h.

References triggerObjects_cff::id, and m_ID.

Referenced by setID().

void FEConfigTimingInfo::setID ( int  id)
inline

Definition at line 25 of file FEConfigTimingInfo.h.

References setId().

25 {setId(id);}
void FEConfigTimingInfo::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 83 of file FEConfigTimingInfo.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 setConfigTag(std::string x)
Definition: IODConfig.h:31
void FEConfigTimingInfo::setVersion ( int  id)
inline
void FEConfigTimingInfo::writeDB ( )
privatenoexcept

Definition at line 98 of file FEConfigTimingInfo.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("FEConfigTimingInfo::writeDB(): ")+getOraMessage(&e)));
115  }
116  // Now get the ID
117  if (!this->fetchID()) {
118  throw(std::runtime_error("FEConfigTimingInfo::writeDB: Failed to write"));
119  }
120 
121 
122 }
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigTimingInfo.h.

Member Data Documentation

Tm FEConfigTimingInfo::m_db_time
private

Definition at line 49 of file FEConfigTimingInfo.h.

Referenced by getDBTime(), and setDBTime().

int FEConfigTimingInfo::m_ID
private

Definition at line 48 of file FEConfigTimingInfo.h.

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

int FEConfigTimingInfo::m_version
private

Definition at line 50 of file FEConfigTimingInfo.h.

Referenced by getVersion(), and setVersion().