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::ODDCUConfig ( )

Definition at line 10 of file ODDCUConfig.cc.

References l1ct::clear().

10  {
11  m_env = nullptr;
12  m_conn = nullptr;
13  m_writeStmt = nullptr;
14  m_readStmt = nullptr;
15  m_config_tag = "";
16  m_ID = 0;
17  clear();
18 }
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
void clear()
Definition: ODDCUConfig.cc:20

◆ ~ODDCUConfig()

ODDCUConfig::~ODDCUConfig ( )
override

Definition at line 22 of file ODDCUConfig.cc.

22 {}

Member Function Documentation

◆ clear()

void ODDCUConfig::clear ( void  )
private

Definition at line 20 of file ODDCUConfig.cc.

20 {}

◆ fetchData()

void ODDCUConfig::fetchData ( ODDCUConfig result)
privatenoexcept

Definition at line 89 of file ODDCUConfig.cc.

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

89  {
90  this->checkConnection();
91  result->clear();
92  if (result->getId() == 0 && (result->getConfigTag().empty())) {
93  throw(std::runtime_error("ODDCUConfig::fetchData(): no Id defined for this ODDCUConfig "));
94  }
95 
96  try {
97  m_readStmt->setSQL(
98  "SELECT * "
99  "FROM ECAL_DCU_CONFIGURATION "
100  " where ( dcu_configuration_id = :1 or dcu_tag=:2 ) ");
101  m_readStmt->setInt(1, result->getId());
102  m_readStmt->setString(2, result->getConfigTag());
103  ResultSet* rset = m_readStmt->executeQuery();
104 
105  rset->next();
106  // 1 is the id and 2 is the config tag
107  result->setId(rset->getInt(1));
108  result->setConfigTag(rset->getString(2));
109 
110  } catch (SQLException& e) {
111  throw(std::runtime_error(std::string("ODDCUConfig::fetchData(): ") + e.getMessage()));
112  }
113 }
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
void clear()
Definition: ODDCUConfig.cc:20

◆ fetchID()

int ODDCUConfig::fetchID ( )
privatenoexcept

Definition at line 115 of file ODDCUConfig.cc.

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

115  {
116  // Return from memory if available
117  if (m_ID != 0) {
118  return m_ID;
119  }
120 
121  this->checkConnection();
122 
123  try {
124  Statement* stmt = m_conn->createStatement();
125  stmt->setSQL(
126  "SELECT dcu_configuration_id FROM ecal_dcu_configuration "
127  "WHERE dcu_tag=:dcu_tag ");
128 
129  stmt->setString(1, getConfigTag());
130 
131  ResultSet* rset = stmt->executeQuery();
132 
133  if (rset->next()) {
134  m_ID = rset->getInt(1);
135  } else {
136  m_ID = 0;
137  }
138  m_conn->terminateStatement(stmt);
139  } catch (SQLException& e) {
140  throw(std::runtime_error(std::string("ODDCUConfig::fetchID: ") + e.getMessage()));
141  }
142 
143  return m_ID;
144 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30

◆ fetchNextId()

int ODDCUConfig::fetchNextId ( )
privatenoexcept

Definition at line 34 of file ODDCUConfig.cc.

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

34  {
35  int result = 0;
36  try {
37  this->checkConnection();
38 
39  m_readStmt = m_conn->createStatement();
40  m_readStmt->setSQL("select ecal_dcu_config_sq.NextVal from dual");
41  ResultSet* rset = m_readStmt->executeQuery();
42  while (rset->next()) {
43  result = rset->getInt(1);
44  }
45  m_conn->terminateStatement(m_readStmt);
46  return result;
47 
48  } catch (SQLException& e) {
49  throw(std::runtime_error(std::string("ODDCUConfig::fetchNextId(): ") + e.getMessage()));
50  }
51 }
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

◆ getId()

int ODDCUConfig::getId ( void  ) const
inline

Definition at line 25 of file ODDCUConfig.h.

References m_ID.

25 { return m_ID; }

◆ getTable()

std::string ODDCUConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODDCUConfig.h.

22 { return "ECAL_DCU_CONFIGURATION"; }

◆ prepareWrite()

void ODDCUConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 53 of file ODDCUConfig.cc.

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

53  {
54  this->checkConnection();
55  int next_id = fetchNextId();
56 
57  try {
58  m_writeStmt = m_conn->createStatement();
59  m_writeStmt->setSQL(
60  "INSERT INTO ECAL_DCU_CONFIGURATION ( dcu_configuration_id, dcu_tag ) "
61  "VALUES ( "
62  ":1, :2 )");
63  m_writeStmt->setInt(1, next_id);
64  m_ID = next_id;
65 
66  } catch (SQLException& e) {
67  throw(std::runtime_error(std::string("ODDCUConfig::prepareWrite(): ") + e.getMessage()));
68  }
69 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int fetchNextId() noexcept(false)
Definition: ODDCUConfig.cc:34

◆ setId()

void ODDCUConfig::setId ( int  id)
inline

Definition at line 24 of file ODDCUConfig.h.

References l1ctLayer2EG_cff::id, and m_ID.

◆ setParameters()

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

Definition at line 24 of file ODDCUConfig.cc.

24  {
25  // parses the result of the XML parser that is a map of
26  // string string with variable name variable value
27 
28  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
29  if (ci->first == "DCU_CONFIGURATION_ID")
30  setConfigTag(ci->second);
31  }
32 }
void setConfigTag(std::string x)
Definition: IODConfig.h:29

◆ writeDB()

void ODDCUConfig::writeDB ( )
privatenoexcept

Definition at line 71 of file ODDCUConfig.cc.

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

71  {
72  this->checkConnection();
73  this->checkPrepare();
74 
75  try {
76  m_writeStmt->setString(2, this->getConfigTag());
77 
78  m_writeStmt->executeUpdate();
79 
80  } catch (SQLException& e) {
81  throw(std::runtime_error(std::string("ODDCUConfig::writeDB(): ") + e.getMessage()));
82  }
83  // Now get the ID
84  if (!this->fetchID()) {
85  throw(std::runtime_error("ODDCUConfig::writeDB: Failed to write"));
86  }
87 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int fetchID() noexcept(false)
Definition: ODDCUConfig.cc:115
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 17 of file ODDCUConfig.h.

Member Data Documentation

◆ m_ID

int ODDCUConfig::m_ID
private

Definition at line 39 of file ODDCUConfig.h.

Referenced by getId(), and setId().