CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Friends
RunSeqDef Class Reference

#include <RunSeqDef.h>

Inheritance diagram for RunSeqDef:
IDef IUniqueDBObject IDBObject

Public Member Functions

int fetchID () noexcept(false)
 
std::string getRunSeq () const
 
RunTypeDef getRunTypeDef () const
 
bool operator!= (const RunSeqDef &t) const
 
bool operator== (const RunSeqDef &t) const
 
 RunSeqDef ()
 
void setByID (int id) noexcept(false)
 
void setRunSeq (std::string runseq)
 
void setRunTypeDef (const RunTypeDef &runTypeDef)
 
virtual ~RunSeqDef ()
 
- 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 ()
 

Protected Member Functions

void fetchAllDefs (std::vector< RunSeqDef > *fillVec) noexcept(false)
 
int writeDB () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

std::string m_runSeq
 
RunTypeDef m_runType
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Friends

class EcalCondDBInterface
 
class ODRunConfigSeqInfo
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 

Detailed Description

Def for Location information

Definition at line 13 of file RunSeqDef.h.

Constructor & Destructor Documentation

RunSeqDef::RunSeqDef ( )

Definition at line 9 of file RunSeqDef.cc.

References NULL.

10 {
11  m_env = NULL;
12  m_conn = NULL;
13  m_ID = 0;
14  m_runSeq = "";
16 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
RunTypeDef m_runType
Definition: RunSeqDef.h:43
std::string m_runSeq
Definition: RunSeqDef.h:42
RunSeqDef::~RunSeqDef ( )
virtual

Definition at line 20 of file RunSeqDef.cc.

21 {
22 }

Member Function Documentation

void RunSeqDef::fetchAllDefs ( std::vector< RunSeqDef > *  fillVec)
protectednoexcept

Definition at line 118 of file RunSeqDef.cc.

References alignCSCRings::e, setByID(), and IDBObject::setConnection().

120 {
121  this->checkConnection();
122  try {
123  Statement* stmt = m_conn->createStatement();
124  stmt->setSQL("SELECT def_id FROM ecal_sequence_type_def ORDER BY def_id");
125  ResultSet* rset = stmt->executeQuery();
126 
127  RunSeqDef runSeqDef;
128  runSeqDef.setConnection(m_env, m_conn);
129 
130  while(rset->next()) {
131  runSeqDef.setByID( rset->getInt(1) );
132  fillVec->push_back( runSeqDef );
133  }
134  } catch (SQLException &e) {
135  throw(std::runtime_error("RunSeqDef::fetchAllDefs: "+e.getMessage()));
136  }
137 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setByID(int id) noexcept(false)
Definition: RunSeqDef.cc:86
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int RunSeqDef::fetchID ( )
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 44 of file RunSeqDef.cc.

References alignCSCRings::e.

46 {
47  // Return def from memory if available
48  if (m_ID) {
49  return m_ID;
50  }
51 
52  this->checkConnection();
53 
54 
55  // get the run type
57  int run_type_id = m_runType.fetchID();
58 
59 
60  try {
61  Statement* stmt = m_conn->createStatement();
62  stmt->setSQL("SELECT def_id FROM ecal_sequence_type_def WHERE "
63  " run_type_def_id = :1 and sequence_type_string = :2 "
64  );
65 
66  stmt->setInt(1, run_type_id);
67  stmt->setString(2, m_runSeq);
68 
69  ResultSet* rset = stmt->executeQuery();
70 
71  if (rset->next()) {
72  m_ID = rset->getInt(1);
73  } else {
74  m_ID = 0;
75  }
76  m_conn->terminateStatement(stmt);
77  } catch (SQLException &e) {
78  throw(std::runtime_error("RunSeqDef::fetchID: "+e.getMessage()));
79  }
80 
81  return m_ID;
82 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)
Definition: RunTypeDef.cc:50
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunTypeDef m_runType
Definition: RunSeqDef.h:43
std::string m_runSeq
Definition: RunSeqDef.h:42
string RunSeqDef::getRunSeq ( ) const

Definition at line 26 of file RunSeqDef.cc.

26 { return m_runSeq;}
std::string m_runSeq
Definition: RunSeqDef.h:42
RunTypeDef RunSeqDef::getRunTypeDef ( ) const

Definition at line 32 of file RunSeqDef.cc.

33 {
34  return m_runType;
35 }
RunTypeDef m_runType
Definition: RunSeqDef.h:43
bool RunSeqDef::operator!= ( const RunSeqDef t) const
inline

Definition at line 38 of file RunSeqDef.h.

References m_runSeq.

38 { return m_runSeq != t.m_runSeq; }
std::string m_runSeq
Definition: RunSeqDef.h:42
bool RunSeqDef::operator== ( const RunSeqDef t) const
inline

Definition at line 37 of file RunSeqDef.h.

References m_runSeq.

37 { return m_runSeq == t.m_runSeq; }
std::string m_runSeq
Definition: RunSeqDef.h:42
void RunSeqDef::setByID ( int  id)
virtualnoexcept

Implements IUniqueDBObject.

Definition at line 86 of file RunSeqDef.cc.

References alignCSCRings::e.

Referenced by fetchAllDefs().

88 {
89  this->checkConnection();
90 
91  try {
92  Statement* stmt = m_conn->createStatement();
93 
94  stmt->setSQL("SELECT run_type_def_id, sequence_type_string FROM ecal_sequence_type_def WHERE def_id = :1");
95  stmt->setInt(1, id);
96 
97  int idruntype=0;
98  ResultSet* rset = stmt->executeQuery();
99  if (rset->next()) {
100  idruntype = rset->getInt(1);
101  m_runSeq = rset->getString(2);
102  } else {
103  throw(std::runtime_error("RunSeqDef::setByID: Given def_id is not in the database"));
104  }
105 
106  m_conn->terminateStatement(stmt);
107 
109  m_runType.setByID(idruntype);
110 
111  } catch (SQLException &e) {
112  throw(std::runtime_error("RunSeqDef::setByID: "+e.getMessage()));
113  }
114 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void setByID(int id) noexcept(false)
Definition: RunTypeDef.cc:84
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunTypeDef m_runType
Definition: RunSeqDef.h:43
std::string m_runSeq
Definition: RunSeqDef.h:42
void RunSeqDef::setRunSeq ( std::string  runseq)

Definition at line 30 of file RunSeqDef.cc.

30 { m_runSeq = runseq;}
std::string m_runSeq
Definition: RunSeqDef.h:42
void RunSeqDef::setRunTypeDef ( const RunTypeDef runTypeDef)

Definition at line 37 of file RunSeqDef.cc.

38 {
39  m_runType = runTypeDef;
40 }
RunTypeDef m_runType
Definition: RunSeqDef.h:43
int RunSeqDef::writeDB ( )
protectednoexcept

Definition at line 139 of file RunSeqDef.cc.

References alignCSCRings::e.

141 {
142  // see if this data is already in the DB
143  try {
144  if (this->fetchID()) {
145  return m_ID;
146  }
147  } catch (SQLException &e) {
148  // it does not exist yet
149  }
150 
151  // check the connectioin
152  this->checkConnection();
153 
154  // get the run type
156  int run_type_id = m_runType.fetchID();
157 
158  // write new seq def to the DB
159  try {
160  Statement* stmt = m_conn->createStatement();
161 
162  stmt->setSQL("insert into ecal_sequence_type_def(RUN_TYPE_DEF_ID, SEQUENCE_TYPE_STRING) values "
163  " ( :1, :2 )");
164  stmt->setInt(1, run_type_id);
165  stmt->setString(2, m_runSeq);
166 
167 
168  stmt->executeUpdate();
169 
170  m_conn->terminateStatement(stmt);
171  } catch (SQLException &e) {
172  throw(std::runtime_error("RunSeqDef::writeDB: "+e.getMessage()));
173  }
174 
175  // now get the tag_id
176  if (!this->fetchID()) {
177  throw(std::runtime_error("RunSeqDef::writeDB: Failed to write"));
178  }
179 
180  return m_ID;
181 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int fetchID() noexcept(false)
Definition: RunTypeDef.cc:50
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
int fetchID() noexcept(false)
Definition: RunSeqDef.cc:44
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunTypeDef m_runType
Definition: RunSeqDef.h:43
std::string m_runSeq
Definition: RunSeqDef.h:42

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 16 of file RunSeqDef.h.

friend class ODRunConfigSeqInfo
friend

Definition at line 15 of file RunSeqDef.h.

Member Data Documentation

std::string RunSeqDef::m_runSeq
protected

Definition at line 42 of file RunSeqDef.h.

Referenced by operator!=(), and operator==().

RunTypeDef RunSeqDef::m_runType
protected

Definition at line 43 of file RunSeqDef.h.