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

Constructor & Destructor Documentation

◆ ODDCUConfig()

ODDCUConfig::ODDCUConfig ( )

Definition at line 10 of file ODDCUConfig.cc.

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 }

References clear().

◆ ~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.

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 }

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

◆ fetchID()

int ODDCUConfig::fetchID ( )
privatenoexcept

Definition at line 115 of file ODDCUConfig.cc.

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 }

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

◆ fetchNextId()

int ODDCUConfig::fetchNextId ( )
privatenoexcept

Definition at line 34 of file ODDCUConfig.cc.

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 }

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

◆ getId()

int ODDCUConfig::getId ( void  ) const
inline

Definition at line 25 of file ODDCUConfig.h.

25 { return m_ID; }

References 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.

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 }

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

◆ setId()

void ODDCUConfig::setId ( int  id)
inline

Definition at line 24 of file ODDCUConfig.h.

24 { m_ID = id; }

References triggerObjects_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 }

◆ writeDB()

void ODDCUConfig::writeDB ( )
privatenoexcept

Definition at line 71 of file ODDCUConfig.cc.

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 }

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

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().

IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
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
ODDCUConfig::clear
void clear()
Definition: ODDCUConfig.cc:20
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
ODDCUConfig::m_ID
int m_ID
Definition: ODDCUConfig.h:39
ODDCUConfig::fetchID
int fetchID() noexcept(false)
Definition: ODDCUConfig.cc:115
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
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
ODDCUConfig::fetchNextId
int fetchNextId() noexcept(false)
Definition: ODDCUConfig.cc:34
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37