CMS 3D CMS Logo

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

#include <FEConfigCokeInfo.h>

Inheritance diagram for FEConfigCokeInfo:
IODConfig IDBObject

Public Member Functions

 FEConfigCokeInfo ()
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
Tm getDBTime () const
 
int getID ()
 
int getId () const
 
std::string getTable () override
 
int getVersion () const
 
bool operator!= (const FEConfigCokeInfo &r) const
 
bool operator== (const FEConfigCokeInfo &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)
 
 ~FEConfigCokeInfo () 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 (FEConfigCokeInfo *result) noexcept(false)
 
void fetchLastData (FEConfigCokeInfo *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 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 FEConfigCokeInfo.h.

Constructor & Destructor Documentation

◆ FEConfigCokeInfo()

FEConfigCokeInfo::FEConfigCokeInfo ( )

Definition at line 13 of file FEConfigCokeInfo.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().

◆ ~FEConfigCokeInfo()

FEConfigCokeInfo::~FEConfigCokeInfo ( )
override

Definition at line 26 of file FEConfigCokeInfo.cc.

26 {}

Member Function Documentation

◆ clear()

void FEConfigCokeInfo::clear ( void  )
private

Definition at line 24 of file FEConfigCokeInfo.cc.

24 {}

◆ fetchData()

void FEConfigCokeInfo::fetchData ( FEConfigCokeInfo result)
privatenoexcept

Definition at line 102 of file FEConfigCokeInfo.cc.

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

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

◆ fetchID()

int FEConfigCokeInfo::fetchID ( )
noexcept

Definition at line 157 of file FEConfigCokeInfo.cc.

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

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

◆ fetchLastData()

void FEConfigCokeInfo::fetchLastData ( FEConfigCokeInfo result)
privatenoexcept

Definition at line 134 of file FEConfigCokeInfo.cc.

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

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

◆ fetchNextId()

int FEConfigCokeInfo::fetchNextId ( )
noexcept

Definition at line 28 of file FEConfigCokeInfo.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_COKE_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("FEConfigCokeInfo::fetchNextId(): ") + e.getMessage()));
45  }
46 }

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

◆ getDBTime()

Tm FEConfigCokeInfo::getDBTime ( ) const
inline

Definition at line 30 of file FEConfigCokeInfo.h.

30 { return m_db_time; }

References m_db_time.

◆ getID()

int FEConfigCokeInfo::getID ( )
inline

Definition at line 25 of file FEConfigCokeInfo.h.

25 { return getId(); }

References getId().

◆ getId()

int FEConfigCokeInfo::getId ( void  ) const
inline

Definition at line 22 of file FEConfigCokeInfo.h.

22 { return m_ID; }

References m_ID.

Referenced by getID().

◆ getTable()

std::string FEConfigCokeInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigCokeInfo.h.

19 { return "FE_CONFIG_COKE_INFO"; }

◆ getVersion()

int FEConfigCokeInfo::getVersion ( ) const
inline

Definition at line 28 of file FEConfigCokeInfo.h.

28 { return m_version; }

References m_version.

◆ operator!=()

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

Definition at line 41 of file FEConfigCokeInfo.h.

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

References alignCSCRings::r.

◆ operator==()

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

Definition at line 40 of file FEConfigCokeInfo.h.

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

References m_ID, and alignCSCRings::r.

◆ prepareWrite()

void FEConfigCokeInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 48 of file FEConfigCokeInfo.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  " ( coke_conf_id, tag, version) "
60  " VALUES ( :1, :2, :3 ) ");
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("FEConfigCokeInfo::prepareWrite(): ") + e.getMessage()));
67  }
68 }

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

◆ setByID()

void FEConfigCokeInfo::setByID ( int  id)
noexcept

Definition at line 187 of file FEConfigCokeInfo.cc.

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

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

◆ setDBTime()

void FEConfigCokeInfo::setDBTime ( const Tm x)
inline

Definition at line 31 of file FEConfigCokeInfo.h.

31 { m_db_time = x; }

References m_db_time, and x.

◆ setId()

void FEConfigCokeInfo::setId ( int  id)
inline

Definition at line 21 of file FEConfigCokeInfo.h.

21 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

Referenced by setID().

◆ setID()

void FEConfigCokeInfo::setID ( int  id)
inline

Definition at line 24 of file FEConfigCokeInfo.h.

24 { setId(id); }

References setId().

◆ setParameters()

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

Definition at line 70 of file FEConfigCokeInfo.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  }
80 }

◆ setVersion()

void FEConfigCokeInfo::setVersion ( int  id)
inline

Definition at line 27 of file FEConfigCokeInfo.h.

27 { m_version = id; }

References triggerObjects_cff::id, and m_version.

◆ writeDB()

void FEConfigCokeInfo::writeDB ( )
privatenoexcept

Definition at line 82 of file FEConfigCokeInfo.cc.

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

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 13 of file FEConfigCokeInfo.h.

Member Data Documentation

◆ m_db_time

Tm FEConfigCokeInfo::m_db_time
private

Definition at line 46 of file FEConfigCokeInfo.h.

Referenced by getDBTime(), and setDBTime().

◆ m_ID

int FEConfigCokeInfo::m_ID
private

Definition at line 45 of file FEConfigCokeInfo.h.

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

◆ m_version

int FEConfigCokeInfo::m_version
private

Definition at line 47 of file FEConfigCokeInfo.h.

Referenced by getVersion(), and setVersion().

FEConfigCokeInfo::setVersion
void setVersion(int id)
Definition: FEConfigCokeInfo.h:27
FEConfigCokeInfo::m_ID
int m_ID
Definition: FEConfigCokeInfo.h:45
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
FEConfigCokeInfo::getTable
std::string getTable() override
Definition: FEConfigCokeInfo.h:19
DDAxes::x
FEConfigCokeInfo::m_db_time
Tm m_db_time
Definition: FEConfigCokeInfo.h:46
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
FEConfigCokeInfo::fetchNextId
int fetchNextId() noexcept(false)
Definition: FEConfigCokeInfo.cc:28
FEConfigCokeInfo::setId
void setId(int id)
Definition: FEConfigCokeInfo.h:21
IODConfig::checkPrepare
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
FEConfigCokeInfo::clear
void clear()
Definition: FEConfigCokeInfo.cc:24
FEConfigCokeInfo::m_version
int m_version
Definition: FEConfigCokeInfo.h:47
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
FEConfigCokeInfo::fetchID
int fetchID() noexcept(false)
Definition: FEConfigCokeInfo.cc:157
FEConfigCokeInfo::getVersion
int getVersion() const
Definition: FEConfigCokeInfo.h:28
FEConfigCokeInfo::setDBTime
void setDBTime(const Tm &x)
Definition: FEConfigCokeInfo.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FEConfigCokeInfo::getId
int getId() const
Definition: FEConfigCokeInfo.h:22
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
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
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
cuy.dh
dh
Definition: cuy.py:354
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37