CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODCond2ConfInfo Class Reference

#include <ODCond2ConfInfo.h>

Inheritance diagram for ODCond2ConfInfo:
IODConfig IDBObject

Public Member Functions

int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
Tm getDBDate () const
 
std::string getDescription () const
 
int getId () const
 
std::string getLocation () const
 
Tm getRecordDate () const
 
int getRunNumber () const
 
std::string getTable () override
 
std::string getType () const
 
 ODCond2ConfInfo ()
 
void setDBDate (const Tm &x)
 
void setDescription (std::string x)
 
void setId (int id)
 
void setLocation (std::string x)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setRecordDate (const Tm &x)
 
void setRunNumber (int id)
 
void setType (std::string x)
 
 ~ODCond2ConfInfo () 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 (ODCond2ConfInfo *result) noexcept(false)
 
void fetchParents () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

Tm m_db_time
 
std::string m_desc
 
int m_ID
 
std::string m_loc
 
int m_loc_id
 
Tm m_rec_time
 
int m_run
 
int m_typ_id
 
std::string m_type
 

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 12 of file ODCond2ConfInfo.h.

Constructor & Destructor Documentation

◆ ODCond2ConfInfo()

ODCond2ConfInfo::ODCond2ConfInfo ( )

Definition at line 12 of file ODCond2ConfInfo.cc.

References l1ct::clear().

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

◆ ~ODCond2ConfInfo()

ODCond2ConfInfo::~ODCond2ConfInfo ( )
override

Definition at line 33 of file ODCond2ConfInfo.cc.

33 {}

Member Function Documentation

◆ clear()

void ODCond2ConfInfo::clear ( void  )
private

Definition at line 22 of file ODCond2ConfInfo.cc.

References RunInfoPI::m_run.

22  {
23  m_type = "";
24  m_loc = "";
25  m_run = 0;
26  m_desc = "";
27  m_rec_time = Tm();
28  m_db_time = Tm();
29  m_typ_id = 0;
30  m_loc_id = 0;
31 }
std::string m_type
std::string m_desc
std::string m_loc
Definition: Tm.h:13

◆ fetchData()

void ODCond2ConfInfo::fetchData ( ODCond2ConfInfo result)
privatenoexcept

Definition at line 154 of file ODCond2ConfInfo.cc.

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

154  {
155  this->checkConnection();
156  result->clear();
157 
159 
160  if (result->getId() == 0) {
161  throw(std::runtime_error("ODCond2ConfInfo::fetchData(): no Id defined for this ODCond2ConfInfo "));
162  }
163 
164  try {
165  m_readStmt->setSQL(
166  "SELECT rec_id, REC_TYPE, rec_date, location, "
167  "run_number, short_desc, db_timestamp FROM " +
168  getTable() +
169  " , COND2CONF_TYPE_DEF , location_def "
170  " where rec_id = :1 AND COND2CONF_TYPE_DEF.def_id=" +
171  getTable() + ".REC_TYPE_ID AND location_def.def_id=LOCATION_ID ");
172  m_readStmt->setInt(1, result->getId());
173  ResultSet* rset = m_readStmt->executeQuery();
174 
175  rset->next();
176 
177  // 1 is the id and 2 is the config tag and 3 is the version
178 
179  // result->setId(rset->getInt(1));
180 
181  result->setType(rset->getString(2));
182  Date startDate = rset->getDate(3);
183  result->setLocation(rset->getString(4));
184  result->setRunNumber(rset->getInt(5));
185  result->setDescription(rset->getString(6));
186  Date endDate = rset->getDate(7);
187 
188  m_rec_time = dh.dateToTm(startDate);
189  m_db_time = dh.dateToTm(endDate);
190 
191  } catch (SQLException& e) {
192  throw(std::runtime_error(std::string("ODCond2ConfInfo::fetchData(): ") + e.getMessage()));
193  }
194 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTable() override
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
dh
Definition: cuy.py:354

◆ fetchID()

int ODCond2ConfInfo::fetchID ( )
noexcept

Definition at line 196 of file ODCond2ConfInfo.cc.

References MillePedeFileConverter_cfg::e, DeadROCCounter::getRunNumber(), and AlCaHLTBitMon_QueryRunRegistry::string.

196  {
197  // Return from memory if available
198  if (m_ID != 0) {
199  return m_ID;
200  }
201 
202  this->checkConnection();
203 
204  fetchParents();
205 
206  try {
207  Statement* stmt = m_conn->createStatement();
208  stmt->setSQL("SELECT rec_id FROM " + getTable() +
209  "WHERE rec_type_id=:1 and (run_number=:2 or short_desc=:3 ) order by rec_id DESC ");
210 
211  stmt->setInt(1, m_typ_id);
212  stmt->setInt(2, getRunNumber());
213  stmt->setString(3, getDescription());
214 
215  ResultSet* rset = stmt->executeQuery();
216 
217  if (rset->next()) {
218  m_ID = rset->getInt(1);
219  } else {
220  m_ID = 0;
221  }
222  m_conn->terminateStatement(stmt);
223  } catch (SQLException& e) {
224  throw(std::runtime_error(std::string("ODCond2ConfInfo::fetchID: ") + e.getMessage()));
225  }
226 
227  return m_ID;
228 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getDescription() const
std::string getTable() override
void fetchParents() noexcept(false)
int getRunNumber() const
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

◆ fetchNextId()

int ODCond2ConfInfo::fetchNextId ( )
noexcept

Definition at line 35 of file ODCond2ConfInfo.cc.

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

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

◆ fetchParents()

void ODCond2ConfInfo::fetchParents ( )
privatenoexcept

Definition at line 55 of file ODCond2ConfInfo.cc.

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

55  {
56  if (m_typ_id == 0) {
57  if (!getType().empty()) {
58  try {
59  this->checkConnection();
60  m_readStmt = m_conn->createStatement();
61  m_readStmt->setSQL("select def_id from COND2CONF_TYPE_DEF where rec_type=" + getType());
62  ResultSet* rset = m_readStmt->executeQuery();
63  while (rset->next()) {
64  m_typ_id = rset->getInt(1);
65  }
66  m_conn->terminateStatement(m_readStmt);
67 
68  } catch (SQLException& e) {
69  throw(std::runtime_error(std::string("ODCond2ConfInfo::fetchParents(): ") + e.getMessage()));
70  }
71  }
72  }
73  if (m_loc_id == 0) {
74  if (!getLocation().empty()) {
75  try {
76  this->checkConnection();
77  m_readStmt = m_conn->createStatement();
78  m_readStmt->setSQL("select def_id from location_def where location=" + getLocation());
79  ResultSet* rset = m_readStmt->executeQuery();
80  while (rset->next()) {
81  m_loc_id = rset->getInt(1);
82  }
83  m_conn->terminateStatement(m_readStmt);
84  } catch (SQLException& e) {
85  throw(std::runtime_error(std::string("ODCond2ConfInfo::fetchParents(): ") + e.getMessage()));
86  }
87  }
88  }
89 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
std::string getLocation() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
std::string getType() const

◆ getDBDate()

Tm ODCond2ConfInfo::getDBDate ( ) const
inline

Definition at line 40 of file ODCond2ConfInfo.h.

References m_db_time.

40 { return m_db_time; }

◆ getDescription()

std::string ODCond2ConfInfo::getDescription ( ) const
inline

Definition at line 37 of file ODCond2ConfInfo.h.

References m_desc.

37 { return m_desc; }
std::string m_desc

◆ getId()

int ODCond2ConfInfo::getId ( void  ) const
inline

Definition at line 22 of file ODCond2ConfInfo.h.

References m_ID.

22 { return m_ID; }

◆ getLocation()

std::string ODCond2ConfInfo::getLocation ( ) const
inline

Definition at line 31 of file ODCond2ConfInfo.h.

References m_loc.

31 { return m_loc; }
std::string m_loc

◆ getRecordDate()

Tm ODCond2ConfInfo::getRecordDate ( ) const
inline

Definition at line 28 of file ODCond2ConfInfo.h.

References m_rec_time.

28 { return m_rec_time; }

◆ getRunNumber()

int ODCond2ConfInfo::getRunNumber ( ) const
inline

Definition at line 34 of file ODCond2ConfInfo.h.

References m_run.

34 { return m_run; }

◆ getTable()

std::string ODCond2ConfInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file ODCond2ConfInfo.h.

19 { return "COND_2_CONF_INFO"; }

◆ getType()

std::string ODCond2ConfInfo::getType ( void  ) const
inline

Definition at line 25 of file ODCond2ConfInfo.h.

References m_type.

25 { return m_type; }
std::string m_type

◆ prepareWrite()

void ODCond2ConfInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 91 of file ODCond2ConfInfo.cc.

References MillePedeFileConverter_cfg::e, getId(), and AlCaHLTBitMon_QueryRunRegistry::string.

91  {
92  this->checkConnection();
93 
94  int next_id = 0;
95  if (getId() == 0) {
96  next_id = fetchNextId();
97  }
98 
99  fetchParents();
100  try {
101  m_writeStmt = m_conn->createStatement();
102  m_writeStmt->setSQL("INSERT INTO " + getTable() +
103  " ( rec_id, rec_type_id, rec_date, "
104  "location_id, run_number, short_desc ) "
105  " VALUES ( :1, :2, :3 , :4, :5, :6 ) ");
106 
107  m_writeStmt->setInt(1, next_id);
108  m_writeStmt->setInt(3, m_typ_id);
109  m_writeStmt->setInt(4, m_loc_id);
110 
111  m_ID = next_id;
112 
113  } catch (SQLException& e) {
114  throw(std::runtime_error(std::string("ODCond2ConfInfo::prepareWrite(): ") + e.getMessage()));
115  }
116 }
int fetchNextId() noexcept(false)
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
std::string getTable() override
void fetchParents() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int getId() const

◆ setDBDate()

void ODCond2ConfInfo::setDBDate ( const Tm x)
inline

Definition at line 39 of file ODCond2ConfInfo.h.

References m_db_time, and x.

◆ setDescription()

void ODCond2ConfInfo::setDescription ( std::string  x)
inline

Definition at line 36 of file ODCond2ConfInfo.h.

References m_desc, and x.

36 { m_desc = x; }
std::string m_desc

◆ setId()

void ODCond2ConfInfo::setId ( int  id)
inline

◆ setLocation()

void ODCond2ConfInfo::setLocation ( std::string  x)
inline

Definition at line 30 of file ODCond2ConfInfo.h.

References m_loc, and x.

30 { m_loc = x; }
std::string m_loc

◆ setParameters()

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

Definition at line 118 of file ODCond2ConfInfo.cc.

References gather_cfg::cout.

118  {
119  // parses the result of the XML parser that is a map of
120  // string string with variable name variable value
121 
122  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
123  // if(ci->first== "TAG") setConfigTag(ci->second);
124  }
125  std::cout << "method not yet implemented" << std::endl;
126 }

◆ setRecordDate()

void ODCond2ConfInfo::setRecordDate ( const Tm x)
inline

Definition at line 27 of file ODCond2ConfInfo.h.

References m_rec_time, and x.

◆ setRunNumber()

void ODCond2ConfInfo::setRunNumber ( int  id)
inline

◆ setType()

void ODCond2ConfInfo::setType ( std::string  x)
inline

Definition at line 24 of file ODCond2ConfInfo.h.

References m_type, and x.

24 { m_type = x; }
std::string m_type

◆ writeDB()

void ODCond2ConfInfo::writeDB ( )
privatenoexcept

Definition at line 128 of file ODCond2ConfInfo.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DeadROCCounter::getRunNumber(), and AlCaHLTBitMon_QueryRunRegistry::string.

128  {
129  this->checkConnection();
130  this->checkPrepare();
131 
133  if (m_rec_time.isNull()) {
134  int very_old_time = 0;
135  m_rec_time = Tm(very_old_time);
136  }
137 
138  try {
139  m_writeStmt->setDate(3, dh.tmToDate(this->m_rec_time));
140  m_writeStmt->setInt(5, this->getRunNumber());
141  m_writeStmt->setString(6, this->getDescription());
142 
143  m_writeStmt->executeUpdate();
144 
145  } catch (SQLException& e) {
146  throw(std::runtime_error(std::string("ODCond2ConfInfo::writeDB(): ") + e.getMessage()));
147  }
148  // Now get the ID
149  if (!this->fetchID()) {
150  throw(std::runtime_error("ODCond2ConfInfo::writeDB: Failed to write"));
151  }
152 }
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
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getDescription() const
int getRunNumber() const
int isNull() const
Definition: Tm.cc:44
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
dh
Definition: cuy.py:354
Definition: Tm.h:13
void checkPrepare() noexcept(false)
Definition: IODConfig.h:36
int fetchID() noexcept(false)

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 14 of file ODCond2ConfInfo.h.

Member Data Documentation

◆ m_db_time

Tm ODCond2ConfInfo::m_db_time
private

Definition at line 67 of file ODCond2ConfInfo.h.

Referenced by getDBDate(), and setDBDate().

◆ m_desc

std::string ODCond2ConfInfo::m_desc
private

Definition at line 66 of file ODCond2ConfInfo.h.

Referenced by getDescription(), and setDescription().

◆ m_ID

int ODCond2ConfInfo::m_ID
private

Definition at line 61 of file ODCond2ConfInfo.h.

Referenced by getId(), and setId().

◆ m_loc

std::string ODCond2ConfInfo::m_loc
private

Definition at line 64 of file ODCond2ConfInfo.h.

Referenced by getLocation(), and setLocation().

◆ m_loc_id

int ODCond2ConfInfo::m_loc_id
private

Definition at line 68 of file ODCond2ConfInfo.h.

◆ m_rec_time

Tm ODCond2ConfInfo::m_rec_time
private

Definition at line 63 of file ODCond2ConfInfo.h.

Referenced by getRecordDate(), and setRecordDate().

◆ m_run

int ODCond2ConfInfo::m_run
private

Definition at line 65 of file ODCond2ConfInfo.h.

Referenced by getRunNumber(), and setRunNumber().

◆ m_typ_id

int ODCond2ConfInfo::m_typ_id
private

Definition at line 69 of file ODCond2ConfInfo.h.

◆ m_type

std::string ODCond2ConfInfo::m_type
private

Definition at line 62 of file ODCond2ConfInfo.h.

Referenced by getType(), and setType().