CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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) override
 
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) override
 
void setRunSeq (std::string runseq)
 
void setRunTypeDef (const RunTypeDef &runTypeDef)
 
 ~RunSeqDef () override
 
- 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.

9  {
10  m_env = nullptr;
11  m_conn = nullptr;
12  m_ID = 0;
13  m_runSeq = "";
15 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
RunTypeDef m_runType
Definition: RunSeqDef.h:39
std::string m_runSeq
Definition: RunSeqDef.h:38
RunSeqDef::~RunSeqDef ( )
override

Definition at line 17 of file RunSeqDef.cc.

17 {}

Member Function Documentation

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

Definition at line 91 of file RunSeqDef.cc.

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

91  {
92  this->checkConnection();
93  try {
94  Statement* stmt = m_conn->createStatement();
95  stmt->setSQL("SELECT def_id FROM ecal_sequence_type_def ORDER BY def_id");
96  ResultSet* rset = stmt->executeQuery();
97 
98  RunSeqDef runSeqDef;
99  runSeqDef.setConnection(m_env, m_conn);
100 
101  while (rset->next()) {
102  runSeqDef.setByID(rset->getInt(1));
103  fillVec->push_back(runSeqDef);
104  }
105  } catch (SQLException& e) {
106  throw(std::runtime_error("RunSeqDef::fetchAllDefs: " + e.getMessage()));
107  }
108 }
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
void setByID(int id) noexcept(false) override
Definition: RunSeqDef.cc:63
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
int RunSeqDef::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 27 of file RunSeqDef.cc.

References alignCSCRings::e.

27  {
28  // Return def from memory if available
29  if (m_ID) {
30  return m_ID;
31  }
32 
33  this->checkConnection();
34 
35  // get the run type
37  int run_type_id = m_runType.fetchID();
38 
39  try {
40  Statement* stmt = m_conn->createStatement();
41  stmt->setSQL(
42  "SELECT def_id FROM ecal_sequence_type_def WHERE "
43  " run_type_def_id = :1 and sequence_type_string = :2 ");
44 
45  stmt->setInt(1, run_type_id);
46  stmt->setString(2, m_runSeq);
47 
48  ResultSet* rset = stmt->executeQuery();
49 
50  if (rset->next()) {
51  m_ID = rset->getInt(1);
52  } else {
53  m_ID = 0;
54  }
55  m_conn->terminateStatement(stmt);
56  } catch (SQLException& e) {
57  throw(std::runtime_error("RunSeqDef::fetchID: " + e.getMessage()));
58  }
59 
60  return m_ID;
61 }
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
int fetchID() noexcept(false) override
Definition: RunTypeDef.cc:30
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunTypeDef m_runType
Definition: RunSeqDef.h:39
std::string m_runSeq
Definition: RunSeqDef.h:38
string RunSeqDef::getRunSeq ( ) const

Definition at line 19 of file RunSeqDef.cc.

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

Definition at line 23 of file RunSeqDef.cc.

23 { return m_runType; }
RunTypeDef m_runType
Definition: RunSeqDef.h:39
bool RunSeqDef::operator!= ( const RunSeqDef t) const
inline

Definition at line 34 of file RunSeqDef.h.

References m_runSeq.

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

Definition at line 33 of file RunSeqDef.h.

References m_runSeq.

33 { return m_runSeq == t.m_runSeq; }
std::string m_runSeq
Definition: RunSeqDef.h:38
void RunSeqDef::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 63 of file RunSeqDef.cc.

References alignCSCRings::e.

Referenced by fetchAllDefs().

63  {
64  this->checkConnection();
65 
66  try {
67  Statement* stmt = m_conn->createStatement();
68 
69  stmt->setSQL("SELECT run_type_def_id, sequence_type_string FROM ecal_sequence_type_def WHERE def_id = :1");
70  stmt->setInt(1, id);
71 
72  int idruntype = 0;
73  ResultSet* rset = stmt->executeQuery();
74  if (rset->next()) {
75  idruntype = rset->getInt(1);
76  m_runSeq = rset->getString(2);
77  } else {
78  throw(std::runtime_error("RunSeqDef::setByID: Given def_id is not in the database"));
79  }
80 
81  m_conn->terminateStatement(stmt);
82 
84  m_runType.setByID(idruntype);
85 
86  } catch (SQLException& e) {
87  throw(std::runtime_error("RunSeqDef::setByID: " + e.getMessage()));
88  }
89 }
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
void setByID(int id) noexcept(false) override
Definition: RunTypeDef.cc:60
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunTypeDef m_runType
Definition: RunSeqDef.h:39
std::string m_runSeq
Definition: RunSeqDef.h:38
void RunSeqDef::setRunSeq ( std::string  runseq)

Definition at line 21 of file RunSeqDef.cc.

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

Definition at line 25 of file RunSeqDef.cc.

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

Definition at line 110 of file RunSeqDef.cc.

References alignCSCRings::e.

110  {
111  // see if this data is already in the DB
112  try {
113  if (this->fetchID()) {
114  return m_ID;
115  }
116  } catch (SQLException& e) {
117  // it does not exist yet
118  }
119 
120  // check the connectioin
121  this->checkConnection();
122 
123  // get the run type
125  int run_type_id = m_runType.fetchID();
126 
127  // write new seq def to the DB
128  try {
129  Statement* stmt = m_conn->createStatement();
130 
131  stmt->setSQL(
132  "insert into ecal_sequence_type_def(RUN_TYPE_DEF_ID, SEQUENCE_TYPE_STRING) values "
133  " ( :1, :2 )");
134  stmt->setInt(1, run_type_id);
135  stmt->setString(2, m_runSeq);
136 
137  stmt->executeUpdate();
138 
139  m_conn->terminateStatement(stmt);
140  } catch (SQLException& e) {
141  throw(std::runtime_error("RunSeqDef::writeDB: " + e.getMessage()));
142  }
143 
144  // now get the tag_id
145  if (!this->fetchID()) {
146  throw(std::runtime_error("RunSeqDef::writeDB: Failed to write"));
147  }
148 
149  return m_ID;
150 }
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
int fetchID() noexcept(false) override
Definition: RunTypeDef.cc:30
int fetchID() noexcept(false) override
Definition: RunSeqDef.cc:27
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
RunTypeDef m_runType
Definition: RunSeqDef.h:39
std::string m_runSeq
Definition: RunSeqDef.h:38

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 38 of file RunSeqDef.h.

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

RunTypeDef RunSeqDef::m_runType
protected

Definition at line 39 of file RunSeqDef.h.