CMS 3D CMS Logo

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

#include <FEConfigSlidingInfo.h>

Inheritance diagram for FEConfigSlidingInfo:
IODConfig IDBObject

Public Member Functions

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

Constructor & Destructor Documentation

◆ FEConfigSlidingInfo()

FEConfigSlidingInfo::FEConfigSlidingInfo ( )

Definition at line 13 of file FEConfigSlidingInfo.cc.

13  {
14  m_env = nullptr;
15  m_conn = nullptr;
16  m_writeStmt = nullptr;
17  m_readStmt = nullptr;
18  m_config_tag = "";
19  m_version = 0;
20  m_ID = 0;
21  clear();
22 }

References clear().

◆ ~FEConfigSlidingInfo()

FEConfigSlidingInfo::~FEConfigSlidingInfo ( )
override

Definition at line 26 of file FEConfigSlidingInfo.cc.

26 {}

Member Function Documentation

◆ clear()

void FEConfigSlidingInfo::clear ( void  )
private

Definition at line 24 of file FEConfigSlidingInfo.cc.

24 { m_iov_id = 0; }

◆ fetchData()

void FEConfigSlidingInfo::fetchData ( FEConfigSlidingInfo result)
privatenoexcept

Definition at line 105 of file FEConfigSlidingInfo.cc.

105  {
106  this->checkConnection();
107  result->clear();
108  if (result->getId() == 0 && (result->getConfigTag().empty())) {
109  throw(std::runtime_error("FEConfigSlidingInfo::fetchData(): no Id defined for this FEConfigSlidingInfo "));
110  }
111 
112  try {
114 
115  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where ( sli_conf_id= :1 or (tag=:2 AND version=:3 ) )");
116  m_readStmt->setInt(1, result->getId());
117  m_readStmt->setString(2, result->getConfigTag());
118  m_readStmt->setInt(3, result->getVersion());
119  ResultSet* rset = m_readStmt->executeQuery();
120 
121  rset->next();
122 
123  // 1 is the id and 2 is the config tag and 3 is the version
124 
125  result->setId(rset->getInt(1));
126  result->setConfigTag(rset->getString(2));
127  result->setVersion(rset->getInt(3));
128  result->setIOVId(rset->getInt(4));
129  Date dbdate = rset->getDate(5);
130  result->setDBTime(dh.dateToTm(dbdate));
131 
132  } catch (SQLException& e) {
133  throw(std::runtime_error(std::string("FEConfigSlidingInfo::fetchData(): ") + e.getMessage()));
134  }
135 }

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

◆ fetchID()

int FEConfigSlidingInfo::fetchID ( )
noexcept

Definition at line 161 of file FEConfigSlidingInfo.cc.

161  {
162  // Return from memory if available
163  if (m_ID != 0) {
164  return m_ID;
165  }
166 
167  this->checkConnection();
168 
169  try {
170  Statement* stmt = m_conn->createStatement();
171  stmt->setSQL("SELECT sli_conf_id FROM " + getTable() + " WHERE tag=:1 and version=:2 ");
172 
173  stmt->setString(1, getConfigTag());
174  stmt->setInt(2, getVersion());
175 
176  ResultSet* rset = stmt->executeQuery();
177 
178  if (rset->next()) {
179  m_ID = rset->getInt(1);
180  } else {
181  m_ID = 0;
182  }
183  m_conn->terminateStatement(stmt);
184  } catch (SQLException& e) {
185  throw(std::runtime_error(std::string("FEConfigSlidingInfo::fetchID: ") + e.getMessage()));
186  }
187 
188  return m_ID;
189 }

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

◆ fetchLastData()

void FEConfigSlidingInfo::fetchLastData ( FEConfigSlidingInfo result)
privatenoexcept

Definition at line 137 of file FEConfigSlidingInfo.cc.

137  {
138  this->checkConnection();
139  result->clear();
140  try {
142 
143  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where sli_conf_id = ( select max( sli_conf_id) from " +
144  getTable() + " ) ");
145  ResultSet* rset = m_readStmt->executeQuery();
146 
147  rset->next();
148 
149  result->setId(rset->getInt(1));
150  result->setConfigTag(rset->getString(2));
151  result->setVersion(rset->getInt(3));
152  result->setIOVId(rset->getInt(4));
153  Date dbdate = rset->getDate(5);
154  result->setDBTime(dh.dateToTm(dbdate));
155 
156  } catch (SQLException& e) {
157  throw(std::runtime_error(std::string("FEConfigSlidingInfo::fetchData(): ") + e.getMessage()));
158  }
159 }

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

◆ fetchNextId()

int FEConfigSlidingInfo::fetchNextId ( )
noexcept

Definition at line 28 of file FEConfigSlidingInfo.cc.

28  {
29  int result = 0;
30  try {
31  this->checkConnection();
32 
33  m_readStmt = m_conn->createStatement();
34  m_readStmt->setSQL("select FE_CONFIG_SLI_SQ.NextVal from DUAL ");
35  ResultSet* rset = m_readStmt->executeQuery();
36  while (rset->next()) {
37  result = rset->getInt(1);
38  }
39  result++;
40  m_conn->terminateStatement(m_readStmt);
41  return result;
42 
43  } catch (SQLException& e) {
44  throw(std::runtime_error(std::string("FEConfigSlidingInfo::fetchNextId(): ") + e.getMessage()));
45  }
46 }

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

◆ getDBTime()

Tm FEConfigSlidingInfo::getDBTime ( ) const
inline

Definition at line 33 of file FEConfigSlidingInfo.h.

33 { return m_db_time; }

References m_db_time.

◆ getID()

int FEConfigSlidingInfo::getID ( )
inline

Definition at line 28 of file FEConfigSlidingInfo.h.

28 { return getId(); }

References getId().

◆ getId()

int FEConfigSlidingInfo::getId ( void  ) const
inline

Definition at line 25 of file FEConfigSlidingInfo.h.

25 { return m_ID; }

References m_ID.

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

◆ getIOVId()

int FEConfigSlidingInfo::getIOVId ( ) const
inline

Definition at line 22 of file FEConfigSlidingInfo.h.

22 { return m_iov_id; }

References m_iov_id.

◆ getTable()

std::string FEConfigSlidingInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigSlidingInfo.h.

19 { return "FE_CONFIG_SLIDING_INFO"; }

◆ getVersion()

int FEConfigSlidingInfo::getVersion ( ) const
inline

Definition at line 31 of file FEConfigSlidingInfo.h.

31 { return m_version; }

References m_version.

◆ operator!=()

bool FEConfigSlidingInfo::operator!= ( const FEConfigSlidingInfo r) const
inline

Definition at line 44 of file FEConfigSlidingInfo.h.

44 { return !(*this == r); }

References alignCSCRings::r.

◆ operator==()

bool FEConfigSlidingInfo::operator== ( const FEConfigSlidingInfo r) const
inline

Definition at line 43 of file FEConfigSlidingInfo.h.

43 { return (m_ID == r.m_ID); }

References m_ID, and alignCSCRings::r.

◆ prepareWrite()

void FEConfigSlidingInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 48 of file FEConfigSlidingInfo.cc.

48  {
49  this->checkConnection();
50 
51  int next_id = 0;
52  if (getId() == 0) {
53  next_id = fetchNextId();
54  }
55 
56  try {
57  m_writeStmt = m_conn->createStatement();
58  m_writeStmt->setSQL("INSERT INTO " + getTable() +
59  " ( sli_conf_id, tag, version, iov_id) "
60  " VALUES ( :1, :2, :3 , :4) ");
61 
62  m_writeStmt->setInt(1, next_id);
63  m_ID = next_id;
64 
65  } catch (SQLException& e) {
66  throw(std::runtime_error(std::string("FEConfigSlidingInfo::prepareWrite(): ") + e.getMessage()));
67  }
68 }

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

◆ setByID()

void FEConfigSlidingInfo::setByID ( int  id)
noexcept

Definition at line 191 of file FEConfigSlidingInfo.cc.

191  {
192  this->checkConnection();
193 
195 
196  try {
197  Statement* stmt = m_conn->createStatement();
198 
199  stmt->setSQL("SELECT * FROM " + getTable() + " WHERE sli_conf_id = :1");
200  stmt->setInt(1, id);
201 
202  ResultSet* rset = stmt->executeQuery();
203  if (rset->next()) {
204  this->setId(rset->getInt(1));
205  this->setConfigTag(rset->getString(2));
206  this->setVersion(rset->getInt(3));
207  this->setIOVId(rset->getInt(4));
208  Date dbdate = rset->getDate(5);
209  this->setDBTime(dh.dateToTm(dbdate));
210  } else {
211  throw(std::runtime_error("FEConfigSlidingInfo::setByID: Given config_id is not in the database"));
212  }
213 
214  m_conn->terminateStatement(stmt);
215  } catch (SQLException& e) {
216  throw(std::runtime_error(std::string("FEConfigSlidingInfo::setByID: ") + e.getMessage()));
217  }
218 }

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

◆ setDBTime()

void FEConfigSlidingInfo::setDBTime ( const Tm x)
inline

Definition at line 34 of file FEConfigSlidingInfo.h.

34 { m_db_time = x; }

References m_db_time, and x.

◆ setId()

void FEConfigSlidingInfo::setId ( int  id)
inline

Definition at line 24 of file FEConfigSlidingInfo.h.

24 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

Referenced by popcon::EcalTPGSlidingWindowHandler::getNewObjects(), and setID().

◆ setID()

void FEConfigSlidingInfo::setID ( int  id)
inline

Definition at line 27 of file FEConfigSlidingInfo.h.

27 { setId(id); }

References setId().

◆ setIOVId()

void FEConfigSlidingInfo::setIOVId ( int  iov_id)
inline

Definition at line 21 of file FEConfigSlidingInfo.h.

21 { m_iov_id = iov_id; }

References m_iov_id.

Referenced by EcalTPGDBApp::writeToConfDB_TPGSliding().

◆ setParameters()

void FEConfigSlidingInfo::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 70 of file FEConfigSlidingInfo.cc.

70  {
71  // parses the result of the XML parser that is a map of
72  // string string with variable name variable value
73 
74  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
75  if (ci->first == "VERSION")
76  setVersion(atoi(ci->second.c_str()));
77  if (ci->first == "TAG")
78  setConfigTag(ci->second);
79  if (ci->first == "IOV_ID")
80  setIOVId(atoi(ci->second.c_str()));
81  }
82 }

◆ setVersion()

void FEConfigSlidingInfo::setVersion ( int  id)
inline

Definition at line 30 of file FEConfigSlidingInfo.h.

30 { m_version = id; }

References triggerObjects_cff::id, and m_version.

◆ writeDB()

void FEConfigSlidingInfo::writeDB ( )
privatenoexcept

Definition at line 84 of file FEConfigSlidingInfo.cc.

84  {
85  this->checkConnection();
86  this->checkPrepare();
87 
88  try {
89  // number 1 is the id
90  m_writeStmt->setString(2, this->getConfigTag());
91  m_writeStmt->setInt(3, this->getVersion());
92  m_writeStmt->setInt(4, this->getIOVId());
93 
94  m_writeStmt->executeUpdate();
95 
96  } catch (SQLException& e) {
97  throw(std::runtime_error(std::string("FEConfigSlidingInfo::writeDB(): ") + e.getMessage()));
98  }
99  // Now get the ID
100  if (!this->fetchID()) {
101  throw(std::runtime_error("FEConfigSlidingInfo::writeDB: Failed to write"));
102  }
103 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigSlidingInfo.h.

Member Data Documentation

◆ m_db_time

Tm FEConfigSlidingInfo::m_db_time
private

Definition at line 50 of file FEConfigSlidingInfo.h.

Referenced by getDBTime(), and setDBTime().

◆ m_ID

int FEConfigSlidingInfo::m_ID
private

Definition at line 49 of file FEConfigSlidingInfo.h.

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

◆ m_iov_id

int FEConfigSlidingInfo::m_iov_id
private

Definition at line 48 of file FEConfigSlidingInfo.h.

Referenced by getIOVId(), and setIOVId().

◆ m_version

int FEConfigSlidingInfo::m_version
private

Definition at line 51 of file FEConfigSlidingInfo.h.

Referenced by getVersion(), and setVersion().

FEConfigSlidingInfo::getIOVId
int getIOVId() const
Definition: FEConfigSlidingInfo.h:22
FEConfigSlidingInfo::getTable
std::string getTable() override
Definition: FEConfigSlidingInfo.h:19
FEConfigSlidingInfo::clear
void clear()
Definition: FEConfigSlidingInfo.cc:24
FEConfigSlidingInfo::setVersion
void setVersion(int id)
Definition: FEConfigSlidingInfo.h:30
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
DDAxes::x
FEConfigSlidingInfo::setId
void setId(int id)
Definition: FEConfigSlidingInfo.h:24
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
IODConfig::checkPrepare
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
FEConfigSlidingInfo::m_ID
int m_ID
Definition: FEConfigSlidingInfo.h:49
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IODConfig::getConfigTag
std::string getConfigTag()
Definition: IODConfig.h:30
IDBObject::checkConnection
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
IODConfig::m_readStmt
Statement * m_readStmt
Definition: IODConfig.h:34
FEConfigSlidingInfo::getVersion
int getVersion() const
Definition: FEConfigSlidingInfo.h:31
FEConfigSlidingInfo::getId
int getId() const
Definition: FEConfigSlidingInfo.h:25
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FEConfigSlidingInfo::setIOVId
void setIOVId(int iov_id)
Definition: FEConfigSlidingInfo.h:21
FEConfigSlidingInfo::fetchNextId
int fetchNextId() noexcept(false)
Definition: FEConfigSlidingInfo.cc:28
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
IODConfig::m_config_tag
std::string m_config_tag
Definition: IODConfig.h:25
FEConfigSlidingInfo::setDBTime
void setDBTime(const Tm &x)
Definition: FEConfigSlidingInfo.h:34
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
FEConfigSlidingInfo::fetchID
int fetchID() noexcept(false)
Definition: FEConfigSlidingInfo.cc:161
mps_fire.result
result
Definition: mps_fire.py:311
IODConfig::setConfigTag
void setConfigTag(std::string x)
Definition: IODConfig.h:29
DateHandler
Definition: DateHandler.h:7
FEConfigSlidingInfo::m_iov_id
int m_iov_id
Definition: FEConfigSlidingInfo.h:48
cuy.dh
dh
Definition: cuy.py:355
FEConfigSlidingInfo::m_version
int m_version
Definition: FEConfigSlidingInfo.h:51
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
FEConfigSlidingInfo::m_db_time
Tm m_db_time
Definition: FEConfigSlidingInfo.h:50