CMS 3D CMS Logo

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

#include <ODDCUConfig.h>

Inheritance diagram for ODDCUConfig:
IODConfig IDBObject

Public Member Functions

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

Private Attributes

int m_ID
 

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 15 of file ODDCUConfig.h.

Constructor & Destructor Documentation

ODDCUConfig::ODDCUConfig ( )

Definition at line 10 of file ODDCUConfig.cc.

References hitfit::clear().

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  clear();
19 
20 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
void clear()
Definition: ODDCUConfig.cc:22
ODDCUConfig::~ODDCUConfig ( )
override

Definition at line 27 of file ODDCUConfig.cc.

28 {
29 }

Member Function Documentation

void ODDCUConfig::clear ( void  )
private

Definition at line 22 of file ODDCUConfig.cc.

Referenced by getId().

22  {
23 }
void ODDCUConfig::fetchData ( ODDCUConfig result)
privatenoexcept

Definition at line 113 of file ODDCUConfig.cc.

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

Referenced by getId().

115 {
116  this->checkConnection();
117  result->clear();
118  if(result->getId()==0 && (result->getConfigTag().empty()) ){
119  throw(std::runtime_error("ODDCUConfig::fetchData(): no Id defined for this ODDCUConfig "));
120  }
121 
122  try {
123 
124  m_readStmt->setSQL("SELECT * "
125  "FROM ECAL_DCU_CONFIGURATION "
126  " where ( dcu_configuration_id = :1 or dcu_tag=:2 ) " );
127  m_readStmt->setInt(1, result->getId());
128  m_readStmt->setString(2, result->getConfigTag());
129  ResultSet* rset = m_readStmt->executeQuery();
130 
131  rset->next();
132  // 1 is the id and 2 is the config tag
133  result->setId(rset->getInt(1));
134  result->setConfigTag(getOraString(rset,2));
135 
136 
137  } catch (SQLException &e) {
138  throw(std::runtime_error(std::string("ODDCUConfig::fetchData(): ")+getOraMessage(&e)));
139  }
140 }
void setId(int id)
Definition: ODDCUConfig.h:24
int getId() const
Definition: ODDCUConfig.h:25
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void clear()
Definition: ODDCUConfig.cc:22
int ODDCUConfig::fetchID ( )
privatenoexcept

Definition at line 142 of file ODDCUConfig.cc.

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

Referenced by getId().

143 {
144  // Return from memory if available
145  if (m_ID!=0) {
146  return m_ID;
147  }
148 
149  this->checkConnection();
150 
151  try {
152  Statement* stmt = m_conn->createStatement();
153  stmt->setSQL("SELECT dcu_configuration_id FROM ecal_dcu_configuration "
154  "WHERE dcu_tag=:dcu_tag " );
155 
156  stmt->setString(1, getConfigTag());
157 
158  ResultSet* rset = stmt->executeQuery();
159 
160  if (rset->next()) {
161  m_ID = rset->getInt(1);
162  } else {
163  m_ID = 0;
164  }
165  m_conn->terminateStatement(stmt);
166  } catch (SQLException &e) {
167  throw(std::runtime_error(std::string("ODDCUConfig::fetchID: ")+getOraMessage(&e)));
168  }
169 
170  return m_ID;
171 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
int ODDCUConfig::fetchNextId ( )
privatenoexcept

Definition at line 44 of file ODDCUConfig.cc.

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

Referenced by getId().

44  {
45 
46  int result=0;
47  try {
48  this->checkConnection();
49 
50  m_readStmt = m_conn->createStatement();
51  m_readStmt->setSQL("select ecal_dcu_config_sq.NextVal from dual");
52  ResultSet* rset = m_readStmt->executeQuery();
53  while (rset->next ()){
54  result= rset->getInt(1);
55  }
56  m_conn->terminateStatement(m_readStmt);
57  return result;
58 
59  } catch (SQLException &e) {
60  throw(std::runtime_error(std::string("ODDCUConfig::fetchNextId(): ")+getOraMessage(&e)));
61  }
62 
63 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
int ODDCUConfig::getId ( void  ) const
inline
std::string ODDCUConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODDCUConfig.h.

22 { return "ECAL_DCU_CONFIGURATION"; }
void ODDCUConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 66 of file ODDCUConfig.cc.

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

Referenced by getId().

68 {
69  this->checkConnection();
70  int next_id=fetchNextId();
71 
72  try {
73  m_writeStmt = m_conn->createStatement();
74  m_writeStmt->setSQL("INSERT INTO ECAL_DCU_CONFIGURATION ( dcu_configuration_id, dcu_tag ) "
75  "VALUES ( "
76  ":1, :2 )");
77  m_writeStmt->setInt(1, next_id);
78  m_ID=next_id;
79 
80  } catch (SQLException &e) {
81  throw(std::runtime_error(std::string("ODDCUConfig::prepareWrite(): ")+getOraMessage(&e)));
82  }
83 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int fetchNextId() noexcept(false)
Definition: ODDCUConfig.cc:44
void ODDCUConfig::setId ( int  id)
inline

Definition at line 24 of file ODDCUConfig.h.

References triggerObjects_cff::id, and m_ID.

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

Definition at line 31 of file ODDCUConfig.cc.

Referenced by getId().

31  {
32 
33  // parses the result of the XML parser that is a map of
34  // string string with variable name variable value
35 
36  for( std::map<std::string, std::string >::const_iterator ci=
37  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
38 
39  if(ci->first== "DCU_CONFIGURATION_ID") setConfigTag(ci->second);
40  }
41 
42 }
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void ODDCUConfig::writeDB ( )
privatenoexcept

Definition at line 87 of file ODDCUConfig.cc.

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

Referenced by getId().

89 {
90  this->checkConnection();
91  this->checkPrepare();
92 
93  try {
94 
95  m_writeStmt->setString(2, this->getConfigTag());
96 
97  m_writeStmt->executeUpdate();
98 
99 
100  } catch (SQLException &e) {
101  throw(std::runtime_error(std::string("ODDCUConfig::writeDB(): ")+getOraMessage(&e)));
102  }
103  // Now get the ID
104  if (!this->fetchID()) {
105  throw(std::runtime_error("ODDCUConfig::writeDB: Failed to write"));
106  }
107 
108 
109 }
Statement * m_writeStmt
Definition: IODConfig.h:36
int fetchID() noexcept(false)
Definition: ODDCUConfig.cc:142
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODDCUConfig.h.

Member Data Documentation

int ODDCUConfig::m_ID
private

Definition at line 40 of file ODDCUConfig.h.

Referenced by getId(), and setId().