test
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
ODScanConfig Class Reference

#include <ODScanConfig.h>

Inheritance diagram for ODScanConfig:
IODConfig IDBObject

Public Member Functions

int getFromVal () const
 
int getId () const
 
std::string getScanType () const
 
int getStep () const
 
std::string getTable ()
 
int getToVal () const
 
int getTypeId () const
 
 ODScanConfig ()
 
void setFromVal (int x)
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setScanType (std::string x)
 
void setStep (int x)
 
void setToVal (int x)
 
void setTypeId (int x)
 
 ~ODScanConfig ()
 
- 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 (ODScanConfig *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_from_val
 
int m_ID
 
int m_step
 
int m_to_val
 
std::string m_type
 
int m_type_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 9 of file ODScanConfig.h.

Constructor & Destructor Documentation

ODScanConfig::ODScanConfig ( )

Definition at line 11 of file ODScanConfig.cc.

References hitfit::clear(), and NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_readStmt = NULL;
17  m_config_tag="";
18  m_ID=0;
19  clear();
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
ODScanConfig::~ODScanConfig ( )

Definition at line 24 of file ODScanConfig.cc.

25 {
26 }

Member Function Documentation

void ODScanConfig::clear ( void  )
private

Definition at line 28 of file ODScanConfig.cc.

28  {
29 
30  m_type_id=0;
31  m_type="";
32  m_from_val=0;
33  m_to_val=0;
34  m_step=0;
35 
36 }
std::string m_type
Definition: ODScanConfig.h:50
void ODScanConfig::fetchData ( ODScanConfig result)
throw (std::runtime_error
)
private

Definition at line 131 of file ODScanConfig.cc.

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

133 {
134  this->checkConnection();
135  result->clear();
136  if(result->getId()==0 && (result->getConfigTag()=="") ){
137  throw(std::runtime_error("ODScanConfig::fetchData(): no Id defined for this ODScanConfig "));
138  }
139 
140  try {
141 
142  m_readStmt->setSQL("SELECT * "
143  "FROM ECAL_SCAN_DAT "
144  " where (scan_id = :1 or scan_tag=:2 )" );
145  m_readStmt->setInt(1, result->getId());
146  m_readStmt->setString(2, result->getConfigTag());
147 
148  ResultSet* rset = m_readStmt->executeQuery();
149 
150  rset->next();
151 
152  // id 1 is the scan_id
153  result->setId(rset->getInt(1));
154  result->setConfigTag(rset->getString(2));
155  result->setTypeId( rset->getInt(3) );
156  result->setScanType( rset->getString(4) );
157  result->setFromVal( rset->getInt(5) );
158  result->setToVal( rset->getInt(6) );
159  result->setStep( rset->getInt(7) );
160 
161  } catch (SQLException &e) {
162  throw(std::runtime_error("ODScanConfig::fetchData(): "+e.getMessage()));
163  }
164 }
void setToVal(int x)
Definition: ODScanConfig.h:30
void setId(int id)
Definition: ODScanConfig.h:18
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getId() const
Definition: ODScanConfig.h:19
void setScanType(std::string x)
Definition: ODScanConfig.h:24
void setFromVal(int x)
Definition: ODScanConfig.h:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
void setTypeId(int x)
Definition: ODScanConfig.h:21
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
void setStep(int x)
Definition: ODScanConfig.h:33
int ODScanConfig::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 166 of file ODScanConfig.cc.

References alignCSCRings::e.

167 {
168  // Return from memory if available
169  if (m_ID!=0) {
170  return m_ID;
171  }
172 
173  this->checkConnection();
174 
175  try {
176  Statement* stmt = m_conn->createStatement();
177  stmt->setSQL("SELECT scan_id FROM ecal_scan_dat "
178  "WHERE scan_tag=:scan_tag ");
179 
180  stmt->setString(1, getConfigTag() );
181 
182  ResultSet* rset = stmt->executeQuery();
183 
184  if (rset->next()) {
185  m_ID = rset->getInt(1);
186  } else {
187  m_ID = 0;
188  }
189  m_conn->terminateStatement(stmt);
190  } catch (SQLException &e) {
191  throw(std::runtime_error("ODScanConfig::fetchID: "+e.getMessage()));
192  }
193 
194  return m_ID;
195 }
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 ODScanConfig::fetchNextId ( )
throw (std::runtime_error
)
private

Definition at line 38 of file ODScanConfig.cc.

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

38  {
39 
40  int result=0;
41  try {
42  this->checkConnection();
43 
44  m_readStmt = m_conn->createStatement();
45  m_readStmt->setSQL("select ecal_scan_config_sq.NextVal from dual");
46  ResultSet* rset = m_readStmt->executeQuery();
47  while (rset->next ()){
48  result= rset->getInt(1);
49  }
50  m_conn->terminateStatement(m_readStmt);
51  return result;
52 
53  } catch (SQLException &e) {
54  throw(std::runtime_error("ODScanConfig::fetchNextId(): "+e.getMessage()));
55  }
56 
57 }
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 ODScanConfig::getFromVal ( ) const
inline

Definition at line 28 of file ODScanConfig.h.

References m_from_val.

28 { return m_from_val; }
int ODScanConfig::getId ( ) const
inline

Definition at line 19 of file ODScanConfig.h.

References m_ID.

19 { return m_ID; }
std::string ODScanConfig::getScanType ( ) const
inline

Definition at line 25 of file ODScanConfig.h.

References m_type.

25 { return m_type; }
std::string m_type
Definition: ODScanConfig.h:50
int ODScanConfig::getStep ( ) const
inline

Definition at line 34 of file ODScanConfig.h.

References m_step.

34 { return m_step ; }
std::string ODScanConfig::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 16 of file ODScanConfig.h.

16 { return "ECAL_Scan_DAT"; }
int ODScanConfig::getToVal ( ) const
inline

Definition at line 31 of file ODScanConfig.h.

References m_to_val.

31 { return m_to_val; }
int ODScanConfig::getTypeId ( ) const
inline

Definition at line 22 of file ODScanConfig.h.

References m_type_id.

22 { return m_type_id; }
void ODScanConfig::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 79 of file ODScanConfig.cc.

References alignCSCRings::e.

81 {
82  this->checkConnection();
83  int next_id=fetchNextId();
84 
85  try {
86  m_writeStmt = m_conn->createStatement();
87  m_writeStmt->setSQL("INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ,"
88  " type_id, scan_type , FROM_VAL , TO_VAL, STEP )"
89  " VALUES ( :1, :2, :3, :4, :5, :6, :7)");
90  m_writeStmt->setInt(1, next_id);
91  m_ID=next_id;
92 
93  } catch (SQLException &e) {
94  throw(std::runtime_error("ODScanConfig::prepareWrite(): "+e.getMessage()));
95  }
96 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int fetchNextId()
Definition: ODScanConfig.cc:38
void checkConnection() const
Definition: IDBObject.h:41
void ODScanConfig::setFromVal ( int  x)
inline

Definition at line 27 of file ODScanConfig.h.

References m_from_val, and x.

27 { m_from_val = x; }
Definition: DDAxes.h:10
void ODScanConfig::setId ( int  id)
inline

Definition at line 18 of file ODScanConfig.h.

References m_ID.

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

Definition at line 60 of file ODScanConfig.cc.

60  {
61 
62  // parses the result of the XML parser that is a map of
63  // string string with variable name variable value
64 
65  for( std::map<std::string, std::string >::const_iterator ci=
66  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
67 
68  if(ci->first== "SCAN_ID") setConfigTag(ci->second);
69  if(ci->first== "TYPE_ID") setTypeId(atoi(ci->second.c_str()) );
70  if(ci->first== "TYPE" || ci->first== "SCAN_TYPE") setScanType(ci->second.c_str() );
71  if(ci->first== "FROM" ||ci->first== "FROM_VAL" ) setFromVal(atoi(ci->second.c_str() ));
72  if(ci->first== "TO" ||ci->first== "TO_VAL" ) setToVal(atoi(ci->second.c_str() ));
73  if(ci->first== "STEP") setStep(atoi(ci->second.c_str() ));
74 
75  }
76 
77 }
void setToVal(int x)
Definition: ODScanConfig.h:30
void setScanType(std::string x)
Definition: ODScanConfig.h:24
void setFromVal(int x)
Definition: ODScanConfig.h:27
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setTypeId(int x)
Definition: ODScanConfig.h:21
void setStep(int x)
Definition: ODScanConfig.h:33
void ODScanConfig::setScanType ( std::string  x)
inline

Definition at line 24 of file ODScanConfig.h.

References m_type, and x.

24 { m_type = x; }
std::string m_type
Definition: ODScanConfig.h:50
Definition: DDAxes.h:10
void ODScanConfig::setStep ( int  x)
inline

Definition at line 33 of file ODScanConfig.h.

References m_step, and x.

33 { m_step = x; }
Definition: DDAxes.h:10
void ODScanConfig::setToVal ( int  x)
inline

Definition at line 30 of file ODScanConfig.h.

References m_to_val, and x.

30 { m_to_val = x; }
Definition: DDAxes.h:10
void ODScanConfig::setTypeId ( int  x)
inline

Definition at line 21 of file ODScanConfig.h.

References m_type_id, and x.

21 { m_type_id = x; }
Definition: DDAxes.h:10
void ODScanConfig::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 98 of file ODScanConfig.cc.

References alignCSCRings::e.

100 {
101  this->checkConnection();
102  this->checkPrepare();
103 
104  try {
105 
106  // number 1 is the id
107  m_writeStmt->setString(2, this->getConfigTag());
108 
109  m_writeStmt->setInt(3, this->getTypeId());
110  m_writeStmt->setString(4, this->getScanType() );
111  m_writeStmt->setInt(5, this->getFromVal() );
112  m_writeStmt->setInt(6, this->getToVal() );
113  m_writeStmt->setInt(7, this->getStep() );
114 
115  m_writeStmt->executeUpdate();
116 
117 
118  } catch (SQLException &e) {
119  throw(std::runtime_error("ODScanConfig::writeDB(): "+e.getMessage()));
120  }
121  // Now get the ID
122  if (!this->fetchID()) {
123  throw(std::runtime_error("ODScanConfig::writeDB: Failed to write"));
124  }
125 
126 }
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int getStep() const
Definition: ODScanConfig.h:34
void checkPrepare()
Definition: IODConfig.h:39
int getToVal() const
Definition: ODScanConfig.h:31
int getFromVal() const
Definition: ODScanConfig.h:28
std::string getConfigTag()
Definition: IODConfig.h:32
std::string getScanType() const
Definition: ODScanConfig.h:25
int getTypeId() const
Definition: ODScanConfig.h:22
void checkConnection() const
Definition: IDBObject.h:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODScanConfig.h.

Member Data Documentation

int ODScanConfig::m_from_val
private

Definition at line 51 of file ODScanConfig.h.

Referenced by getFromVal(), and setFromVal().

int ODScanConfig::m_ID
private

Definition at line 47 of file ODScanConfig.h.

Referenced by getId(), and setId().

int ODScanConfig::m_step
private

Definition at line 53 of file ODScanConfig.h.

Referenced by getStep(), and setStep().

int ODScanConfig::m_to_val
private

Definition at line 52 of file ODScanConfig.h.

Referenced by getToVal(), and setToVal().

std::string ODScanConfig::m_type
private

Definition at line 50 of file ODScanConfig.h.

Referenced by getScanType(), and setScanType().

int ODScanConfig::m_type_id
private

Definition at line 49 of file ODScanConfig.h.

Referenced by getTypeId(), and setTypeId().