CMS 3D CMS Logo

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

#include <ODVfeToRejectInfo.h>

Inheritance diagram for ODVfeToRejectInfo:
IODConfig IDBObject

Public Member Functions

int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
int getId () const
 
std::string getTable () override
 
int getVersion () const
 
 ODVfeToRejectInfo ()
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setVersion (int id)
 
 ~ODVfeToRejectInfo () 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 (ODVfeToRejectInfo *result) noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

int m_ID
 
int m_version
 

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

Constructor & Destructor Documentation

ODVfeToRejectInfo::ODVfeToRejectInfo ( )

Definition at line 11 of file ODVfeToRejectInfo.cc.

References hitfit::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  m_version=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
ODVfeToRejectInfo::~ODVfeToRejectInfo ( )
override

Definition at line 30 of file ODVfeToRejectInfo.cc.

31 {
32 }

Member Function Documentation

void ODVfeToRejectInfo::clear ( void  )
private

Definition at line 24 of file ODVfeToRejectInfo.cc.

Referenced by getVersion().

24  {
25 
26 }
void ODVfeToRejectInfo::fetchData ( ODVfeToRejectInfo result)
privatenoexcept

Definition at line 130 of file ODVfeToRejectInfo.cc.

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

Referenced by getVersion().

132 {
133  this->checkConnection();
134  result->clear();
135  if(result->getId()==0 && (result->getConfigTag().empty()) ){
136  throw(std::runtime_error("ODVfeToRejectInfo::fetchData(): no Id defined for this ODVfeToRejectInfo "));
137  }
138 
139 
140 
141  try {
142  if(result->getId()!=0) {
143  m_readStmt->setSQL("SELECT * FROM " + getTable() +
144  " where rec_id = :1 ");
145  m_readStmt->setInt(1, result->getId());
146  } else if (!result->getConfigTag().empty()) {
147 
148  if(result->getVersion() !=0){
149  m_readStmt->setSQL("SELECT * FROM " + getTable() +
150  " WHERE tag = :tag "
151  " and version = :version " );
152  m_readStmt->setString(1, result->getConfigTag());
153  m_readStmt->setInt(2, result->getVersion());
154  } else {
155  // always select the last inserted one with a given tag
156  m_readStmt->setSQL("SELECT * FROM " + getTable() +
157  " WHERE tag = :1 and version= (select max(version) from "+getTable() +" where tag=:2) " );
158  m_readStmt->setString(1, result->getConfigTag());
159  m_readStmt->setString(2, result->getConfigTag());
160  }
161 
162  } else {
163  // we should never pass here
164  throw(std::runtime_error("ODVfeToRejectInfo::fetchData(): no Id defined for this record "));
165  }
166 
167 
168  ResultSet* rset = m_readStmt->executeQuery();
169 
170  rset->next();
171 
172  // 1 is the id and 2 is the config tag and 3 is the version
173 
174  result->setId(rset->getInt(1));
175  result->setConfigTag(getOraString(rset,2));
176  result->setVersion(rset->getInt(3));
177 
178  } catch (SQLException &e) {
179  throw(std::runtime_error(std::string("ODVfeToRejectInfo::fetchData(): ")+getOraMessage(&e)));
180  }
181 }
int getVersion() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string getTable() override
void setConfigTag(std::string x)
Definition: IODConfig.h:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void setVersion(int id)
int ODVfeToRejectInfo::fetchID ( )
noexcept

Definition at line 183 of file ODVfeToRejectInfo.cc.

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

Referenced by getVersion().

184 {
185  // Return from memory if available
186  if (m_ID!=0) {
187  return m_ID;
188  }
189 
190  this->checkConnection();
191 
192  try {
193  Statement* stmt = m_conn->createStatement();
194  stmt->setSQL("SELECT rec_id FROM "+ getTable()+
195  " WHERE tag=:1 and version=:2 " );
196 
197  stmt->setString(1, getConfigTag() );
198  stmt->setInt(2, getVersion() );
199 
200  ResultSet* rset = stmt->executeQuery();
201 
202  if (rset->next()) {
203  m_ID = rset->getInt(1);
204  } else {
205  m_ID = 0;
206  }
207  m_conn->terminateStatement(stmt);
208  } catch (SQLException &e) {
209  throw(std::runtime_error(std::string("ODVfeToRejectInfo::fetchID: ")+getOraMessage(&e)));
210  }
211 
212  return m_ID;
213 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int getVersion() const
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string getTable() override
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
int ODVfeToRejectInfo::fetchNextId ( )
noexcept

Definition at line 36 of file ODVfeToRejectInfo.cc.

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

Referenced by getVersion().

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

Definition at line 19 of file ODVfeToRejectInfo.h.

References m_ID.

19 { return m_ID; }
std::string ODVfeToRejectInfo::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 16 of file ODVfeToRejectInfo.h.

16 { return "VFES_to_reject_INFO"; }
int ODVfeToRejectInfo::getVersion ( ) const
inline
void ODVfeToRejectInfo::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 58 of file ODVfeToRejectInfo.cc.

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

Referenced by getVersion().

60 {
61  this->checkConnection();
62 
63  int next_id=0;
64  if(getId()==0){
65  next_id=fetchNextId();
66  }
67 
68  try {
69  m_writeStmt = m_conn->createStatement();
70  m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( rec_id, tag, version) "
71  " VALUES ( :1, :2, :3 ) " );
72 
73  m_writeStmt->setInt(1, next_id);
74  m_ID=next_id;
75 
76  } catch (SQLException &e) {
77  throw(std::runtime_error(std::string("ODVfeToRejectInfo::prepareWrite(): ")+getOraMessage(&e)));
78  }
79 
80 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
std::string getTable() override
int fetchNextId() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
void ODVfeToRejectInfo::setId ( int  id)
inline

Definition at line 18 of file ODVfeToRejectInfo.h.

References triggerObjects_cff::id, and m_ID.

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

Definition at line 82 of file ODVfeToRejectInfo.cc.

Referenced by getVersion().

82  {
83 
84  // parses the result of the XML parser that is a map of
85  // string string with variable name variable value
86 
87  for( std::map<std::string, std::string >::const_iterator ci=
88  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
89 
90  if(ci->first== "VERSION") setVersion(atoi(ci->second.c_str()) );
91  if(ci->first== "TAG") setConfigTag(ci->second);
92 
93  }
94 
95 }
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setVersion(int id)
void ODVfeToRejectInfo::setVersion ( int  id)
inline
void ODVfeToRejectInfo::writeDB ( )
privatenoexcept

Definition at line 97 of file ODVfeToRejectInfo.cc.

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

Referenced by getVersion().

99 {
100  this->checkConnection();
101  this->checkPrepare();
102 
103  try {
104 
105  // number 1 is the id
106  m_writeStmt->setString(2, this->getConfigTag());
107  m_writeStmt->setInt(3, this->getVersion());
108 
109  m_writeStmt->executeUpdate();
110 
111 
112  } catch (SQLException &e) {
113  throw(std::runtime_error(std::string("ODVfeToRejectInfo::writeDB(): ")+getOraMessage(&e)));
114  }
115  // Now get the ID
116  if (!this->fetchID()) {
117  throw(std::runtime_error("ODVfeToRejectInfo::writeDB: Failed to write"));
118  } else {
119  int old_version=this->getVersion();
120  m_readStmt = m_conn->createStatement();
121  this->fetchData (this);
122  m_conn->terminateStatement(m_readStmt);
123  if(this->getVersion()!=old_version) std::cout << "ODVfeToRejectInfo>>WARNING version is "<< getVersion()<< endl;
124  }
125 
126 
127 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
int getVersion() const
int fetchID() noexcept(false)
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void fetchData(ODVfeToRejectInfo *result) noexcept(false)
void checkPrepare() noexcept(false)
Definition: IODConfig.h:39

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 11 of file ODVfeToRejectInfo.h.

Member Data Documentation

int ODVfeToRejectInfo::m_ID
private

Definition at line 42 of file ODVfeToRejectInfo.h.

Referenced by getId(), and setId().

int ODVfeToRejectInfo::m_version
private

Definition at line 43 of file ODVfeToRejectInfo.h.

Referenced by getVersion(), and setVersion().