CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes | Friends

ODDCCCycle Class Reference

#include <ODDCCCycle.h>

Inheritance diagram for ODDCCCycle:
IODConfig IDBObject

List of all members.

Public Member Functions

int getDCCConfigurationID () const
int getId () const
std::string getTable ()
 ODDCCCycle ()
bool operator!= (const ODDCCCycle &m) const
bool operator== (const ODDCCCycle &m) const
void setDCCConfigurationID (int x)
void setId (int id)
 ~ODDCCCycle ()

Private Member Functions

void clear ()
void fetchData (ODDCCCycle *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
void insertConfig () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void setByID (int id) throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

int m_dcc_config_id
int m_ID

Friends

class EcalCondDBInterface
class ODEcalCycle

Detailed Description

Definition at line 11 of file ODDCCCycle.h.


Constructor & Destructor Documentation

ODDCCCycle::ODDCCCycle ( )

Definition at line 9 of file ODDCCCycle.cc.

References NULL.

ODDCCCycle::~ODDCCCycle ( )

Definition at line 21 of file ODDCCCycle.cc.

{
}

Member Function Documentation

void ODDCCCycle::clear ( void  ) [private]

Definition at line 66 of file ODDCCCycle.cc.

void ODDCCCycle::fetchData ( ODDCCCycle result) throw (std::runtime_error) [private]

Definition at line 131 of file ODDCCCycle.cc.

References alignCSCRings::e, and query::result.

{
  this->checkConnection();
  result->clear();

  if(result->getId()==0){
    throw(std::runtime_error("ODDCCConfig::fetchData(): no Id defined for this ODDCCConfig "));
  }

  try {

    m_readStmt->setSQL("SELECT  dcc_configuration_id FROM ecal_dcc_cycle "
                 "WHERE cycle_id = :1 ");

    m_readStmt->setInt(1, result->getId());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();

    result->setDCCConfigurationID(       rset->getInt(1) );

  } catch (SQLException &e) {
    throw(std::runtime_error("ODDCCCycle::fetchData():  "+e.getMessage()));
  }
}
int ODDCCCycle::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 71 of file ODDCCCycle.cc.

References alignCSCRings::e.

{
  // Return from memory if available
  if (m_ID) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT cycle_id, dcc_configuration_id FROM ecal_dcc_cycle "
                 "WHERE cycle_id = :1 ");
    stmt->setInt(1, m_ID);
    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      m_ID = rset->getInt(1);
      m_dcc_config_id = rset->getInt(2);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("ODDCCCycle::fetchID:  "+e.getMessage()));
  }

  return m_ID;
}
int ODDCCCycle::getDCCConfigurationID ( ) const [inline]

Definition at line 26 of file ODDCCCycle.h.

References m_dcc_config_id.

{return m_dcc_config_id;}
int ODDCCCycle::getId ( ) const [inline]

Definition at line 22 of file ODDCCCycle.h.

References m_ID.

{ return m_ID;} ;
std::string ODDCCCycle::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 19 of file ODDCCCycle.h.

{ return "ECAL_DCC_CYCLE"; }
void ODDCCCycle::insertConfig ( ) throw (std::runtime_error) [private]

Definition at line 158 of file ODDCCCycle.cc.

References alignCSCRings::e.

Referenced by ODEcalCycle::writeDB().

{
  try {

    prepareWrite();
    writeDB();
    m_conn->commit();
    terminateWriteStatement();
  } catch (std::runtime_error &e) {
    m_conn->rollback();
    throw(e);
  } catch (...) {
    m_conn->rollback();
    throw(std::runtime_error("EcalCondDBInterface::insertDataSet:  Unknown exception caught"));
  }
}
bool ODDCCCycle::operator!= ( const ODDCCCycle m) const [inline]

Definition at line 30 of file ODDCCCycle.h.

References m.

{ return !(*this == m); }
bool ODDCCCycle::operator== ( const ODDCCCycle m) const [inline]

Definition at line 29 of file ODDCCCycle.h.

References m_ID.

{ return ( m_ID   == m.m_ID); }
void ODDCCCycle::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 26 of file ODDCCCycle.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_DCC_Cycle (cycle_id, dcc_configuration_id ) "
                 "VALUES (:1, :2 )");
  } catch (SQLException &e) {
    throw(std::runtime_error("ODDCCCycle::prepareWrite():  "+e.getMessage()));
  }
}
void ODDCCCycle::setByID ( int  id) throw (std::runtime_error) [private]

Definition at line 104 of file ODDCCCycle.cc.

References alignCSCRings::e.

{
   this->checkConnection();


  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT cycle_id, dcc_configuration_id FROM ecal_dcc_cycle "
                 "WHERE cycle_id = :1 ");
    stmt->setInt(1, id);
    ResultSet* rset = stmt->executeQuery();

    if (rset->next()) {
      m_ID = rset->getInt(1);
      m_dcc_config_id = rset->getInt(2);
    } else {
      m_ID = 0;
    }
    m_conn->terminateStatement(stmt);
  } catch (SQLException &e) {
    throw(std::runtime_error("ODDCCCycle::fetchID:  "+e.getMessage()));
  }
}
void ODDCCCycle::setDCCConfigurationID ( int  x) [inline]

Definition at line 25 of file ODDCCCycle.h.

References m_dcc_config_id, and x.

Referenced by ODEcalCycle::writeDB().

void ODDCCCycle::setId ( int  id) [inline]

Definition at line 21 of file ODDCCCycle.h.

References errorMatrix2Lands_multiChannel::id, and m_ID.

Referenced by ODEcalCycle::writeDB().

{m_ID=id;}
void ODDCCCycle::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 41 of file ODDCCCycle.cc.

References alignCSCRings::e, and getId().

{
  this->checkConnection();
  this->checkPrepare();

  try {

    m_writeStmt->setInt(1, this->getId());
    m_writeStmt->setInt(2, this->getDCCConfigurationID());

    m_writeStmt->executeUpdate();


  } catch (SQLException &e) {
    throw(std::runtime_error("ODDCCCycle::writeDB:  "+e.getMessage()));
  }

  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("ODDCCCycle::writeDB:  Failed to write"));
  }
  
 
}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 13 of file ODDCCCycle.h.

friend class ODEcalCycle [friend]

Definition at line 14 of file ODDCCCycle.h.


Member Data Documentation

Definition at line 35 of file ODDCCCycle.h.

Referenced by getDCCConfigurationID(), and setDCCConfigurationID().

int ODDCCCycle::m_ID [private]

Definition at line 34 of file ODDCCCycle.h.

Referenced by getId(), operator==(), and setId().