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 () const
 
int getID ()
 
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 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 FEConfigCokeInfo.h.

Constructor & Destructor Documentation

◆ FEConfigCokeInfo()

FEConfigCokeInfo::FEConfigCokeInfo ( )

Definition at line 14 of file FEConfigCokeInfo.cc.

References l1ct::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:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
std::string m_config_tag
Definition: IODConfig.h:25
Statement * m_readStmt
Definition: IODConfig.h:34

◆ ~FEConfigCokeInfo()

FEConfigCokeInfo::~FEConfigCokeInfo ( )
override

Definition at line 27 of file FEConfigCokeInfo.cc.

27 {}

Member Function Documentation

◆ clear()

void FEConfigCokeInfo::clear ( void  )
private

Definition at line 25 of file FEConfigCokeInfo.cc.

25 {}

◆ fetchData()

void FEConfigCokeInfo::fetchData ( FEConfigCokeInfo result)
privatenoexcept

Definition at line 103 of file FEConfigCokeInfo.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, Exception, and mps_fire::result.

103  {
104  this->checkConnection();
105  result->clear();
106  if (result->getId() == 0 && (result->getConfigTag().empty())) {
107  throw(std::runtime_error("FEConfigCokeInfo::fetchData(): no Id defined for this FEConfigCokeInfo "));
108  }
109 
110  try {
112 
113  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where ( coke_conf_id= :1 or (tag=:2 AND version=:3 ) )");
114  m_readStmt->setInt(1, result->getId());
115  m_readStmt->setString(2, result->getConfigTag());
116  m_readStmt->setInt(3, result->getVersion());
117  ResultSet* rset = m_readStmt->executeQuery();
118 
119  rset->next();
120 
121  // 1 is the id and 2 is the config tag and 3 is the version
122 
123  result->setId(rset->getInt(1));
124  result->setConfigTag(rset->getString(2));
125  result->setVersion(rset->getInt(3));
126 
127  Date dbdate = rset->getDate(4);
128  result->setDBTime(dh.dateToTm(dbdate));
129 
130  } catch (SQLException& e) {
131  throw cms::Exception("SQLException") << "FEConfigCokeInfo::fetchData(): " << e.getMessage();
132  }
133 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
dh
Definition: cuy.py:354

◆ fetchID()

int FEConfigCokeInfo::fetchID ( )
noexcept

Definition at line 158 of file FEConfigCokeInfo.cc.

References MillePedeFileConverter_cfg::e, and Exception.

158  {
159  // Return from memory if available
160  if (m_ID != 0) {
161  return m_ID;
162  }
163 
164  this->checkConnection();
165 
166  try {
167  Statement* stmt = m_conn->createStatement();
168  stmt->setSQL("SELECT coke_conf_id FROM " + getTable() + " WHERE tag=:1 and version=:2 ");
169 
170  stmt->setString(1, getConfigTag());
171  stmt->setInt(2, getVersion());
172 
173  ResultSet* rset = stmt->executeQuery();
174 
175  if (rset->next()) {
176  m_ID = rset->getInt(1);
177  } else {
178  m_ID = 0;
179  }
180  m_conn->terminateStatement(stmt);
181  } catch (SQLException& e) {
182  throw cms::Exception("SQLException") << "FEConfigCokeInfo::fetchID: " << e.getMessage();
183  }
184 
185  return m_ID;
186 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getVersion() const
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30

◆ fetchLastData()

void FEConfigCokeInfo::fetchLastData ( FEConfigCokeInfo result)
privatenoexcept

Definition at line 135 of file FEConfigCokeInfo.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, Exception, and mps_fire::result.

135  {
136  this->checkConnection();
137  result->clear();
138  try {
140 
141  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where coke_conf_id = ( select max( coke_conf_id) from " +
142  getTable() + " ) ");
143  ResultSet* rset = m_readStmt->executeQuery();
144 
145  rset->next();
146 
147  result->setId(rset->getInt(1));
148  result->setConfigTag(rset->getString(2));
149  result->setVersion(rset->getInt(3));
150  Date dbdate = rset->getDate(4);
151  result->setDBTime(dh.dateToTm(dbdate));
152 
153  } catch (SQLException& e) {
154  throw cms::Exception("SQLException") << "FEConfigCokeInfo::fetchData(): " << e.getMessage();
155  }
156 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
dh
Definition: cuy.py:354

◆ fetchNextId()

int FEConfigCokeInfo::fetchNextId ( )
noexcept

Definition at line 29 of file FEConfigCokeInfo.cc.

References MillePedeFileConverter_cfg::e, Exception, and mps_fire::result.

29  {
30  int result = 0;
31  try {
32  this->checkConnection();
33 
34  m_readStmt = m_conn->createStatement();
35  m_readStmt->setSQL("select FE_CONFIG_COKE_SQ.NextVal from DUAL ");
36  ResultSet* rset = m_readStmt->executeQuery();
37  while (rset->next()) {
38  result = rset->getInt(1);
39  }
40  result++;
41  m_conn->terminateStatement(m_readStmt);
42  return result;
43 
44  } catch (SQLException& e) {
45  throw cms::Exception("SQLException") << "FEConfigCokeInfo::fetchNextId(): " << e.getMessage();
46  }
47 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34

◆ getDBTime()

Tm FEConfigCokeInfo::getDBTime ( ) const
inline

Definition at line 30 of file FEConfigCokeInfo.h.

References m_db_time.

30 { return m_db_time; }

◆ getId()

int FEConfigCokeInfo::getId ( void  ) const
inline

Definition at line 22 of file FEConfigCokeInfo.h.

References m_ID.

Referenced by getID().

22 { return m_ID; }

◆ getID()

int FEConfigCokeInfo::getID ( )
inline

Definition at line 25 of file FEConfigCokeInfo.h.

References getId().

25 { return 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.

References m_version.

28 { return m_version; }

◆ operator!=()

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

Definition at line 41 of file FEConfigCokeInfo.h.

References alignCSCRings::r.

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

◆ operator==()

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

Definition at line 40 of file FEConfigCokeInfo.h.

References m_ID, and alignCSCRings::r.

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

◆ prepareWrite()

void FEConfigCokeInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 49 of file FEConfigCokeInfo.cc.

References MillePedeFileConverter_cfg::e, Exception, and getId().

49  {
50  this->checkConnection();
51 
52  int next_id = 0;
53  if (getId() == 0) {
54  next_id = fetchNextId();
55  }
56 
57  try {
58  m_writeStmt = m_conn->createStatement();
59  m_writeStmt->setSQL("INSERT INTO " + getTable() +
60  " ( coke_conf_id, tag, version) "
61  " VALUES ( :1, :2, :3 ) ");
62 
63  m_writeStmt->setInt(1, next_id);
64  m_ID = next_id;
65 
66  } catch (SQLException& e) {
67  throw cms::Exception("SQLException") << "FEConfigCokeInfo::prepareWrite(): " << e.getMessage();
68  }
69 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
std::string getTable() override
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchNextId() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

◆ setByID()

void FEConfigCokeInfo::setByID ( int  id)
noexcept

Definition at line 188 of file FEConfigCokeInfo.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, and Exception.

188  {
189  this->checkConnection();
190 
192 
193  try {
194  Statement* stmt = m_conn->createStatement();
195 
196  stmt->setSQL("SELECT * FROM " + getTable() + " WHERE coke_conf_id = :1");
197  stmt->setInt(1, id);
198 
199  ResultSet* rset = stmt->executeQuery();
200  if (rset->next()) {
201  this->setId(rset->getInt(1));
202  this->setConfigTag(rset->getString(2));
203  this->setVersion(rset->getInt(3));
204 
205  Date dbdate = rset->getDate(4);
206  this->setDBTime(dh.dateToTm(dbdate));
207  } else {
208  throw(std::runtime_error("FEConfigCokeInfo::setByID: Given config_id is not in the database"));
209  }
210 
211  m_conn->terminateStatement(stmt);
212  } catch (SQLException& e) {
213  throw cms::Exception("SQLException") << "FEConfigCokeInfo::setByID: " << e.getMessage();
214  }
215 }
void setId(int id)
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void setVersion(int id)
std::string getTable() override
void setDBTime(const Tm &x)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
void setConfigTag(std::string x)
Definition: IODConfig.h:29
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
dh
Definition: cuy.py:354

◆ setDBTime()

void FEConfigCokeInfo::setDBTime ( const Tm x)
inline

Definition at line 31 of file FEConfigCokeInfo.h.

References m_db_time, and x.

◆ setId()

void FEConfigCokeInfo::setId ( int  id)
inline

Definition at line 21 of file FEConfigCokeInfo.h.

References l1ctLayer2EG_cff::id, and m_ID.

Referenced by setID().

◆ setID()

void FEConfigCokeInfo::setID ( int  id)
inline

Definition at line 24 of file FEConfigCokeInfo.h.

References setId().

24 { setId(id); }
void setId(int id)

◆ setParameters()

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

Definition at line 71 of file FEConfigCokeInfo.cc.

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

◆ setVersion()

void FEConfigCokeInfo::setVersion ( int  id)
inline

Definition at line 27 of file FEConfigCokeInfo.h.

References l1ctLayer2EG_cff::id, and m_version.

◆ writeDB()

void FEConfigCokeInfo::writeDB ( )
privatenoexcept

Definition at line 83 of file FEConfigCokeInfo.cc.

References MillePedeFileConverter_cfg::e, and Exception.

83  {
84  this->checkConnection();
85  this->checkPrepare();
86 
87  try {
88  // number 1 is the id
89  m_writeStmt->setString(2, this->getConfigTag());
90  m_writeStmt->setInt(3, this->getVersion());
91 
92  m_writeStmt->executeUpdate();
93 
94  } catch (SQLException& e) {
95  throw cms::Exception("SQLException") << "FEConfigCokeInfo::writeDB(): " << e.getMessage();
96  }
97  // Now get the ID
98  if (!this->fetchID()) {
99  throw(std::runtime_error("FEConfigCokeInfo::writeDB: Failed to write"));
100  }
101 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false)
int getVersion() const
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36

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