CMS 3D CMS Logo

CaliGeneralDat Class Reference

#include <OnlineDB/EcalCondDB/interface/CaliGeneralDat.h>

Inheritance diagram for CaliGeneralDat:

IDataItem IDBObject

List of all members.

Public Member Functions

 CaliGeneralDat ()
std::string getComments () const
int getNumEvents () const
std::string getTable ()
void setComments (std::string comments)
void setNumEvents (int n)
 ~CaliGeneralDat ()

Private Member Functions

void fetchData (std::map< EcalLogicID, CaliGeneralDat > *fillVec, CaliIOV *iov) throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB (const EcalLogicID *ecid, const CaliGeneralDat *item, CaliIOV *iov) throw (std::runtime_error)

Private Attributes

std::string m_comments
int m_numEvents

Friends

class EcalCondDBInterface


Detailed Description

Definition at line 12 of file CaliGeneralDat.h.


Constructor & Destructor Documentation

CaliGeneralDat::CaliGeneralDat (  ) 

Definition at line 12 of file CaliGeneralDat.cc.

References m_comments, IDBObject::m_conn, IDBObject::m_env, m_numEvents, IDataItem::m_writeStmt, and NULL.

00013 {
00014   m_env = NULL;
00015   m_conn = NULL;
00016   m_writeStmt = NULL;
00017   
00018   m_numEvents = 0;
00019   m_comments = "none";
00020 }

CaliGeneralDat::~CaliGeneralDat (  ) 

Definition at line 24 of file CaliGeneralDat.cc.

00025 {
00026 }


Member Function Documentation

void CaliGeneralDat::fetchData ( std::map< EcalLogicID, CaliGeneralDat > *  fillVec,
CaliIOV iov 
) throw (std::runtime_error) [private]

Definition at line 75 of file CaliGeneralDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setComments(), and setNumEvents().

00077 {
00078   this->checkConnection();
00079   fillMap->clear();
00080   
00081   iov->setConnection(m_env, m_conn);
00082   int iovID = iov->fetchID();
00083   if (!iovID) { 
00084     //  throw(runtime_error("CaliGeneralDat::writeDB:  IOV not in DB")); 
00085     return;
00086   }
00087   
00088   try {
00089 
00090     m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, "
00091                  "d.num_events, d.comments "
00092                  "FROM channelview cv JOIN cali_general_dat d "
00093                  "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to "
00094                  "WHERE d.iov_id = :iov_id");
00095     m_readStmt->setInt(1, iovID);
00096     ResultSet* rset = m_readStmt->executeQuery();
00097     
00098     std::pair< EcalLogicID, CaliGeneralDat > p;
00099     CaliGeneralDat dat;
00100     while(rset->next()) {
00101       p.first = EcalLogicID( rset->getString(1),     // name
00102                              rset->getInt(2),        // logic_id
00103                              rset->getInt(3),        // id1
00104                              rset->getInt(4),        // id2
00105                              rset->getInt(5),        // id3
00106                              rset->getString(6));    // maps_to
00107       
00108       dat.setNumEvents( rset->getInt(7) );
00109       dat.setComments( rset->getString(8) );
00110       
00111       p.second = dat;
00112       fillMap->insert(p);
00113     }
00114   } catch (SQLException &e) {
00115     throw(runtime_error("CaliGeneralDat::fetchData():  "+e.getMessage()));
00116   }
00117 }

std::string CaliGeneralDat::getComments (  )  const [inline]

Definition at line 25 of file CaliGeneralDat.h.

References m_comments.

00025 { return m_comments; }

int CaliGeneralDat::getNumEvents (  )  const [inline]

Definition at line 22 of file CaliGeneralDat.h.

References m_numEvents.

00022 { return m_numEvents; }

std::string CaliGeneralDat::getTable (  )  [inline, virtual]

Implements IDataItem.

Definition at line 19 of file CaliGeneralDat.h.

00019 { return "CALI_GENERAL_DAT"; }

void CaliGeneralDat::prepareWrite (  )  throw (std::runtime_error) [private, virtual]

Implements IDataItem.

Definition at line 30 of file CaliGeneralDat.cc.

References IDBObject::checkConnection(), e, IDBObject::m_conn, and IDataItem::m_writeStmt.

00032 {
00033   this->checkConnection();
00034   
00035   try {
00036     m_writeStmt = m_conn->createStatement();
00037     m_writeStmt->setSQL("INSERT INTO cali_general_dat (iov_id, logic_id, "
00038                         "num_events, comments) "
00039                         "VALUES (:iov_id, :logic_id, "
00040                         ":3, :4)");
00041   } catch (SQLException &e) {
00042     throw(runtime_error("CaliGeneralDat::prepareWrite():  "+e.getMessage()));
00043   }
00044 }

void CaliGeneralDat::setComments ( std::string  comments  )  [inline]

Definition at line 24 of file CaliGeneralDat.h.

References m_comments.

Referenced by fetchData().

00024 { m_comments = comments; }

void CaliGeneralDat::setNumEvents ( int  n  )  [inline]

Definition at line 21 of file CaliGeneralDat.h.

References m_numEvents.

Referenced by fetchData().

00021 { m_numEvents = n; }

void CaliGeneralDat::writeDB ( const EcalLogicID ecid,
const CaliGeneralDat item,
CaliIOV iov 
) throw (std::runtime_error) [private]

Definition at line 48 of file CaliGeneralDat.cc.

References IDBObject::checkConnection(), IDataItem::checkPrepare(), e, and IDataItem::m_writeStmt.

00050 {
00051   this->checkConnection();
00052   this->checkPrepare();
00053   
00054   int iovID = iov->fetchID();
00055   if (!iovID) { throw(runtime_error("CaliGeneralDat::writeDB:  IOV not in DB")); }
00056   
00057   int logicID = ecid->getLogicID();
00058   if (!logicID) { throw(runtime_error("CaliGeneralDat::writeDB:  Bad EcalLogicID")); }
00059   
00060   try {
00061     m_writeStmt->setInt(1, iovID);
00062     m_writeStmt->setInt(2, logicID);
00063     
00064     m_writeStmt->setInt(3, item->getNumEvents() );
00065     m_writeStmt->setString(4, item->getComments() );
00066     
00067     m_writeStmt->executeUpdate();
00068   } catch (SQLException &e) {
00069     throw(runtime_error("CaliGeneralDat::writeDB():  "+e.getMessage()));
00070   }
00071 }


Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 14 of file CaliGeneralDat.h.


Member Data Documentation

std::string CaliGeneralDat::m_comments [private]

Definition at line 39 of file CaliGeneralDat.h.

Referenced by CaliGeneralDat(), getComments(), and setComments().

int CaliGeneralDat::m_numEvents [private]

Definition at line 38 of file CaliGeneralDat.h.

Referenced by CaliGeneralDat(), getNumEvents(), and setNumEvents().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:15:39 2009 for CMSSW by  doxygen 1.5.4