CMS 3D CMS Logo

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

#include <MODDCCOperationDat.h>

Inheritance diagram for MODDCCOperationDat:
IDataItem IDBObject

Public Member Functions

std::string getOperation () const
 
std::string getTable ()
 
 MODDCCOperationDat ()
 
void setOperation (std::string x)
 
 ~MODDCCOperationDat ()
 
- Public Member Functions inherited from IDataItem
 IDataItem ()
 
- 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 fetchData (std::map< EcalLogicID, MODDCCOperationDat > *fillMap, MODRunIOV *iov) noexcept(false)
 
void prepareWrite () noexcept(false)
 
void writeArrayDB (const std::map< EcalLogicID, MODDCCOperationDat > *data, MODRunIOV *iov) noexcept(false)
 
void writeDB (const EcalLogicID *ecid, const MODDCCOperationDat *item, MODRunIOV *iov) noexcept(false)
 

Private Attributes

std::string m_word
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS =1024
 
- Protected Member Functions inherited from IDataItem
void checkPrepare () noexcept(false)
 
void createReadStatement () 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 IDataItem
oracle::occi::Statement * m_readStmt
 
oracle::occi::Statement * m_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 11 of file MODDCCOperationDat.h.

Constructor & Destructor Documentation

MODDCCOperationDat::MODDCCOperationDat ( )

Definition at line 11 of file MODDCCOperationDat.cc.

References NULL.

12 {
13  m_env = NULL;
14  m_conn = NULL;
15  m_writeStmt = NULL;
16  m_readStmt = NULL;
17 
18  m_word = "";
19 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
#define NULL
Definition: scimark2.h:8
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
MODDCCOperationDat::~MODDCCOperationDat ( )

Definition at line 23 of file MODDCCOperationDat.cc.

24 {
25 }

Member Function Documentation

void MODDCCOperationDat::fetchData ( std::map< EcalLogicID, MODDCCOperationDat > *  fillMap,
MODRunIOV iov 
)
privatenoexcept

Definition at line 72 of file MODDCCOperationDat.cc.

References MillePedeFileConverter_cfg::e, AlCaHLTBitMon_ParallelJobs::p, and setOperation().

Referenced by getOperation().

74 {
75  this->checkConnection();
76  fillMap->clear();
77 
78  iov->setConnection(m_env, m_conn);
79  int iovID = iov->fetchID();
80  if (!iovID) {
81  // throw(std::runtime_error("MODDCCOperationDat::writeDB: IOV not in DB"));
82  return;
83  }
84 
85  try {
86 
87  m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
88  " d.operationMode "
89  "FROM channelview cv JOIN "+getTable()+" d "
90  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
91  "WHERE d.iov_id = :iov_id");
92  m_readStmt->setInt(1, iovID);
93  ResultSet* rset = m_readStmt->executeQuery();
94 
95  std::pair< EcalLogicID, MODDCCOperationDat > p;
97  while(rset->next()) {
98  p.first = EcalLogicID( rset->getString(1), // name
99  rset->getInt(2), // logic_id
100  rset->getInt(3), // id1
101  rset->getInt(4), // id2
102  rset->getInt(5), // id3
103  rset->getString(6)); // maps_to
104 
105  dat.setOperation( rset->getString(7) );
106 
107  p.second = dat;
108  fillMap->insert(p);
109  }
110  } catch (SQLException &e) {
111  throw(std::runtime_error("MODDCCOperationDat::fetchData(): "+e.getMessage()));
112  }
113 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
int fetchID() noexcept(false)
Definition: MODRunIOV.cc:101
std::string getTable()
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement * m_readStmt
Definition: IDataItem.h:29
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
void setOperation(std::string x)
std::string MODDCCOperationDat::getOperation ( ) const
inline

Definition at line 21 of file MODDCCOperationDat.h.

References data, fetchData(), m_word, noexcept, prepareWrite(), writeArrayDB(), and writeDB().

Referenced by writeArrayDB().

21 { return m_word; }
std::string MODDCCOperationDat::getTable ( )
inlinevirtual

Implements IDataItem.

Definition at line 18 of file MODDCCOperationDat.h.

18 { return "OD_DCC_OPERATION_DAT"; }
void MODDCCOperationDat::prepareWrite ( )
privatevirtualnoexcept

Implements IDataItem.

Definition at line 29 of file MODDCCOperationDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getOperation().

31 {
32  this->checkConnection();
33 
34  try {
35  m_writeStmt = m_conn->createStatement();
36  m_writeStmt->setSQL("INSERT INTO "+getTable()+" (iov_id, logic_id, "
37  "operationMode) "
38  "VALUES (:iov_id, :logic_id, "
39  ":1) ");
40  } catch (SQLException &e) {
41  throw(std::runtime_error("MODDCCOperationDat::prepareWrite(): "+e.getMessage()));
42  }
43 }
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
std::string getTable()
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
void MODDCCOperationDat::setOperation ( std::string  x)
inline

Definition at line 20 of file MODDCCOperationDat.h.

References m_word, and x.

Referenced by fetchData().

20 { m_word = x; }
void MODDCCOperationDat::writeArrayDB ( const std::map< EcalLogicID, MODDCCOperationDat > *  data,
MODRunIOV iov 
)
privatenoexcept

Definition at line 115 of file MODDCCOperationDat.cc.

References KineDebug3::count(), data, MillePedeFileConverter_cfg::e, EcalLogicID::getLogicID(), getOperation(), electrons_cff::ids, AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, x, and geometryCSVtoXML::xx.

Referenced by getOperation().

117 {
118  this->checkConnection();
119  this->checkPrepare();
120 
121  int iovID = iov->fetchID();
122  if (!iovID) { throw(std::runtime_error("MODDCCOperationDat::writeArrayDB: IOV not in DB")); }
123 
124 
125  int nrows=data->size();
126  int* ids= new int[nrows];
127  int* iovid_vec= new int[nrows];
128  std::string* xx= new std::string[nrows];
129 
130  ub2* ids_len= new ub2[nrows];
131  ub2* iov_len= new ub2[nrows];
132  ub2* x_len= new ub2[nrows];
133 
134  const EcalLogicID* channel;
135  const MODDCCOperationDat* dataitem;
136  int count=0;
137  typedef map< EcalLogicID, MODDCCOperationDat >::const_iterator CI;
138  for (CI p = data->begin(); p != data->end(); ++p) {
139  channel = &(p->first);
140  int logicID = channel->getLogicID();
141  if (!logicID) { throw(std::runtime_error("MODDCCOperationDat::writeArrayDB: Bad EcalLogicID")); }
142  ids[count]=logicID;
143  iovid_vec[count]=iovID;
144 
145  dataitem = &(p->second);
146  // dataIface.writeDB( channel, dataitem, iov);
147  std::string x=dataitem->getOperation();
148 
149  xx[count]=x;
150 
151  ids_len[count]=sizeof(ids[count]);
152  iov_len[count]=sizeof(iovid_vec[count]);
153 
154  x_len[count]=sizeof(xx[count]);
155 
156  count++;
157  }
158 
159 
160  try {
161  m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len);
162  m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len );
163  m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCISTRING , sizeof(xx[0]), x_len );
164 
165  m_writeStmt->executeArrayUpdate(nrows);
166 
167  delete [] ids;
168  delete [] iovid_vec;
169  delete [] xx;
170 
171 
172  delete [] ids_len;
173  delete [] iov_len;
174  delete [] x_len;
175 
176 
177 
178  } catch (SQLException &e) {
179  throw(std::runtime_error("MonPedestalsDat::writeArrayDB(): "+e.getMessage()));
180  }
181 }
std::string getOperation() const
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int fetchID() noexcept(false)
Definition: MODRunIOV.cc:101
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void MODDCCOperationDat::writeDB ( const EcalLogicID ecid,
const MODDCCOperationDat item,
MODRunIOV iov 
)
privatenoexcept

Definition at line 47 of file MODDCCOperationDat.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getOperation().

49 {
50  this->checkConnection();
51  this->checkPrepare();
52 
53  int iovID = iov->fetchID();
54  if (!iovID) { throw(std::runtime_error("MODDCCOperationDat::writeDB: IOV not in DB")); }
55 
56  int logicID = ecid->getLogicID();
57  if (!logicID) { throw(std::runtime_error("MODDCCOperationDat::writeDB: Bad EcalLogicID")); }
58 
59  try {
60  m_writeStmt->setInt(1, iovID);
61  m_writeStmt->setInt(2, logicID);
62  m_writeStmt->setString(3, item->getOperation() );
63 
64  m_writeStmt->executeUpdate();
65  } catch (SQLException &e) {
66  throw(std::runtime_error("MODDCCOperationDat::writeDB(): "+e.getMessage()));
67  }
68 }
std::string getOperation() const
oracle::occi::Statement * m_writeStmt
Definition: IDataItem.h:28
void checkPrepare() noexcept(false)
Definition: IDataItem.h:31
int fetchID() noexcept(false)
Definition: MODRunIOV.cc:101
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getLogicID() const
Definition: EcalLogicID.cc:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 13 of file MODDCCOperationDat.h.

Member Data Documentation

std::string MODDCCOperationDat::m_word
private

Definition at line 39 of file MODDCCOperationDat.h.

Referenced by getOperation(), and setOperation().