CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
 ODDCUConfig ()
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
 ~ODDCUConfig ()
 
- 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) throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
int fetchNextId () throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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(), and NULL.

11 {
12  m_env = NULL;
13  m_conn = NULL;
14  m_writeStmt = NULL;
15  m_readStmt = NULL;
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
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
void clear()
Definition: ODDCUConfig.cc:22
ODDCUConfig::~ODDCUConfig ( )

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.

22  {
23 }
void ODDCUConfig::fetchData ( ODDCUConfig result)
throw (std::runtime_error
)
private

Definition at line 113 of file ODDCUConfig.cc.

References alignCSCRings::e, and query::result.

115 {
116  this->checkConnection();
117  result->clear();
118  if(result->getId()==0 && (result->getConfigTag()=="") ){
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(rset->getString(2));
135 
136 
137  } catch (SQLException &e) {
138  throw(std::runtime_error("ODDCUConfig::fetchData(): "+e.getMessage()));
139  }
140 }
void setId(int id)
Definition: ODDCUConfig.h:24
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getId() const
Definition: ODDCUConfig.h:25
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void clear()
Definition: ODDCUConfig.cc:22
void checkConnection() const
Definition: IDBObject.h:41
int ODDCUConfig::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 142 of file ODDCUConfig.cc.

References alignCSCRings::e.

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("ODDCUConfig::fetchID: "+e.getMessage()));
168  }
169 
170  return m_ID;
171 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
int ODDCUConfig::fetchNextId ( )
throw (std::runtime_error
)
private

Definition at line 44 of file ODDCUConfig.cc.

References alignCSCRings::e, and query::result.

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("ODDCUConfig::fetchNextId(): "+e.getMessage()));
61  }
62 
63 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
int ODDCUConfig::getId ( ) const
inline

Definition at line 25 of file ODDCUConfig.h.

References m_ID.

25 { return m_ID; }
std::string ODDCUConfig::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 22 of file ODDCUConfig.h.

22 { return "ECAL_DCU_CONFIGURATION"; }
void ODDCUConfig::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 66 of file ODDCUConfig.cc.

References alignCSCRings::e.

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("ODDCUConfig::prepareWrite(): "+e.getMessage()));
82  }
83 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
int fetchNextId()
Definition: ODDCUConfig.cc:44
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkConnection() const
Definition: IDBObject.h:41
void ODDCUConfig::setId ( int  id)
inline

Definition at line 24 of file ODDCUConfig.h.

References m_ID.

24 { m_ID = id; }
void ODDCUConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 31 of file ODDCUConfig.cc.

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 ( )
throw (std::runtime_error
)
private

Definition at line 87 of file ODDCUConfig.cc.

References alignCSCRings::e.

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("ODDCUConfig::writeDB(): "+e.getMessage()));
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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
void checkPrepare()
Definition: IODConfig.h:39
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41

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