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

Definition at line 12 of file ODCond2ConfInfo.cc.

References hitfit::clear().

13 {
14  m_env = nullptr;
15  m_conn = nullptr;
16  m_writeStmt = nullptr;
17  m_readStmt = nullptr;
18  m_config_tag="";
19  m_ID=0;
20  clear();
21 }
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
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODCond2ConfInfo::~ODCond2ConfInfo ( )
override

Definition at line 39 of file ODCond2ConfInfo.cc.

40 {
41 }

Member Function Documentation

void ODCond2ConfInfo::clear ( void  )
private

Definition at line 24 of file ODCond2ConfInfo.cc.

Referenced by getDBDate().

24  {
25  m_type="";
26  m_loc="";
27  m_run=0;
28  m_desc="";
29  m_rec_time = Tm();
30  m_db_time = Tm();
31  m_typ_id=0;
32  m_loc_id=0;
33 
34 
35 }
std::string m_type
std::string m_desc
std::string m_loc
Definition: Tm.h:13
void ODCond2ConfInfo::fetchData ( ODCond2ConfInfo result)
privatenoexcept

Definition at line 187 of file ODCond2ConfInfo.cc.

References DateHandler::dateToTm(), cuy::dh, MillePedeFileConverter_cfg::e, and mps_fire::result.

Referenced by getDBDate().

189 {
190  this->checkConnection();
191  result->clear();
192 
194 
195 
196  if(result->getId()==0 ){
197  throw(std::runtime_error("ODCond2ConfInfo::fetchData(): no Id defined for this ODCond2ConfInfo "));
198  }
199 
200  try {
201 
202  m_readStmt->setSQL("SELECT rec_id, REC_TYPE, rec_date, location, "
203  "run_number, short_desc, db_timestamp FROM " + getTable() + " , COND2CONF_TYPE_DEF , location_def "
204  " where rec_id = :1 AND COND2CONF_TYPE_DEF.def_id="
205  +getTable()+".REC_TYPE_ID AND location_def.def_id=LOCATION_ID ");
206  m_readStmt->setInt(1, result->getId());
207  ResultSet* rset = m_readStmt->executeQuery();
208 
209  rset->next();
210 
211  // 1 is the id and 2 is the config tag and 3 is the version
212 
213 
214 
215 
216  // result->setId(rset->getInt(1));
217 
218 
219  result->setType(rset->getString(2));
220  Date startDate = rset->getDate(3);
221  result->setLocation(rset->getString(4));
222  result->setRunNumber(rset->getInt(5));
223  result->setDescription(rset->getString(6));
224  Date endDate = rset->getDate(7);
225 
226  m_rec_time = dh.dateToTm( startDate );
227  m_db_time = dh.dateToTm( endDate );
228 
229  } catch (SQLException &e) {
230  throw(std::runtime_error("ODCond2ConfInfo::fetchData(): "+e.getMessage()));
231  }
232 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable() override
int getId() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void setDescription(std::string x)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
void setLocation(std::string x)
dh
Definition: cuy.py:353
void setRunNumber(int id)
void setType(std::string x)
int ODCond2ConfInfo::fetchID ( )
noexcept

Definition at line 234 of file ODCond2ConfInfo.cc.

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

Referenced by getDBDate().

235 {
236  // Return from memory if available
237  if (m_ID!=0) {
238  return m_ID;
239  }
240 
241  this->checkConnection();
242 
243 
244  fetchParents();
245 
246  try {
247  Statement* stmt = m_conn->createStatement();
248  stmt->setSQL("SELECT rec_id FROM "+ getTable()+
249  "WHERE rec_type_id=:1 and (run_number=:2 or short_desc=:3 ) order by rec_id DESC " );
250 
251  stmt->setInt(1, m_typ_id );
252  stmt->setInt(2, getRunNumber() );
253  stmt->setString(3, getDescription() );
254 
255  ResultSet* rset = stmt->executeQuery();
256 
257  if (rset->next()) {
258  m_ID = rset->getInt(1);
259  } else {
260  m_ID = 0;
261  }
262  m_conn->terminateStatement(stmt);
263  } catch (SQLException &e) {
264  throw(std::runtime_error("ODCond2ConfInfo::fetchID: "+e.getMessage()));
265  }
266 
267  return m_ID;
268 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getDescription() const
std::string getTable() override
void fetchParents() noexcept(false)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
int getRunNumber() const
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int ODCond2ConfInfo::fetchNextId ( )
noexcept

Definition at line 45 of file ODCond2ConfInfo.cc.

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

Referenced by getDBDate().

45  {
46 
47  int result=0;
48  try {
49  this->checkConnection();
50 
51  m_readStmt = m_conn->createStatement();
52  m_readStmt->setSQL("select COND2CONF_INFO_SQ.NextVal from DUAL ");
53  ResultSet* rset = m_readStmt->executeQuery();
54  while (rset->next ()){
55  result= rset->getInt(1);
56  }
57  result++;
58  m_conn->terminateStatement(m_readStmt);
59  return result;
60 
61  } catch (SQLException &e) {
62  throw(std::runtime_error("ODCond2ConfInfo::fetchNextId(): "+e.getMessage()));
63  }
64 
65 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
void ODCond2ConfInfo::fetchParents ( )
privatenoexcept

Definition at line 67 of file ODCond2ConfInfo.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getDBDate().

67  {
68 
69 
70 
71  if(m_typ_id==0) {
72 
73  if(getType()!=""){
74  try {
75  this->checkConnection();
76  m_readStmt = m_conn->createStatement();
77  m_readStmt->setSQL("select def_id from COND2CONF_TYPE_DEF where rec_type="+getType());
78  ResultSet* rset = m_readStmt->executeQuery();
79  while (rset->next ()){
80  m_typ_id= rset->getInt(1);
81  }
82  m_conn->terminateStatement(m_readStmt);
83 
84 
85  } catch (SQLException &e) {
86  throw(std::runtime_error("ODCond2ConfInfo::fetchParents(): "+e.getMessage()));
87  }
88  }
89  }
90  if(m_loc_id==0){
91  if(getLocation()!=""){
92  try {
93  this->checkConnection();
94  m_readStmt = m_conn->createStatement();
95  m_readStmt->setSQL("select def_id from location_def where location="+getLocation());
96  ResultSet* rset = m_readStmt->executeQuery();
97  while (rset->next ()){
98  m_loc_id= rset->getInt(1);
99  }
100  m_conn->terminateStatement(m_readStmt);
101  } catch (SQLException &e) {
102  throw(std::runtime_error("ODCond2ConfInfo::fetchParents(): "+e.getMessage()));
103  }
104  }
105  }
106 
107 }
std::string getType() const
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getLocation() const
Statement * m_readStmt
Definition: IODConfig.h:37
Tm ODCond2ConfInfo::getDBDate ( ) const
inline
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
int ODCond2ConfInfo::getId ( void  ) const
inline

Definition at line 22 of file ODCond2ConfInfo.h.

References m_ID.

22 { return m_ID; }
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
Tm ODCond2ConfInfo::getRecordDate ( ) const
inline

Definition at line 28 of file ODCond2ConfInfo.h.

References m_rec_time.

28 { return m_rec_time; }
int ODCond2ConfInfo::getRunNumber ( ) const
inline

Definition at line 34 of file ODCond2ConfInfo.h.

References m_run.

34 { return m_run; }
std::string ODCond2ConfInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 19 of file ODCond2ConfInfo.h.

19 { return "COND_2_CONF_INFO"; }
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
void ODCond2ConfInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 109 of file ODCond2ConfInfo.cc.

References MillePedeFileConverter_cfg::e, and getId().

Referenced by getDBDate().

111 {
112  this->checkConnection();
113 
114  int next_id=0;
115  if(getId()==0){
116  next_id=fetchNextId();
117  }
118 
119  fetchParents();
120  try {
121  m_writeStmt = m_conn->createStatement();
122  m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( rec_id, rec_type_id, rec_date, "
123  "location_id, run_number, short_desc ) "
124  " VALUES ( :1, :2, :3 , :4, :5, :6 ) " );
125 
126  m_writeStmt->setInt(1, next_id);
127  m_writeStmt->setInt(3, m_typ_id);
128  m_writeStmt->setInt(4, m_loc_id);
129 
130  m_ID=next_id;
131 
132  } catch (SQLException &e) {
133  throw(std::runtime_error("ODCond2ConfInfo::prepareWrite(): "+e.getMessage()));
134  }
135 
136 }
int fetchNextId() noexcept(false)
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getTable() override
void fetchParents() noexcept(false)
int getId() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODCond2ConfInfo::setDBDate ( const Tm x)
inline

Definition at line 39 of file ODCond2ConfInfo.h.

References m_db_time, and x.

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
void ODCond2ConfInfo::setId ( int  id)
inline

Definition at line 21 of file ODCond2ConfInfo.h.

References triggerObjects_cff::id, and m_ID.

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
void ODCond2ConfInfo::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 138 of file ODCond2ConfInfo.cc.

References gather_cfg::cout.

Referenced by getDBDate().

138  {
139 
140  // parses the result of the XML parser that is a map of
141  // string string with variable name variable value
142 
143  for( std::map<std::string, std::string >::const_iterator ci=
144  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
145 
146  // if(ci->first== "TAG") setConfigTag(ci->second);
147 
148  }
149  std::cout<< "method not yet implemented"<< std::endl;
150 
151 }
void ODCond2ConfInfo::setRecordDate ( const Tm x)
inline

Definition at line 27 of file ODCond2ConfInfo.h.

References m_rec_time, and x.

void ODCond2ConfInfo::setRunNumber ( int  id)
inline

Definition at line 33 of file ODCond2ConfInfo.h.

References triggerObjects_cff::id, and m_run.

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
void ODCond2ConfInfo::writeDB ( )
privatenoexcept

Definition at line 154 of file ODCond2ConfInfo.cc.

References cuy::dh, MillePedeFileConverter_cfg::e, DeadROCCounter::getRunNumber(), and DateHandler::tmToDate().

Referenced by getDBDate().

156 {
157  this->checkConnection();
158  this->checkPrepare();
159 
160 
162  if (m_rec_time.isNull()) {
163  int very_old_time=0;
164  m_rec_time = Tm(very_old_time);
165  }
166 
167  try {
168 
169  m_writeStmt->setDate(3, dh.tmToDate(this->m_rec_time));
170  m_writeStmt->setInt(5, this->getRunNumber());
171  m_writeStmt->setString(6, this->getDescription());
172 
173  m_writeStmt->executeUpdate();
174 
175 
176  } catch (SQLException &e) {
177  throw(std::runtime_error("ODCond2ConfInfo::writeDB(): "+e.getMessage()));
178  }
179  // Now get the ID
180  if (!this->fetchID()) {
181  throw(std::runtime_error("ODCond2ConfInfo::writeDB: Failed to write"));
182  }
183 
184 }
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
std::string getDescription() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getRunNumber() const
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int isNull() const
Definition: Tm.cc:63
dh
Definition: cuy.py:353
Definition: Tm.h:13
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39
int fetchID() noexcept(false)

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 14 of file ODCond2ConfInfo.h.

Member Data Documentation

Tm ODCond2ConfInfo::m_db_time
private

Definition at line 68 of file ODCond2ConfInfo.h.

Referenced by getDBDate(), and setDBDate().

std::string ODCond2ConfInfo::m_desc
private

Definition at line 67 of file ODCond2ConfInfo.h.

Referenced by getDescription(), and setDescription().

int ODCond2ConfInfo::m_ID
private

Definition at line 62 of file ODCond2ConfInfo.h.

Referenced by getId(), and setId().

std::string ODCond2ConfInfo::m_loc
private

Definition at line 65 of file ODCond2ConfInfo.h.

Referenced by getLocation(), and setLocation().

int ODCond2ConfInfo::m_loc_id
private

Definition at line 69 of file ODCond2ConfInfo.h.

Tm ODCond2ConfInfo::m_rec_time
private

Definition at line 64 of file ODCond2ConfInfo.h.

Referenced by getRecordDate(), and setRecordDate().

int ODCond2ConfInfo::m_run
private

Definition at line 66 of file ODCond2ConfInfo.h.

Referenced by getRunNumber(), and setRunNumber().

int ODCond2ConfInfo::m_typ_id
private

Definition at line 70 of file ODCond2ConfInfo.h.

std::string ODCond2ConfInfo::m_type
private

Definition at line 63 of file ODCond2ConfInfo.h.

Referenced by getType(), and setType().