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
ODCond2ConfInfo Class Reference

#include <ODCond2ConfInfo.h>

Inheritance diagram for ODCond2ConfInfo:
IODConfig IDBObject

Public Member Functions

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

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

Constructor & Destructor Documentation

ODCond2ConfInfo::ODCond2ConfInfo ( )

Definition at line 12 of file ODCond2ConfInfo.cc.

References hitfit::clear(), and NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
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
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
Statement * m_readStmt
Definition: IODConfig.h:37
ODCond2ConfInfo::~ODCond2ConfInfo ( )

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.

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:14
void ODCond2ConfInfo::fetchData ( ODCond2ConfInfo result)
throw (std::runtime_error
)
private

Definition at line 187 of file ODCond2ConfInfo.cc.

References DateHandler::dateToTm(), alignCSCRings::e, and query::result.

189 {
190  this->checkConnection();
191  result->clear();
192 
193  DateHandler dh(m_env, m_conn);
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()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getId() const
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setDescription(std::string x)
Statement * m_readStmt
Definition: IODConfig.h:37
void setLocation(std::string x)
void setRunNumber(int id)
void setType(std::string x)
void checkConnection() const
Definition: IDBObject.h:41
int ODCond2ConfInfo::fetchID ( )
throw (std::runtime_error
)

Definition at line 234 of file ODCond2ConfInfo.cc.

References alignCSCRings::e.

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()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
int getRunNumber() const
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
int ODCond2ConfInfo::fetchNextId ( )
throw (std::runtime_error
)

Definition at line 45 of file ODCond2ConfInfo.cc.

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

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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
void ODCond2ConfInfo::fetchParents ( )
throw (std::runtime_error
)
private

Definition at line 67 of file ODCond2ConfInfo.cc.

References alignCSCRings::e.

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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
std::string getLocation() const
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
Tm ODCond2ConfInfo::getDBDate ( ) const
inline

Definition at line 40 of file ODCond2ConfInfo.h.

References m_db_time.

40 { return m_db_time; }
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 ( ) 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 ( )
inlinevirtual

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

Implements IODConfig.

Definition at line 109 of file ODCond2ConfInfo.cc.

References alignCSCRings::e, and getId().

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 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getTable()
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getId() const
void checkConnection() const
Definition: IDBObject.h:41
void ODCond2ConfInfo::setDBDate ( Tm  x)
inline

Definition at line 39 of file ODCond2ConfInfo.h.

References m_db_time, and vdt::x.

39 { m_db_time = x; }
x
Definition: VDTMath.h:216
void ODCond2ConfInfo::setDescription ( std::string  x)
inline

Definition at line 36 of file ODCond2ConfInfo.h.

References m_desc, and vdt::x.

36 { m_desc = x; }
std::string m_desc
x
Definition: VDTMath.h:216
void ODCond2ConfInfo::setId ( int  id)
inline
void ODCond2ConfInfo::setLocation ( std::string  x)
inline

Definition at line 30 of file ODCond2ConfInfo.h.

References m_loc, and vdt::x.

30 { m_loc = x; }
std::string m_loc
x
Definition: VDTMath.h:216
void ODCond2ConfInfo::setParameters ( std::map< std::string, std::string >  my_keys_map)

Definition at line 138 of file ODCond2ConfInfo.cc.

References gather_cfg::cout.

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 >::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 }
tuple cout
Definition: gather_cfg.py:121
void ODCond2ConfInfo::setRecordDate ( Tm  x)
inline

Definition at line 27 of file ODCond2ConfInfo.h.

References m_rec_time, and vdt::x.

27 { m_rec_time = x; }
x
Definition: VDTMath.h:216
void ODCond2ConfInfo::setRunNumber ( int  id)
inline
void ODCond2ConfInfo::setType ( std::string  x)
inline

Definition at line 24 of file ODCond2ConfInfo.h.

References m_type, and vdt::x.

24 { m_type = x; }
std::string m_type
x
Definition: VDTMath.h:216
void ODCond2ConfInfo::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 154 of file ODCond2ConfInfo.cc.

References alignCSCRings::e, and DateHandler::tmToDate().

156 {
157  this->checkConnection();
158  this->checkPrepare();
159 
160 
161  DateHandler dh(m_env, m_conn);
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
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getRunNumber() const
void checkPrepare()
Definition: IODConfig.h:39
int isNull() const
Definition: Tm.cc:63
Definition: Tm.h:14
void checkConnection() const
Definition: IDBObject.h:41

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