CMS 3D CMS Logo

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

#include <FEConfigFgrInfo.h>

Inheritance diagram for FEConfigFgrInfo:
IODConfig IDBObject

Public Member Functions

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

Private Attributes

Tm m_db_time
 
int m_ID
 
int m_iov_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 FEConfigFgrInfo.h.

Constructor & Destructor Documentation

FEConfigFgrInfo::FEConfigFgrInfo ( )

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

Definition at line 32 of file FEConfigFgrInfo.cc.

33 {
34 }

Member Function Documentation

void FEConfigFgrInfo::clear ( void  )
private

Definition at line 26 of file FEConfigFgrInfo.cc.

26  {
27  m_iov_id=0;
28 }
void FEConfigFgrInfo::fetchData ( FEConfigFgrInfo result)
privatenoexcept

Definition at line 128 of file FEConfigFgrInfo.cc.

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

130 {
131  this->checkConnection();
132  result->clear();
133  if(result->getId()==0 && (result->getConfigTag().empty()) ){
134  throw(std::runtime_error("FEConfigFgrInfo::fetchData(): no Id defined for this FEConfigFgrInfo "));
135  }
136 
137  try {
139 
140  m_readStmt->setSQL("SELECT * FROM " + getTable() +
141  " where ( fgr_conf_id= :1 or (tag=:2 AND version=:3 ) )" );
142  m_readStmt->setInt(1, result->getId());
143  m_readStmt->setString(2, result->getConfigTag());
144  m_readStmt->setInt(3, result->getVersion());
145  ResultSet* rset = m_readStmt->executeQuery();
146 
147  rset->next();
148 
149  // 1 is the id and 2 is the config tag and 3 is the version
150 
151  result->setId(rset->getInt(1));
152  result->setConfigTag(getOraString(rset,2));
153  result->setVersion(rset->getInt(3));
154  result->setNumberOfGroups(rset->getInt(4));
155  Date dbdate = rset->getDate(5);
156  result->setDBTime( dh.dateToTm( dbdate ));
157 
158  } catch (SQLException &e) {
159  throw(std::runtime_error(std::string("FEConfigFgrInfo::fetchData(): ")+getOraMessage(&e)));
160  }
161 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getId() const
void setDBTime(const Tm &x)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setNumberOfGroups(int iov_id)
void setId(int id)
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void setVersion(int id)
Statement * m_readStmt
Definition: IODConfig.h:37
int getVersion() const
std::string getConfigTag()
Definition: IODConfig.h:32
dh
Definition: cuy.py:354
std::string getTable() override
int FEConfigFgrInfo::fetchID ( )
noexcept

Definition at line 189 of file FEConfigFgrInfo.cc.

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

Referenced by setDBTime().

190 {
191  // Return from memory if available
192  if (m_ID!=0) {
193  return m_ID;
194  }
195 
196  this->checkConnection();
197 
198  try {
199  Statement* stmt = m_conn->createStatement();
200  stmt->setSQL("SELECT fgr_conf_id FROM "+ getTable()+
201  " WHERE tag=:1 and version=:2 " );
202 
203  stmt->setString(1, getConfigTag() );
204  stmt->setInt(2, getVersion() );
205 
206  ResultSet* rset = stmt->executeQuery();
207 
208  if (rset->next()) {
209  m_ID = rset->getInt(1);
210  } else {
211  m_ID = 0;
212  }
213  m_conn->terminateStatement(stmt);
214  } catch (SQLException &e) {
215  throw(std::runtime_error(std::string("FEConfigFgrInfo::fetchID: ")+getOraMessage(&e)));
216  }
217 
218  return m_ID;
219 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
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
std::string getTable() override
void FEConfigFgrInfo::fetchLastData ( FEConfigFgrInfo result)
privatenoexcept

Definition at line 163 of file FEConfigFgrInfo.cc.

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

165 {
166  this->checkConnection();
167  result->clear();
168  try {
170 
171  m_readStmt->setSQL("SELECT * FROM " + getTable() +
172  " where fgr_conf_id = ( select max( fgr_conf_id) from "+ getTable() +" ) " );
173  ResultSet* rset = m_readStmt->executeQuery();
174 
175  rset->next();
176 
177  result->setId(rset->getInt(1));
178  result->setConfigTag(getOraString(rset,2));
179  result->setVersion(rset->getInt(3));
180  result->setNumberOfGroups(rset->getInt(4));
181  Date dbdate = rset->getDate(5);
182  result->setDBTime( dh.dateToTm( dbdate ));
183 
184  } catch (SQLException &e) {
185  throw(std::runtime_error(std::string("FEConfigFgrInfo::fetchData(): ")+getOraMessage(&e)));
186  }
187 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setDBTime(const Tm &x)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setNumberOfGroups(int iov_id)
void setId(int id)
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void setVersion(int id)
Statement * m_readStmt
Definition: IODConfig.h:37
dh
Definition: cuy.py:354
std::string getTable() override
int FEConfigFgrInfo::fetchNextId ( )
noexcept

Definition at line 38 of file FEConfigFgrInfo.cc.

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

Referenced by setDBTime().

38  {
39 
40  int result=0;
41  try {
42  this->checkConnection();
43 
44  m_readStmt = m_conn->createStatement();
45  m_readStmt->setSQL("select FE_CONFIG_FGR_SQ.NextVal from DUAL ");
46  ResultSet* rset = m_readStmt->executeQuery();
47  while (rset->next ()){
48  result= rset->getInt(1);
49  }
50  result++;
51  m_conn->terminateStatement(m_readStmt);
52  return result;
53 
54  } catch (SQLException &e) {
55  throw(std::runtime_error(std::string("FEConfigFgrInfo::fetchNextId(): ")+getOraMessage(&e)));
56  }
57 
58 }
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 FEConfigFgrInfo::getDBTime ( ) const
inline

Definition at line 35 of file FEConfigFgrInfo.h.

References m_db_time.

35 { return m_db_time;}
int FEConfigFgrInfo::getId ( void  ) const
inline

Definition at line 26 of file FEConfigFgrInfo.h.

References m_ID.

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

26 { return m_ID; }
int FEConfigFgrInfo::getID ( )
inline

Definition at line 29 of file FEConfigFgrInfo.h.

References getId().

29 { return getId() ;}
int getId() const
int FEConfigFgrInfo::getNumberOfGroups ( ) const
inline

Definition at line 23 of file FEConfigFgrInfo.h.

References m_iov_id.

23 {return m_iov_id; }
std::string FEConfigFgrInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigFgrInfo.h.

19 { return "FE_CONFIG_FGR_INFO"; }
int FEConfigFgrInfo::getVersion ( ) const
inline

Definition at line 32 of file FEConfigFgrInfo.h.

References m_version.

32 { return m_version; }
bool FEConfigFgrInfo::operator!= ( const FEConfigFgrInfo r) const
inline

Definition at line 47 of file FEConfigFgrInfo.h.

References alignCSCRings::r.

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

Definition at line 46 of file FEConfigFgrInfo.h.

References m_ID.

46 { return (m_ID == r.m_ID ); }
void FEConfigFgrInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 60 of file FEConfigFgrInfo.cc.

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

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()+" ( fgr_conf_id, tag, version, number_of_groups) "
73  " VALUES ( :1, :2, :3 , :4) " );
74 
75  m_writeStmt->setInt(1, next_id);
76  m_ID=next_id;
77 
78  } catch (SQLException &e) {
79  throw(std::runtime_error(std::string("FEConfigFgrInfo::prepareWrite(): ")+getOraMessage(&e)));
80  }
81 
82 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
int getId() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchNextId() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getTable() override
void FEConfigFgrInfo::setByID ( int  id)
noexcept

Definition at line 223 of file FEConfigFgrInfo.cc.

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

Referenced by setDBTime().

225 {
226  this->checkConnection();
227 
229 
230  try {
231  Statement* stmt = m_conn->createStatement();
232 
233  stmt->setSQL("SELECT * FROM fe_config_fgr_info WHERE fgr_conf_id = :1");
234  stmt->setInt(1, id);
235 
236  ResultSet* rset = stmt->executeQuery();
237  if (rset->next()) {
238  this->setId(rset->getInt(1));
239  this->setConfigTag(getOraString(rset,2));
240  this->setVersion(rset->getInt(3));
241  this->setNumberOfGroups(rset->getInt(4));
242  Date dbdate = rset->getDate(5);
243  this->setDBTime( dh.dateToTm( dbdate ));
244  } else {
245  throw(std::runtime_error("FEConfigFgrInfo::setByID: Given config_id is not in the database"));
246  }
247 
248  m_conn->terminateStatement(stmt);
249  } catch (SQLException &e) {
250  throw(std::runtime_error(std::string("FEConfigFgrInfo::setByID: ")+getOraMessage(&e)));
251  }
252 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setDBTime(const Tm &x)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setNumberOfGroups(int iov_id)
void setId(int id)
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 setVersion(int id)
dh
Definition: cuy.py:354
void FEConfigFgrInfo::setDBTime ( const Tm x)
inline
void FEConfigFgrInfo::setId ( int  id)
inline
void FEConfigFgrInfo::setID ( int  id)
inline

Definition at line 28 of file FEConfigFgrInfo.h.

References setId().

28 {setId(id);}
void setId(int id)
void FEConfigFgrInfo::setNumberOfGroups ( int  iov_id)
inline

Definition at line 22 of file FEConfigFgrInfo.h.

References m_iov_id.

Referenced by EcalTPGDBApp::writeToConfDB_TPGFgr().

22 { m_iov_id = iov_id; }
void FEConfigFgrInfo::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 84 of file FEConfigFgrInfo.cc.

Referenced by setDBTime().

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  if(ci->first== "NUMBER_OF_GROUPS") setNumberOfGroups(atoi(ci->second.c_str()) );
95 
96  }
97 
98 }
void setNumberOfGroups(int iov_id)
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setVersion(int id)
void FEConfigFgrInfo::setVersion ( int  id)
inline

Definition at line 31 of file FEConfigFgrInfo.h.

References triggerObjects_cff::id, and m_version.

void FEConfigFgrInfo::writeDB ( )
privatenoexcept

Definition at line 100 of file FEConfigFgrInfo.cc.

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

102 {
103  this->checkConnection();
104  this->checkPrepare();
105 
106  try {
107 
108  // number 1 is the id
109  m_writeStmt->setString(2, this->getConfigTag());
110  m_writeStmt->setInt(3, this->getVersion());
111  m_writeStmt->setInt(4, this->getNumberOfGroups());
112 
113  m_writeStmt->executeUpdate();
114 
115 
116  } catch (SQLException &e) {
117  throw(std::runtime_error(std::string("FEConfigFgrInfo::writeDB(): ")+getOraMessage(&e)));
118  }
119  // Now get the ID
120  if (!this->fetchID()) {
121  throw(std::runtime_error("FEConfigFgrInfo::writeDB: Failed to write"));
122  }
123 
124 
125 }
int fetchID() noexcept(false)
Statement * m_writeStmt
Definition: IODConfig.h:36
int getNumberOfGroups() const
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

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigFgrInfo.h.

Member Data Documentation

Tm FEConfigFgrInfo::m_db_time
private

Definition at line 53 of file FEConfigFgrInfo.h.

Referenced by getDBTime(), and setDBTime().

int FEConfigFgrInfo::m_ID
private

Definition at line 52 of file FEConfigFgrInfo.h.

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

int FEConfigFgrInfo::m_iov_id
private

Definition at line 51 of file FEConfigFgrInfo.h.

Referenced by getNumberOfGroups(), and setNumberOfGroups().

int FEConfigFgrInfo::m_version
private

Definition at line 54 of file FEConfigFgrInfo.h.

Referenced by getVersion(), and setVersion().