CMS 3D CMS Logo

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

ODRunConfigCycleInfo Class Reference

#include <ODRunConfigCycleInfo.h>

Inheritance diagram for ODRunConfigCycleInfo:
IODConfig IDBObject

List of all members.

Public Member Functions

int getCycleNumber () const
std::string getDescription () const
int getId () const
int getSequenceID () const
std::string getTable ()
std::string getTag () const
 ODRunConfigCycleInfo ()
bool operator!= (const ODRunConfigCycleInfo &r) const
bool operator== (const ODRunConfigCycleInfo &r) const
void setCycleNumber (int n)
void setDescription (std::string x)
void setId (int id)
void setSequenceID (int x)
void setTag (std::string x)
 ~ODRunConfigCycleInfo ()

Private Member Functions

void clear ()
void fetchData (ODRunConfigCycleInfo *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchIDLast () 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_cycle_num
std::string m_description
int m_ID
int m_sequence_id
std::string m_tag

Friends

class EcalCondDBInterface
class ODEcalCycle

Detailed Description

Definition at line 14 of file ODRunConfigCycleInfo.h.


Constructor & Destructor Documentation

ODRunConfigCycleInfo::ODRunConfigCycleInfo ( )

Definition at line 12 of file ODRunConfigCycleInfo.cc.

References NULL.

ODRunConfigCycleInfo::~ODRunConfigCycleInfo ( )

Definition at line 29 of file ODRunConfigCycleInfo.cc.

{}

Member Function Documentation

void ODRunConfigCycleInfo::clear ( void  ) [private]

Definition at line 32 of file ODRunConfigCycleInfo.cc.

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

Definition at line 191 of file ODRunConfigCycleInfo.cc.

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

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

  try {
    m_readStmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");

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

    rset->next();

    result->setSequenceID(       rset->getInt(1) );
    result->setCycleNumber(      rset->getInt(2) );
    result->setTag(              rset->getString(3) );
    result->setDescription(      rset->getString(4) );
 
  } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigCycleInfo::fetchData():  "+e.getMessage()));
  }
}
int ODRunConfigCycleInfo::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 92 of file ODRunConfigCycleInfo.cc.

References alignCSCRings::e.

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

  this->checkConnection();


  DateHandler dh(m_env, m_conn);

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT cycle_id from ECAL_cycle_DAT "
                 "WHERE sequence_id = :id1 " 
                 " and cycle_num = :id2  " );
    stmt->setInt(1, m_sequence_id);
    stmt->setInt(2, m_cycle_num);

    ResultSet* rset = stmt->executeQuery();

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

  return m_ID;
}
int ODRunConfigCycleInfo::fetchIDLast ( ) throw (std::runtime_error) [private]

Definition at line 131 of file ODRunConfigCycleInfo.cc.

References alignCSCRings::e.

{

  this->checkConnection();

  DateHandler dh(m_env, m_conn);

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT max(cycle_id) FROM ecal_cycle_dat "    );
    ResultSet* rset = stmt->executeQuery();

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

  setByID(m_ID);
  return m_ID;
}
int ODRunConfigCycleInfo::getCycleNumber ( ) const [inline]

Definition at line 40 of file ODRunConfigCycleInfo.h.

References m_cycle_num.

{return m_cycle_num;  }
std::string ODRunConfigCycleInfo::getDescription ( ) const [inline]

Definition at line 31 of file ODRunConfigCycleInfo.h.

References m_description.

{  return m_description;}
int ODRunConfigCycleInfo::getId ( ) const [inline]

Definition at line 26 of file ODRunConfigCycleInfo.h.

References m_ID.

Referenced by ODEcalCycle::writeDB().

{ return m_ID; }
int ODRunConfigCycleInfo::getSequenceID ( ) const [inline]

Definition at line 37 of file ODRunConfigCycleInfo.h.

References m_sequence_id.

{  return m_sequence_id;}
std::string ODRunConfigCycleInfo::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 22 of file ODRunConfigCycleInfo.h.

{ return "ECAL_CYCLE_DAT"; }
std::string ODRunConfigCycleInfo::getTag ( void  ) const [inline]

Definition at line 34 of file ODRunConfigCycleInfo.h.

References m_tag.

{  return m_tag;}
void ODRunConfigCycleInfo::insertConfig ( ) throw (std::runtime_error) [private]

Definition at line 218 of file ODRunConfigCycleInfo.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 ODRunConfigCycleInfo::operator!= ( const ODRunConfigCycleInfo r) const [inline]

Definition at line 47 of file ODRunConfigCycleInfo.h.

References alignCSCRings::r.

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

Definition at line 46 of file ODRunConfigCycleInfo.h.

References m_ID.

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

Implements IODConfig.

Definition at line 40 of file ODRunConfigCycleInfo.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_CYCLE_DAT ( sequence_id , cycle_num, tag, description ) "
     "VALUES (:1, :2, :3 , :4 )");

  } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigCycleInfo::prepareWrite():  "+e.getMessage()));
  }
}
void ODRunConfigCycleInfo::setByID ( int  id) throw (std::runtime_error) [private]

Definition at line 159 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout, and alignCSCRings::e.

{
   this->checkConnection();

   DateHandler dh(m_env, m_conn);

   cout<< "ODRunConfigCycleInfo::setByID called for id "<<id<<endl;

   try {
     Statement* stmt = m_conn->createStatement();

     stmt->setSQL("SELECT sequence_id , cycle_num , tag , description FROM ECAL_cycle_DAT WHERE cycle_id = :1 ");
     stmt->setInt(1, id);
     
     ResultSet* rset = stmt->executeQuery();
     if (rset->next()) {
       m_sequence_id=rset->getInt(1);
       m_cycle_num=rset->getInt(2);
       m_tag = rset->getString(3);
       m_description= rset->getString(4);
       m_ID = id;
     } else {
       throw(std::runtime_error("ODRunConfigCycleInfo::setByID:  Given cycle_id is not in the database"));
     }
     m_conn->terminateStatement(stmt);
   } catch (SQLException &e) {
     throw(std::runtime_error("ODRunConfigCycleInfo::setByID:  "+e.getMessage()));
   }
}
void ODRunConfigCycleInfo::setCycleNumber ( int  n) [inline]

Definition at line 39 of file ODRunConfigCycleInfo.h.

References m_cycle_num, and n.

Referenced by ODEcalCycle::writeDB().

{ m_cycle_num = n;  }
void ODRunConfigCycleInfo::setDescription ( std::string  x) [inline]

Definition at line 30 of file ODRunConfigCycleInfo.h.

References m_description, and x.

Referenced by ODEcalCycle::writeDB().

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

Definition at line 25 of file ODRunConfigCycleInfo.h.

References m_ID.

{ m_ID = id; }
void ODRunConfigCycleInfo::setSequenceID ( int  x) [inline]

Definition at line 36 of file ODRunConfigCycleInfo.h.

References m_sequence_id, and x.

Referenced by ODEcalCycle::writeDB().

void ODRunConfigCycleInfo::setTag ( std::string  x) [inline]

Definition at line 33 of file ODRunConfigCycleInfo.h.

References m_tag, and x.

Referenced by ODEcalCycle::writeDB().

{ m_tag = x;}
void ODRunConfigCycleInfo::writeDB ( ) throw (std::runtime_error) [private]

Definition at line 56 of file ODRunConfigCycleInfo.cc.

References gather_cfg::cout, and alignCSCRings::e.

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

  // Validate the data, use infinity-till convention
  DateHandler dh(m_env, m_conn);

  try {

    m_writeStmt->setInt(1, this->getSequenceID());
    m_writeStmt->setInt(2, this->getCycleNumber());
    m_writeStmt->setString(3, this->getTag());
    m_writeStmt->setString(4, this->getDescription());
    m_writeStmt->executeUpdate();



  } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigCycleInfo::writeDB:  "+e.getMessage()));
  }
  // Now get the ID
  if (!this->fetchID()) {
    throw(std::runtime_error("ODRunConfigCycleInfo::writeDB:  Failed to write"));
  }

  cout<< "ODRunConfigCycleInfo::writeDB>> done inserting ODRunConfigCycleInfo with id="<<m_ID<<endl;

}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 16 of file ODRunConfigCycleInfo.h.

friend class ODEcalCycle [friend]

Definition at line 17 of file ODRunConfigCycleInfo.h.


Member Data Documentation

Definition at line 53 of file ODRunConfigCycleInfo.h.

Referenced by getCycleNumber(), and setCycleNumber().

std::string ODRunConfigCycleInfo::m_description [private]

Definition at line 55 of file ODRunConfigCycleInfo.h.

Referenced by getDescription(), and setDescription().

Definition at line 51 of file ODRunConfigCycleInfo.h.

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

Definition at line 52 of file ODRunConfigCycleInfo.h.

Referenced by getSequenceID(), and setSequenceID().

std::string ODRunConfigCycleInfo::m_tag [private]

Definition at line 54 of file ODRunConfigCycleInfo.h.

Referenced by getTag(), and setTag().