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

#include <MonRunTag.h>

Inheritance diagram for MonRunTag:
ITag IUniqueDBObject IDBObject

Public Member Functions

int fetchID () throw (std::runtime_error)
 
std::string getGeneralTag () const
 
MonVersionDef getMonVersionDef () const
 
 MonRunTag ()
 
bool operator!= (const MonRunTag &t) const
 
bool operator== (const MonRunTag &t) const
 
void setByID (int id) throw (std::runtime_error)
 
void setGeneralTag (std::string tag)
 
void setMonVersionDef (MonVersionDef ver)
 
 ~MonRunTag ()
 
- 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 fetchAllTags (std::vector< MonRunTag > *fillVec) throw (std::runtime_error)
 
void fetchParentIDs (int *verID) throw (std::runtime_error)
 
int writeDB () throw (std::runtime_error)
 

Private Attributes

std::string m_genTag
 
MonVersionDef m_monVersionDef
 

Friends

class EcalCondDBInterface
 
class MonRunIOV
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Tag for Monitoring Sub-Run information

Definition at line 14 of file MonRunTag.h.

Constructor & Destructor Documentation

MonRunTag::MonRunTag ( )

Definition at line 9 of file MonRunTag.cc.

References NULL.

10 {
11  m_env = NULL;
12  m_conn = NULL;
13  m_ID = 0;
14  m_genTag = "default";
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
MonVersionDef m_monVersionDef
Definition: MonRunTag.h:45
std::string m_genTag
Definition: MonRunTag.h:44
MonRunTag::~MonRunTag ( )

Definition at line 20 of file MonRunTag.cc.

21 {
22 }

Member Function Documentation

void MonRunTag::fetchAllTags ( std::vector< MonRunTag > *  fillVec)
throw (std::runtime_error
)
private

Definition at line 169 of file MonRunTag.cc.

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

171 {
172  this->checkConnection();
173  try {
174  Statement* stmt = m_conn->createStatement();
175  stmt->setSQL("SELECT tag_id FROM mon_run_tag ORDER BY tag_id");
176  ResultSet* rset = stmt->executeQuery();
177 
178  MonRunTag runtag;
179  runtag.setConnection(m_env, m_conn);
180  while(rset->next()) {
181  runtag.setByID( rset->getInt(1) );
182  fillVec->push_back( runtag );
183  }
184  m_conn->terminateStatement(stmt);
185  } catch (SQLException &e) {
186  throw(std::runtime_error("MonRunTag::fetchAllTags: "+e.getMessage()));
187  }
188 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setByID(int id)
Definition: MonRunTag.cc:100
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void checkConnection() const
Definition: IDBObject.h:41
int MonRunTag::fetchID ( )
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 59 of file MonRunTag.cc.

References alignCSCRings::e.

61 {
62  // Return tag from memory if available
63  if (m_ID) {
64  return m_ID;
65  }
66 
67  this->checkConnection();
68 
69  // fetch parent IDs
70  int verID;
71  this->fetchParentIDs(&verID);
72 
73  // fetch this ID
74  try {
75  Statement* stmt = m_conn->createStatement();
76  stmt->setSQL("SELECT tag_id FROM mon_run_tag WHERE "
77  "gen_tag = :1 AND "
78  "mon_ver_id = :2");
79 
80  stmt->setString(1, m_genTag);
81  stmt->setInt(2, verID);
82 
83  ResultSet* rset = stmt->executeQuery();
84 
85  if (rset->next()) {
86  m_ID = rset->getInt(1);
87  } else {
88  m_ID = 0;
89  }
90  m_conn->terminateStatement(stmt);
91  } catch (SQLException &e) {
92  throw(std::runtime_error("MonRunTag::fetchID: "+e.getMessage()));
93  }
94 
95  return m_ID;
96 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void fetchParentIDs(int *verID)
Definition: MonRunTag.cc:192
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void checkConnection() const
Definition: IDBObject.h:41
std::string m_genTag
Definition: MonRunTag.h:44
void MonRunTag::fetchParentIDs ( int *  verID)
throw (std::runtime_error
)
private

Definition at line 192 of file MonRunTag.cc.

194 {
195  // get the monitoring version
197  *verID = m_monVersionDef.fetchID();
198 
199  if (! *verID) {
200  throw(std::runtime_error("MonRunTag::writeDB: Given monitoring version does not exist in DB"));
201  }
202 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
MonVersionDef m_monVersionDef
Definition: MonRunTag.h:45
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
string MonRunTag::getGeneralTag ( ) const

Definition at line 26 of file MonRunTag.cc.

27 {
28  return m_genTag;
29 }
std::string m_genTag
Definition: MonRunTag.h:44
MonVersionDef MonRunTag::getMonVersionDef ( ) const

Definition at line 43 of file MonRunTag.cc.

44 {
45  return m_monVersionDef;
46 }
MonVersionDef m_monVersionDef
Definition: MonRunTag.h:45
bool MonRunTag::operator!= ( const MonRunTag t) const
inline

Definition at line 40 of file MonRunTag.h.

References lumiQTWidget::t.

40 { return !(*this == t); }
bool MonRunTag::operator== ( const MonRunTag t) const
inline

Definition at line 34 of file MonRunTag.h.

References m_genTag, and m_monVersionDef.

35  {
36  return (m_genTag == t.m_genTag &&
38  }
MonVersionDef m_monVersionDef
Definition: MonRunTag.h:45
std::string m_genTag
Definition: MonRunTag.h:44
void MonRunTag::setByID ( int  id)
throw (std::runtime_error
)
virtual

Implements IUniqueDBObject.

Definition at line 100 of file MonRunTag.cc.

References alignCSCRings::e, and errorMatrix2Lands_multiChannel::id.

Referenced by fetchAllTags().

102 {
103  this->checkConnection();
104 
105  try {
106  Statement* stmt = m_conn->createStatement();
107 
108  stmt->setSQL("SELECT gen_tag, mon_ver_id FROM mon_run_tag WHERE tag_id = :1");
109  stmt->setInt(1, id);
110 
111  ResultSet* rset = stmt->executeQuery();
112  if (rset->next()) {
113  m_genTag = rset->getString(1);
114  int verID = rset->getInt(2);
115  m_monVersionDef.setByID(verID);
116  m_ID = id;
117  } else {
118  throw(std::runtime_error("MonRunTag::setByID: Given tag_id is not in the database"));
119  }
120 
121  m_conn->terminateStatement(stmt);
122  } catch (SQLException &e) {
123  throw(std::runtime_error("MonRunTag::setByID: "+e.getMessage()));
124  }
125 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void setByID(int id)
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
MonVersionDef m_monVersionDef
Definition: MonRunTag.h:45
void checkConnection() const
Definition: IDBObject.h:41
std::string m_genTag
Definition: MonRunTag.h:44
void MonRunTag::setGeneralTag ( std::string  tag)
void MonRunTag::setMonVersionDef ( MonVersionDef  ver)
int MonRunTag::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 128 of file MonRunTag.cc.

References alignCSCRings::e.

130 {
131  // see if this data is already in the DB
132  if (this->fetchID()) {
133  return m_ID;
134  }
135 
136  // check the connectioin
137  this->checkConnection();
138 
139  // fetch parent IDs
140  int verID;
141  this->fetchParentIDs(&verID);
142 
143  // write new tag to the DB
144  try {
145  Statement* stmt = m_conn->createStatement();
146 
147  stmt->setSQL("INSERT INTO mon_run_tag (tag_id, gen_tag, mon_ver_id) "
148  "VALUES (mon_run_tag_sq.NextVal, :1, :2)");
149  stmt->setString(1, m_genTag);
150  stmt->setInt(2, verID);
151 
152  stmt->executeUpdate();
153 
154  m_conn->terminateStatement(stmt);
155  } catch (SQLException &e) {
156  throw(std::runtime_error("MonRunTag::writeDB: "+e.getMessage()));
157  }
158 
159  // now get the tag_id
160  if (!this->fetchID()) {
161  throw(std::runtime_error("MonRunTag::writeDB: Failed to write"));
162  }
163 
164  return m_ID;
165 }
int fetchID()
Definition: MonRunTag.cc:59
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void fetchParentIDs(int *verID)
Definition: MonRunTag.cc:192
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
void checkConnection() const
Definition: IDBObject.h:41
std::string m_genTag
Definition: MonRunTag.h:44

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 17 of file MonRunTag.h.

friend class MonRunIOV
friend

Definition at line 16 of file MonRunTag.h.

Member Data Documentation

std::string MonRunTag::m_genTag
private

Definition at line 44 of file MonRunTag.h.

Referenced by operator==().

MonVersionDef MonRunTag::m_monVersionDef
private

Definition at line 45 of file MonRunTag.h.

Referenced by operator==().