CMS 3D CMS Logo

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

#include <FEConfigBadXTInfo.h>

Inheritance diagram for FEConfigBadXTInfo:
IODConfig IDBObject

Public Member Functions

 FEConfigBadXTInfo ()
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
int getId () const
 
std::string getTable () override
 
int getVersion () const
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setVersion (int id)
 
 ~FEConfigBadXTInfo () 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 (FEConfigBadXTInfo *result) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

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 9 of file FEConfigBadXTInfo.h.

Constructor & Destructor Documentation

◆ FEConfigBadXTInfo()

FEConfigBadXTInfo::FEConfigBadXTInfo ( )

Definition at line 11 of file FEConfigBadXTInfo.cc.

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

References clear().

◆ ~FEConfigBadXTInfo()

FEConfigBadXTInfo::~FEConfigBadXTInfo ( )
override

Definition at line 24 of file FEConfigBadXTInfo.cc.

24 {}

Member Function Documentation

◆ clear()

void FEConfigBadXTInfo::clear ( void  )
private

Definition at line 22 of file FEConfigBadXTInfo.cc.

22 {}

◆ fetchData()

void FEConfigBadXTInfo::fetchData ( FEConfigBadXTInfo result)
privatenoexcept

Definition at line 107 of file FEConfigBadXTInfo.cc.

107  {
108  this->checkConnection();
109  result->clear();
110  if (result->getId() == 0 && (result->getConfigTag().empty())) {
111  throw(std::runtime_error("FEConfigBadXTInfo::fetchData(): no Id defined for this FEConfigBadXTInfo "));
112  }
113 
114  try {
115  if (result->getId() != 0) {
116  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where rec_id = :1 ");
117  m_readStmt->setInt(1, result->getId());
118  } else if (!result->getConfigTag().empty()) {
119  m_readStmt->setSQL("SELECT * FROM " + getTable() + " where tag=:1 AND version=:2 ");
120  m_readStmt->setString(1, result->getConfigTag());
121  m_readStmt->setInt(2, result->getVersion());
122  } else {
123  // we should never pass here
124  throw(std::runtime_error("FEConfigBadXTInfo::fetchData(): no Id defined for this record "));
125  }
126 
127  ResultSet* rset = m_readStmt->executeQuery();
128 
129  rset->next();
130 
131  // 1 is the id and 2 is the config tag and 3 is the version
132 
133  result->setId(rset->getInt(1));
134  result->setConfigTag(rset->getString(2));
135  result->setVersion(rset->getInt(3));
136 
137  } catch (SQLException& e) {
138  throw(std::runtime_error(std::string("FEConfigBadXTInfo::fetchData(): ") + e.getMessage()));
139  }
140 }

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

◆ fetchID()

int FEConfigBadXTInfo::fetchID ( )
noexcept

Definition at line 142 of file FEConfigBadXTInfo.cc.

142  {
143  // Return from memory if available
144  if (m_ID != 0) {
145  return m_ID;
146  }
147 
148  this->checkConnection();
149 
150  try {
151  Statement* stmt = m_conn->createStatement();
152  stmt->setSQL("SELECT rec_id FROM " + getTable() + "WHERE tag=:1 and version=:2 ");
153 
154  stmt->setString(1, getConfigTag());
155  stmt->setInt(2, getVersion());
156 
157  ResultSet* rset = stmt->executeQuery();
158 
159  if (rset->next()) {
160  m_ID = rset->getInt(1);
161  } else {
162  m_ID = 0;
163  }
164  m_conn->terminateStatement(stmt);
165  } catch (SQLException& e) {
166  throw(std::runtime_error(std::string("FEConfigBadXTInfo::fetchID: ") + e.getMessage()));
167  }
168 
169  return m_ID;
170 }

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

◆ fetchNextId()

int FEConfigBadXTInfo::fetchNextId ( )
noexcept

Definition at line 26 of file FEConfigBadXTInfo.cc.

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

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

◆ getId()

int FEConfigBadXTInfo::getId ( void  ) const
inline

Definition at line 19 of file FEConfigBadXTInfo.h.

19 { return m_ID; }

References m_ID.

◆ getTable()

std::string FEConfigBadXTInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file FEConfigBadXTInfo.h.

16 { return "FE_CONFIG_BadCrystals_INFO"; }

◆ getVersion()

int FEConfigBadXTInfo::getVersion ( ) const
inline

Definition at line 24 of file FEConfigBadXTInfo.h.

24 { return m_version; }

References m_version.

◆ prepareWrite()

void FEConfigBadXTInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 46 of file FEConfigBadXTInfo.cc.

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

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

◆ setId()

void FEConfigBadXTInfo::setId ( int  id)
inline

Definition at line 18 of file FEConfigBadXTInfo.h.

18 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

Referenced by popcon::EcalTPGBadXTHandler::getNewObjects().

◆ setParameters()

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

Definition at line 68 of file FEConfigBadXTInfo.cc.

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

◆ setVersion()

void FEConfigBadXTInfo::setVersion ( int  id)
inline

Definition at line 23 of file FEConfigBadXTInfo.h.

23 { m_version = id; }

References triggerObjects_cff::id, and m_version.

◆ writeDB()

void FEConfigBadXTInfo::writeDB ( )
privatenoexcept

Definition at line 80 of file FEConfigBadXTInfo.cc.

80  {
81  this->checkConnection();
82  this->checkPrepare();
83 
84  try {
85  // number 1 is the id
86  m_writeStmt->setString(2, this->getConfigTag());
87  m_writeStmt->setInt(3, this->getVersion());
88 
89  m_writeStmt->executeUpdate();
90 
91  } catch (SQLException& e) {
92  throw(std::runtime_error(std::string("FEConfigBadXTInfo::writeDB(): ") + e.getMessage()));
93  }
94  // Now get the ID
95  if (!this->fetchID()) {
96  throw(std::runtime_error("FEConfigBadXTInfo::writeDB: Failed to write"));
97  } else {
98  int old_version = this->getVersion();
99  m_readStmt = m_conn->createStatement();
100  this->fetchData(this);
101  m_conn->terminateStatement(m_readStmt);
102  if (this->getVersion() != old_version)
103  std::cout << "FEConfigBadXTInfo>>WARNING version is " << getVersion() << endl;
104  }
105 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 11 of file FEConfigBadXTInfo.h.

Member Data Documentation

◆ m_ID

int FEConfigBadXTInfo::m_ID
private

Definition at line 40 of file FEConfigBadXTInfo.h.

Referenced by getId(), and setId().

◆ m_version

int FEConfigBadXTInfo::m_version
private

Definition at line 41 of file FEConfigBadXTInfo.h.

Referenced by getVersion(), and setVersion().

FEConfigBadXTInfo::getId
int getId() const
Definition: FEConfigBadXTInfo.h:19
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
gather_cfg.cout
cout
Definition: gather_cfg.py:144
FEConfigBadXTInfo::clear
void clear()
Definition: FEConfigBadXTInfo.cc:22
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
FEConfigBadXTInfo::fetchID
int fetchID() noexcept(false)
Definition: FEConfigBadXTInfo.cc:142
FEConfigBadXTInfo::fetchNextId
int fetchNextId() noexcept(false)
Definition: FEConfigBadXTInfo.cc:26
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
FEConfigBadXTInfo::getTable
std::string getTable() override
Definition: FEConfigBadXTInfo.h:16
IODConfig::checkPrepare
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
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
FEConfigBadXTInfo::fetchData
void fetchData(FEConfigBadXTInfo *result) noexcept(false)
Definition: FEConfigBadXTInfo.cc:107
FEConfigBadXTInfo::getVersion
int getVersion() const
Definition: FEConfigBadXTInfo.h:24
FEConfigBadXTInfo::m_ID
int m_ID
Definition: FEConfigBadXTInfo.h:40
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
FEConfigBadXTInfo::setVersion
void setVersion(int id)
Definition: FEConfigBadXTInfo.h:23
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
IODConfig::m_config_tag
std::string m_config_tag
Definition: IODConfig.h:25
FEConfigBadXTInfo::m_version
int m_version
Definition: FEConfigBadXTInfo.h:41
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
mps_fire.result
result
Definition: mps_fire.py:303
IODConfig::setConfigTag
void setConfigTag(std::string x)
Definition: IODConfig.h:29
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37