CMS 3D CMS Logo

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

ODJBH4Cycle Class Reference

#include <ODJBH4Cycle.h>

Inheritance diagram for ODJBH4Cycle:
IODConfig IDBObject

List of all members.

Public Member Functions

int getId () const
int getJBH4ConfigurationID () const
std::string getTable ()
 ODJBH4Cycle ()
bool operator!= (const ODJBH4Cycle &m) const
bool operator== (const ODJBH4Cycle &m) const
void setId (int id)
void setJBH4ConfigurationID (int x)
 ~ODJBH4Cycle ()

Private Member Functions

void clear ()
void fetchData (ODJBH4Cycle *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_ID
int m_jbh4_config_id

Friends

class EcalCondDBInterface
class ODEcalCycle

Detailed Description

Definition at line 11 of file ODJBH4Cycle.h.


Constructor & Destructor Documentation

ODJBH4Cycle::ODJBH4Cycle ( )

Definition at line 9 of file ODJBH4Cycle.cc.

References NULL.

ODJBH4Cycle::~ODJBH4Cycle ( )

Definition at line 21 of file ODJBH4Cycle.cc.

{
}

Member Function Documentation

void ODJBH4Cycle::clear ( void  ) [private]

Definition at line 66 of file ODJBH4Cycle.cc.

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

Definition at line 131 of file ODJBH4Cycle.cc.

References query::result.

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

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

  try {

    m_readStmt->setSQL("SELECT  jbh4_configuration_id FROM ecal_jbh4_cycle "
                 "WHERE cycle_id = :1 ");

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

    rset->next();

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

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

Definition at line 71 of file ODJBH4Cycle.cc.

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

  this->checkConnection();

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

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

  return m_ID;
}
int ODJBH4Cycle::getId ( ) const [inline]

Definition at line 22 of file ODJBH4Cycle.h.

References m_ID.

{ return m_ID;} ;
int ODJBH4Cycle::getJBH4ConfigurationID ( ) const [inline]

Definition at line 26 of file ODJBH4Cycle.h.

References m_jbh4_config_id.

{return m_jbh4_config_id;}
std::string ODJBH4Cycle::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 19 of file ODJBH4Cycle.h.

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

Definition at line 158 of file ODJBH4Cycle.cc.

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 ODJBH4Cycle::operator!= ( const ODJBH4Cycle m) const [inline]

Definition at line 30 of file ODJBH4Cycle.h.

References m.

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

Definition at line 29 of file ODJBH4Cycle.h.

References m_ID.

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

Implements IODConfig.

Definition at line 26 of file ODJBH4Cycle.cc.

{
  this->checkConnection();

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

Definition at line 104 of file ODJBH4Cycle.cc.

{
   this->checkConnection();


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

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

Definition at line 21 of file ODJBH4Cycle.h.

References m_ID.

Referenced by ODEcalCycle::writeDB().

{m_ID=id;}
void ODJBH4Cycle::setJBH4ConfigurationID ( int  x) [inline]

Definition at line 25 of file ODJBH4Cycle.h.

References m_jbh4_config_id, and x.

Referenced by ODEcalCycle::writeDB().

void ODJBH4Cycle::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 41 of file ODJBH4Cycle.cc.

References getId().

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

  try {

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

    m_writeStmt->executeUpdate();


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

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

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 13 of file ODJBH4Cycle.h.

friend class ODEcalCycle [friend]

Definition at line 14 of file ODJBH4Cycle.h.


Member Data Documentation

int ODJBH4Cycle::m_ID [private]

Definition at line 34 of file ODJBH4Cycle.h.

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

Definition at line 35 of file ODJBH4Cycle.h.

Referenced by getJBH4ConfigurationID(), and setJBH4ConfigurationID().