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

Constructor & Destructor Documentation

◆ FEConfigOddWeightInfo()

FEConfigOddWeightInfo::FEConfigOddWeightInfo ( )

Definition at line 14 of file FEConfigOddWeightInfo.cc.

References 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

◆ ~FEConfigOddWeightInfo()

FEConfigOddWeightInfo::~FEConfigOddWeightInfo ( )
override

Definition at line 27 of file FEConfigOddWeightInfo.cc.

27 {}

Member Function Documentation

◆ clear()

void FEConfigOddWeightInfo::clear ( void  )
private

Definition at line 25 of file FEConfigOddWeightInfo.cc.

◆ fetchData()

void FEConfigOddWeightInfo::fetchData ( FEConfigOddWeightInfo result)
privatenoexcept

Definition at line 103 of file FEConfigOddWeightInfo.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("FEConfigOddWeightInfo::fetchData(): no Id defined for this FEConfigOddWeightInfo "));
108  }
109 
110  try {
112 
113  m_readStmt->setSQL("SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
114  " where ( wei2_conf_id= :1 or (tag=:2 ) )");
115  m_readStmt->setInt(1, result->getId());
116  m_readStmt->setString(2, result->getConfigTag());
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->setNumberOfGroups(rset->getInt(3));
126  Date dbdate = rset->getDate(4);
127  result->setDBTime(dh.dateToTm(dbdate));
128 
129  } catch (SQLException& e) {
130  throw cms::Exception("SQLException") << "FEConfigOddWeightInfo::fetchData(): " << e.getMessage();
131  }
132 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
dh
Definition: cuy.py:354

◆ fetchID()

int FEConfigOddWeightInfo::fetchID ( )
noexcept

Definition at line 157 of file FEConfigOddWeightInfo.cc.

References MillePedeFileConverter_cfg::e, and Exception.

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 wei2_conf_id FROM " + getTable() + " WHERE tag=:1 ");
168 
169  stmt->setString(1, getConfigTag());
170 
171  ResultSet* rset = stmt->executeQuery();
172 
173  if (rset->next()) {
174  m_ID = rset->getInt(1);
175  } else {
176  m_ID = 0;
177  }
178  m_conn->terminateStatement(stmt);
179  } catch (SQLException& e) {
180  throw cms::Exception("SQLException") << "FEConfigOddWeightInfo::fetchID: " << e.getMessage();
181  }
182 
183  return m_ID;
184 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
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 FEConfigOddWeightInfo::fetchLastData ( FEConfigOddWeightInfo result)
privatenoexcept

Definition at line 134 of file FEConfigOddWeightInfo.cc.

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

134  {
135  this->checkConnection();
136  result->clear();
137  try {
139 
140  m_readStmt->setSQL("SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
141  " where wei2_conf_id = ( select max( wei2_conf_id) from " + 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->setNumberOfGroups(rset->getInt(3));
149  Date dbdate = rset->getDate(4);
150  result->setDBTime(dh.dateToTm(dbdate));
151 
152  } catch (SQLException& e) {
153  throw cms::Exception("SQLException") << "FEConfigOddWeightInfo::fetchData(): " << e.getMessage();
154  }
155 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
dh
Definition: cuy.py:354

◆ fetchNextId()

int FEConfigOddWeightInfo::fetchNextId ( )
noexcept

Definition at line 29 of file FEConfigOddWeightInfo.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_WEIGHT2GROUP_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") << "FEConfigOddWeightInfo::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 FEConfigOddWeightInfo::getDBTime ( ) const
inline

Definition at line 33 of file FEConfigOddWeightInfo.h.

References m_db_time.

◆ getId()

int FEConfigOddWeightInfo::getId ( void  ) const
inline

Definition at line 25 of file FEConfigOddWeightInfo.h.

References m_ID.

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

25 { return m_ID; }

◆ getID()

int FEConfigOddWeightInfo::getID ( )
inline

Definition at line 28 of file FEConfigOddWeightInfo.h.

References getId().

28 { return getId(); }

◆ getNumberOfGroups()

int FEConfigOddWeightInfo::getNumberOfGroups ( ) const
inline

Definition at line 22 of file FEConfigOddWeightInfo.h.

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.

References m_version.

◆ operator!=()

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

Definition at line 44 of file FEConfigOddWeightInfo.h.

References alignCSCRings::r.

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

◆ operator==()

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

Definition at line 43 of file FEConfigOddWeightInfo.h.

References m_ID, and alignCSCRings::r.

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

◆ prepareWrite()

void FEConfigOddWeightInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 49 of file FEConfigOddWeightInfo.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  " ( wei2_conf_id, tag, number_of_groups) "
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") << "FEConfigOddWeightInfo::prepareWrite(): " << e.getMessage();
68  }
69 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
int fetchNextId() noexcept(false)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

◆ setByID()

void FEConfigOddWeightInfo::setByID ( int  id)
noexcept

Definition at line 186 of file FEConfigOddWeightInfo.cc.

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

186  {
187  this->checkConnection();
188 
190 
191  try {
192  Statement* stmt = m_conn->createStatement();
193 
194  stmt->setSQL("SELECT wei2_conf_id, tag, number_of_groups, db_timestamp FROM " + getTable() +
195  " WHERE wei2_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->setNumberOfGroups(rset->getInt(3));
203  Date dbdate = rset->getDate(4);
204  this->setDBTime(dh.dateToTm(dbdate));
205  } else {
206  throw(std::runtime_error("FEConfigOddWeightInfo::setByID: Given config_id is not in the database"));
207  }
208 
209  m_conn->terminateStatement(stmt);
210  } catch (SQLException& e) {
211  throw cms::Exception("SQLException") << "FEConfigOddWeightInfo::setByID: " << e.getMessage();
212  }
213 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setDBTime(const Tm &x)
std::string getTable() override
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 FEConfigOddWeightInfo::setDBTime ( const Tm x)
inline

Definition at line 34 of file FEConfigOddWeightInfo.h.

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.

References setId().

27 { setId(id); }

◆ setNumberOfGroups()

void FEConfigOddWeightInfo::setNumberOfGroups ( int  n)
inline

◆ setParameters()

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

Definition at line 71 of file FEConfigOddWeightInfo.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 == "TAG")
77  setConfigTag(ci->second);
78  if (ci->first == "NUMBER_OF_GROUPS")
79  setNumberOfGroups(atoi(ci->second.c_str()));
80  }
81 }
void setConfigTag(std::string x)
Definition: IODConfig.h:29

◆ setVersion()

void FEConfigOddWeightInfo::setVersion ( int  id)
inline

◆ writeDB()

void FEConfigOddWeightInfo::writeDB ( )
privatenoexcept

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