CMS 3D CMS Logo

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 () override
 
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 () 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 (ODScanConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

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 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 9 of file ODScanConfig.h.

Constructor & Destructor Documentation

◆ ODScanConfig()

ODScanConfig::ODScanConfig ( )

Definition at line 11 of file ODScanConfig.cc.

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 }

References clear().

◆ ~ODScanConfig()

ODScanConfig::~ODScanConfig ( )
override

Definition at line 21 of file ODScanConfig.cc.

21 {}

Member Function Documentation

◆ clear()

void ODScanConfig::clear ( void  )
private

Definition at line 23 of file ODScanConfig.cc.

23  {
24  m_type_id = 0;
25  m_type = "";
26  m_from_val = 0;
27  m_to_val = 0;
28  m_step = 0;
29 }

◆ fetchData()

void ODScanConfig::fetchData ( ODScanConfig result)
privatenoexcept

Definition at line 113 of file ODScanConfig.cc.

113  {
114  this->checkConnection();
115  result->clear();
116  if (result->getId() == 0 && (result->getConfigTag().empty())) {
117  throw(std::runtime_error("ODScanConfig::fetchData(): no Id defined for this ODScanConfig "));
118  }
119 
120  try {
121  m_readStmt->setSQL(
122  "SELECT * "
123  "FROM ECAL_SCAN_DAT "
124  " where (scan_id = :1 or scan_tag=:2 )");
125  m_readStmt->setInt(1, result->getId());
126  m_readStmt->setString(2, result->getConfigTag());
127 
128  ResultSet* rset = m_readStmt->executeQuery();
129 
130  rset->next();
131 
132  // id 1 is the scan_id
133  result->setId(rset->getInt(1));
134  result->setConfigTag(rset->getString(2));
135  result->setTypeId(rset->getInt(3));
136  result->setScanType(rset->getString(4));
137  result->setFromVal(rset->getInt(5));
138  result->setToVal(rset->getInt(6));
139  result->setStep(rset->getInt(7));
140 
141  } catch (SQLException& e) {
142  throw(std::runtime_error(std::string("ODScanConfig::fetchData(): ") + e.getMessage()));
143  }
144 }

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

◆ fetchID()

int ODScanConfig::fetchID ( )
privatenoexcept

Definition at line 146 of file ODScanConfig.cc.

146  {
147  // Return from memory if available
148  if (m_ID != 0) {
149  return m_ID;
150  }
151 
152  this->checkConnection();
153 
154  try {
155  Statement* stmt = m_conn->createStatement();
156  stmt->setSQL(
157  "SELECT scan_id FROM ecal_scan_dat "
158  "WHERE scan_tag=:scan_tag ");
159 
160  stmt->setString(1, getConfigTag());
161 
162  ResultSet* rset = stmt->executeQuery();
163 
164  if (rset->next()) {
165  m_ID = rset->getInt(1);
166  } else {
167  m_ID = 0;
168  }
169  m_conn->terminateStatement(stmt);
170  } catch (SQLException& e) {
171  throw(std::runtime_error(std::string("ODScanConfig::fetchID: ") + e.getMessage()));
172  }
173 
174  return m_ID;
175 }

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

◆ fetchNextId()

int ODScanConfig::fetchNextId ( )
privatenoexcept

Definition at line 31 of file ODScanConfig.cc.

31  {
32  int result = 0;
33  try {
34  this->checkConnection();
35 
36  m_readStmt = m_conn->createStatement();
37  m_readStmt->setSQL("select ecal_scan_config_sq.NextVal from dual");
38  ResultSet* rset = m_readStmt->executeQuery();
39  while (rset->next()) {
40  result = rset->getInt(1);
41  }
42  m_conn->terminateStatement(m_readStmt);
43  return result;
44 
45  } catch (SQLException& e) {
46  throw(std::runtime_error(std::string("ODScanConfig::fetchNextId(): ") + e.getMessage()));
47  }
48 }

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

◆ getFromVal()

int ODScanConfig::getFromVal ( ) const
inline

Definition at line 28 of file ODScanConfig.h.

28 { return m_from_val; }

References m_from_val.

◆ getId()

int ODScanConfig::getId ( void  ) const
inline

Definition at line 19 of file ODScanConfig.h.

19 { return m_ID; }

References m_ID.

◆ getScanType()

std::string ODScanConfig::getScanType ( ) const
inline

Definition at line 25 of file ODScanConfig.h.

25 { return m_type; }

References m_type.

◆ getStep()

int ODScanConfig::getStep ( ) const
inline

Definition at line 34 of file ODScanConfig.h.

34 { return m_step; }

References m_step.

◆ getTable()

std::string ODScanConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODScanConfig.h.

16 { return "ECAL_Scan_DAT"; }

◆ getToVal()

int ODScanConfig::getToVal ( ) const
inline

Definition at line 31 of file ODScanConfig.h.

31 { return m_to_val; }

References m_to_val.

◆ getTypeId()

int ODScanConfig::getTypeId ( ) const
inline

Definition at line 22 of file ODScanConfig.h.

22 { return m_type_id; }

References m_type_id.

◆ prepareWrite()

void ODScanConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 70 of file ODScanConfig.cc.

70  {
71  this->checkConnection();
72  int next_id = fetchNextId();
73 
74  try {
75  m_writeStmt = m_conn->createStatement();
76  m_writeStmt->setSQL(
77  "INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ,"
78  " type_id, scan_type , FROM_VAL , TO_VAL, STEP )"
79  " VALUES ( :1, :2, :3, :4, :5, :6, :7)");
80  m_writeStmt->setInt(1, next_id);
81  m_ID = next_id;
82 
83  } catch (SQLException& e) {
84  throw(std::runtime_error(std::string("ODScanConfig::prepareWrite(): ") + e.getMessage()));
85  }
86 }

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

◆ setFromVal()

void ODScanConfig::setFromVal ( int  x)
inline

Definition at line 27 of file ODScanConfig.h.

27 { m_from_val = x; }

References m_from_val, and x.

◆ setId()

void ODScanConfig::setId ( int  id)
inline

Definition at line 18 of file ODScanConfig.h.

18 { m_ID = id; }

References triggerObjects_cff::id, and m_ID.

◆ setParameters()

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

Definition at line 50 of file ODScanConfig.cc.

50  {
51  // parses the result of the XML parser that is a map of
52  // string string with variable name variable value
53 
54  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
55  if (ci->first == "SCAN_ID")
56  setConfigTag(ci->second);
57  if (ci->first == "TYPE_ID")
58  setTypeId(atoi(ci->second.c_str()));
59  if (ci->first == "TYPE" || ci->first == "SCAN_TYPE")
60  setScanType(ci->second);
61  if (ci->first == "FROM" || ci->first == "FROM_VAL")
62  setFromVal(atoi(ci->second.c_str()));
63  if (ci->first == "TO" || ci->first == "TO_VAL")
64  setToVal(atoi(ci->second.c_str()));
65  if (ci->first == "STEP")
66  setStep(atoi(ci->second.c_str()));
67  }
68 }

◆ setScanType()

void ODScanConfig::setScanType ( std::string  x)
inline

Definition at line 24 of file ODScanConfig.h.

24 { m_type = x; }

References m_type, and x.

◆ setStep()

void ODScanConfig::setStep ( int  x)
inline

Definition at line 33 of file ODScanConfig.h.

33 { m_step = x; }

References m_step, and x.

◆ setToVal()

void ODScanConfig::setToVal ( int  x)
inline

Definition at line 30 of file ODScanConfig.h.

30 { m_to_val = x; }

References m_to_val, and x.

◆ setTypeId()

void ODScanConfig::setTypeId ( int  x)
inline

Definition at line 21 of file ODScanConfig.h.

21 { m_type_id = x; }

References m_type_id, and x.

◆ writeDB()

void ODScanConfig::writeDB ( )
privatenoexcept

Definition at line 88 of file ODScanConfig.cc.

88  {
89  this->checkConnection();
90  this->checkPrepare();
91 
92  try {
93  // number 1 is the id
94  m_writeStmt->setString(2, this->getConfigTag());
95 
96  m_writeStmt->setInt(3, this->getTypeId());
97  m_writeStmt->setString(4, this->getScanType());
98  m_writeStmt->setInt(5, this->getFromVal());
99  m_writeStmt->setInt(6, this->getToVal());
100  m_writeStmt->setInt(7, this->getStep());
101 
102  m_writeStmt->executeUpdate();
103 
104  } catch (SQLException& e) {
105  throw(std::runtime_error(std::string("ODScanConfig::writeDB(): ") + e.getMessage()));
106  }
107  // Now get the ID
108  if (!this->fetchID()) {
109  throw(std::runtime_error("ODScanConfig::writeDB: Failed to write"));
110  }
111 }

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

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODScanConfig.h.

Member Data Documentation

◆ m_from_val

int ODScanConfig::m_from_val
private

Definition at line 50 of file ODScanConfig.h.

Referenced by getFromVal(), and setFromVal().

◆ m_ID

int ODScanConfig::m_ID
private

Definition at line 46 of file ODScanConfig.h.

Referenced by getId(), and setId().

◆ m_step

int ODScanConfig::m_step
private

Definition at line 52 of file ODScanConfig.h.

Referenced by getStep(), and setStep().

◆ m_to_val

int ODScanConfig::m_to_val
private

Definition at line 51 of file ODScanConfig.h.

Referenced by getToVal(), and setToVal().

◆ m_type

std::string ODScanConfig::m_type
private

Definition at line 49 of file ODScanConfig.h.

Referenced by getScanType(), and setScanType().

◆ m_type_id

int ODScanConfig::m_type_id
private

Definition at line 48 of file ODScanConfig.h.

Referenced by getTypeId(), and setTypeId().

ODScanConfig::setFromVal
void setFromVal(int x)
Definition: ODScanConfig.h:27
ODScanConfig::fetchID
int fetchID() noexcept(false)
Definition: ODScanConfig.cc:146
ODScanConfig::setToVal
void setToVal(int x)
Definition: ODScanConfig.h:30
IODConfig::Statement
oracle::occi::Statement Statement
Definition: IODConfig.h:21
ODScanConfig::getFromVal
int getFromVal() const
Definition: ODScanConfig.h:28
ODScanConfig::clear
void clear()
Definition: ODScanConfig.cc:23
DDAxes::x
IODConfig::SQLException
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
ODScanConfig::setTypeId
void setTypeId(int x)
Definition: ODScanConfig.h:21
ODScanConfig::m_to_val
int m_to_val
Definition: ODScanConfig.h:51
IDBObject::m_conn
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
ODScanConfig::m_type_id
int m_type_id
Definition: ODScanConfig.h:48
IODConfig::checkPrepare
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
ODScanConfig::getStep
int getStep() const
Definition: ODScanConfig.h:34
ODScanConfig::getToVal
int getToVal() const
Definition: ODScanConfig.h:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ODScanConfig::m_from_val
int m_from_val
Definition: ODScanConfig.h:50
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
ODScanConfig::fetchNextId
int fetchNextId() noexcept(false)
Definition: ODScanConfig.cc:31
ODScanConfig::getScanType
std::string getScanType() const
Definition: ODScanConfig.h:25
ODScanConfig::m_type
std::string m_type
Definition: ODScanConfig.h:49
IODConfig::m_writeStmt
Statement * m_writeStmt
Definition: IODConfig.h:33
ODScanConfig::m_step
int m_step
Definition: ODScanConfig.h:52
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
IODConfig::m_config_tag
std::string m_config_tag
Definition: IODConfig.h:25
ODScanConfig::setScanType
void setScanType(std::string x)
Definition: ODScanConfig.h:24
ODScanConfig::m_ID
int m_ID
Definition: ODScanConfig.h:46
IDBObject::m_env
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
mps_fire.result
result
Definition: mps_fire.py:303
IODConfig::setConfigTag
void setConfigTag(std::string x)
Definition: IODConfig.h:29
ODScanConfig::getTypeId
int getTypeId() const
Definition: ODScanConfig.h:22
ODScanConfig::setStep
void setStep(int x)
Definition: ODScanConfig.h:33
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37