CMS 3D CMS Logo

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

#include <FEConfigOddWeightInfo.h>

Inheritance diagram for FEConfigOddWeightInfo:
IODConfig IDBObject

Public Member Functions

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

Private Attributes

Tm m_db_time
 
int m_ID
 
int m_ngr
 
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 FEConfigOddWeightInfo.h.

Constructor & Destructor Documentation

◆ FEConfigOddWeightInfo()

FEConfigOddWeightInfo::FEConfigOddWeightInfo ( )

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

◆ ~FEConfigOddWeightInfo()

FEConfigOddWeightInfo::~FEConfigOddWeightInfo ( )
override

Definition at line 26 of file FEConfigOddWeightInfo.cc.

26 {}

Member Function Documentation

◆ clear()

void FEConfigOddWeightInfo::clear ( void  )
private

Definition at line 24 of file FEConfigOddWeightInfo.cc.

24 { m_ngr = 0; }

◆ fetchData()

void FEConfigOddWeightInfo::fetchData ( FEConfigOddWeightInfo result)
privatenoexcept

Definition at line 102 of file FEConfigOddWeightInfo.cc.

102  {
103  this->checkConnection();
104  result->clear();
105  if (result->getId() == 0 && (result->getConfigTag().empty())) {
106  throw(std::runtime_error("FEConfigOddWeightInfo::fetchData(): no Id defined for this FEConfigOddWeightInfo "));
107  }
108 
109  try {
111 
112  m_readStmt->setSQL("SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
113  " where ( wei2_conf_id= :1 or (tag=:2 ) )");
114  m_readStmt->setInt(1, result->getId());
115  m_readStmt->setString(2, result->getConfigTag());
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->setNumberOfGroups(rset->getInt(3));
125  Date dbdate = rset->getDate(4);
126  result->setDBTime(dh.dateToTm(dbdate));
127 
128  } catch (SQLException& e) {
129  throw(std::runtime_error(std::string("FEConfigOddWeightInfo::fetchData(): ") + e.getMessage()));
130  }
131 }

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

◆ fetchID()

int FEConfigOddWeightInfo::fetchID ( )
noexcept

Definition at line 156 of file FEConfigOddWeightInfo.cc.

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

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

◆ fetchLastData()

void FEConfigOddWeightInfo::fetchLastData ( FEConfigOddWeightInfo result)
privatenoexcept

Definition at line 133 of file FEConfigOddWeightInfo.cc.

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

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

◆ fetchNextId()

int FEConfigOddWeightInfo::fetchNextId ( )
noexcept

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

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

◆ getDBTime()

Tm FEConfigOddWeightInfo::getDBTime ( ) const
inline

Definition at line 33 of file FEConfigOddWeightInfo.h.

33 { return m_db_time; }

References m_db_time.

◆ getID()

int FEConfigOddWeightInfo::getID ( )
inline

Definition at line 28 of file FEConfigOddWeightInfo.h.

28 { return getId(); }

References getId().

◆ getId()

int FEConfigOddWeightInfo::getId ( void  ) const
inline

Definition at line 25 of file FEConfigOddWeightInfo.h.

25 { return m_ID; }

References m_ID.

Referenced by getID().

◆ getNumberOfGroups()

int FEConfigOddWeightInfo::getNumberOfGroups ( ) const
inline

Definition at line 22 of file FEConfigOddWeightInfo.h.

22 { return m_ngr; }

References m_ngr.

◆ getTable()

std::string FEConfigOddWeightInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file FEConfigOddWeightInfo.h.

19 { return "FE_CONFIG_WEIGHT2_INFO"; }

◆ getVersion()

int FEConfigOddWeightInfo::getVersion ( ) const
inline

Definition at line 31 of file FEConfigOddWeightInfo.h.

31 { return m_version; }

References m_version.

◆ operator!=()

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

Definition at line 44 of file FEConfigOddWeightInfo.h.

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

References alignCSCRings::r.

◆ operator==()

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

Definition at line 43 of file FEConfigOddWeightInfo.h.

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

References m_ID, and alignCSCRings::r.

◆ prepareWrite()

void FEConfigOddWeightInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 48 of file FEConfigOddWeightInfo.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  " ( wei2_conf_id, tag, number_of_groups) "
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("FEConfigOddWeightInfo::prepareWrite(): ") + e.getMessage()));
67  }
68 }

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

◆ setByID()

void FEConfigOddWeightInfo::setByID ( int  id)
noexcept

Definition at line 185 of file FEConfigOddWeightInfo.cc.

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

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

◆ setDBTime()

void FEConfigOddWeightInfo::setDBTime ( const Tm x)
inline

Definition at line 34 of file FEConfigOddWeightInfo.h.

34 { m_db_time = x; }

References m_db_time, and x.

◆ setId()

void FEConfigOddWeightInfo::setId ( int  id)
inline

◆ setID()

void FEConfigOddWeightInfo::setID ( int  id)
inline

Definition at line 27 of file FEConfigOddWeightInfo.h.

27 { setId(id); }

References setId().

◆ setNumberOfGroups()

void FEConfigOddWeightInfo::setNumberOfGroups ( int  n)
inline

Definition at line 21 of file FEConfigOddWeightInfo.h.

21 { m_ngr = n; }

References m_ngr, and dqmiodumpmetadata::n.

◆ setParameters()

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

Definition at line 70 of file FEConfigOddWeightInfo.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 == "TAG")
76  setConfigTag(ci->second);
77  if (ci->first == "NUMBER_OF_GROUPS")
78  setNumberOfGroups(atoi(ci->second.c_str()));
79  }
80 }

◆ setVersion()

void FEConfigOddWeightInfo::setVersion ( int  id)
inline

Definition at line 30 of file FEConfigOddWeightInfo.h.

30 { m_version = id; }

References triggerObjects_cff::id, and m_version.

◆ writeDB()

void FEConfigOddWeightInfo::writeDB ( )
privatenoexcept

Definition at line 82 of file FEConfigOddWeightInfo.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->getNumberOfGroups());
90 
91  m_writeStmt->executeUpdate();
92 
93  } catch (SQLException& e) {
94  throw(std::runtime_error(std::string("FEConfigOddWeightInfo::writeDB(): ") + e.getMessage()));
95  }
96  // Now get the ID
97  if (!this->fetchID()) {
98  throw(std::runtime_error("FEConfigOddWeightInfo::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 FEConfigOddWeightInfo.h.

Member Data Documentation

◆ m_db_time

Tm FEConfigOddWeightInfo::m_db_time
private

Definition at line 50 of file FEConfigOddWeightInfo.h.

Referenced by getDBTime(), and setDBTime().

◆ m_ID

int FEConfigOddWeightInfo::m_ID
private

Definition at line 49 of file FEConfigOddWeightInfo.h.

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

◆ m_ngr

int FEConfigOddWeightInfo::m_ngr
private

Definition at line 48 of file FEConfigOddWeightInfo.h.

Referenced by getNumberOfGroups(), and setNumberOfGroups().

◆ m_version

int FEConfigOddWeightInfo::m_version
private

Definition at line 51 of file FEConfigOddWeightInfo.h.

Referenced by getVersion(), and setVersion().

dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
FEConfigOddWeightInfo::getId
int getId() const
Definition: FEConfigOddWeightInfo.h:25
FEConfigOddWeightInfo::setDBTime
void setDBTime(const Tm &x)
Definition: FEConfigOddWeightInfo.h:34
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
FEConfigOddWeightInfo::fetchNextId
int fetchNextId() noexcept(false)
Definition: FEConfigOddWeightInfo.cc:28
FEConfigOddWeightInfo::m_db_time
Tm m_db_time
Definition: FEConfigOddWeightInfo.h:50
FEConfigOddWeightInfo::fetchID
int fetchID() noexcept(false)
Definition: FEConfigOddWeightInfo.cc:156
DDAxes::x
FEConfigOddWeightInfo::m_version
int m_version
Definition: FEConfigOddWeightInfo.h:51
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
FEConfigOddWeightInfo::setId
void setId(int id)
Definition: FEConfigOddWeightInfo.h:24
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
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
FEConfigOddWeightInfo::setNumberOfGroups
void setNumberOfGroups(int n)
Definition: FEConfigOddWeightInfo.h:21
IODConfig::m_readStmt
Statement * m_readStmt
Definition: IODConfig.h:34
FEConfigOddWeightInfo::getTable
std::string getTable() override
Definition: FEConfigOddWeightInfo.h:19
alignCSCRings.r
r
Definition: alignCSCRings.py:93
FEConfigOddWeightInfo::m_ngr
int m_ngr
Definition: FEConfigOddWeightInfo.h:48
FEConfigOddWeightInfo::getNumberOfGroups
int getNumberOfGroups() const
Definition: FEConfigOddWeightInfo.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
FEConfigOddWeightInfo::m_ID
int m_ID
Definition: FEConfigOddWeightInfo.h:49
FEConfigOddWeightInfo::clear
void clear()
Definition: FEConfigOddWeightInfo.cc:24
DateHandler
Definition: DateHandler.h:7
cuy.dh
dh
Definition: cuy.py:355
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37