CMS 3D CMS Logo

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

ODRunConfigSeqInfo Class Reference

#include <ODRunConfigSeqInfo.h>

Inheritance diagram for ODRunConfigSeqInfo:
IODConfig IDBObject

List of all members.

Public Member Functions

std::string getDescription () const
int getEcalConfigId () const
int getId () const
int getNumberOfCycles () const
RunSeqDef getRunSeqDef () const
int getSequenceId () const
int getSequenceNumber () const
std::string getTable ()
 ODRunConfigSeqInfo ()
bool operator!= (const ODRunConfigSeqInfo &r) const
bool operator== (const ODRunConfigSeqInfo &r) const
void setDescription (std::string x)
void setEcalConfigId (int x)
void setId (int id)
void setNumberOfCycles (int x)
void setRunSeqDef (const RunSeqDef runSeqDef)
void setSequenceId (int x)
void setSequenceNumber (int x)
 ~ODRunConfigSeqInfo ()

Private Member Functions

void clear ()
void fetchData (ODRunConfigSeqInfo *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchIDLast () 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_cycles
std::string m_description
int m_ecal_config_id
int m_ID
RunSeqDef m_run_seq
int m_seq_num
int m_sequence_id

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 15 of file ODRunConfigSeqInfo.h.


Constructor & Destructor Documentation

ODRunConfigSeqInfo::ODRunConfigSeqInfo ( )

Definition at line 12 of file ODRunConfigSeqInfo.cc.

References NULL.

ODRunConfigSeqInfo::~ODRunConfigSeqInfo ( )

Definition at line 28 of file ODRunConfigSeqInfo.cc.

{}

Member Function Documentation

void ODRunConfigSeqInfo::clear ( void  ) [private]

Definition at line 197 of file ODRunConfigSeqInfo.cc.

                              {
  //  m_ecal_config_id =0;
  //  m_seq_num =0;
  m_ID =0;
  m_cycles =0;
  m_run_seq = RunSeqDef();
  m_description="";
}
void ODRunConfigSeqInfo::fetchData ( ODRunConfigSeqInfo result) throw (std::runtime_error) [private]

Definition at line 207 of file ODRunConfigSeqInfo.cc.

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

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

  try {
    
    m_readStmt->setSQL("SELECT ecal_config_id, sequence_num, num_of_cycles, "
                       "sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
    
    m_readStmt->setInt(1, result->getId());
    ResultSet* rset = m_readStmt->executeQuery();
    
    rset->next();
    
    result->setEcalConfigId(       rset->getInt(1) );
    result->setSequenceNumber(        rset->getInt(2) );
    result->setNumberOfCycles(         rset->getInt(3) );
    int seq_def_id=rset->getInt(4);

    m_run_seq.setConnection(m_env, m_conn);
    m_run_seq.setByID(seq_def_id);
    result->setDescription(   rset->getString(5) );
    
    
  } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigSeqInfo::fetchData():  "+e.getMessage()));
  }
}
int ODRunConfigSeqInfo::fetchID ( ) throw (std::runtime_error) [private]

Definition at line 43 of file ODRunConfigSeqInfo.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 sequence_id from ECAL_sequence_DAT "
                 "WHERE ecal_config_id = :id1 " 
                 " and sequence_num = :id2  " );
    stmt->setInt(1, m_ecal_config_id);
    stmt->setInt(2, m_seq_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("ODRunConfigSeqInfo::fetchID:  "+e.getMessage()));
  }
  setByID(m_ID);
  return m_ID;
}
int ODRunConfigSeqInfo::fetchIDLast ( ) throw (std::runtime_error) [private]

Definition at line 81 of file ODRunConfigSeqInfo.cc.

References alignCSCRings::e.

{

  this->checkConnection();

  DateHandler dh(m_env, m_conn);

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT max(sequence_id) FROM ecal_sequence_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("ODRunConfigSeqInfo::fetchIDLast:  "+e.getMessage()));
  }

  setByID(m_ID);
  return m_ID;
}
std::string ODRunConfigSeqInfo::getDescription ( ) const [inline]

Definition at line 31 of file ODRunConfigSeqInfo.h.

References m_description.

{ return m_description;}
int ODRunConfigSeqInfo::getEcalConfigId ( ) const [inline]

Definition at line 33 of file ODRunConfigSeqInfo.h.

References m_ecal_config_id.

{ return m_ecal_config_id;}
int ODRunConfigSeqInfo::getId ( ) const [inline]

Definition at line 28 of file ODRunConfigSeqInfo.h.

References m_ID.

{ return m_ID; }
int ODRunConfigSeqInfo::getNumberOfCycles ( ) const [inline]

Definition at line 37 of file ODRunConfigSeqInfo.h.

References m_cycles.

{return m_cycles;}
RunSeqDef ODRunConfigSeqInfo::getRunSeqDef ( ) const

Definition at line 31 of file ODRunConfigSeqInfo.cc.

{  return m_run_seq;}
int ODRunConfigSeqInfo::getSequenceId ( ) const [inline]

Definition at line 36 of file ODRunConfigSeqInfo.h.

References m_ID.

Referenced by popcon::EcalSRPHandler::getNewObjects().

{ return m_ID;}
int ODRunConfigSeqInfo::getSequenceNumber ( ) const [inline]

Definition at line 39 of file ODRunConfigSeqInfo.h.

References m_seq_num.

{return m_seq_num;}
std::string ODRunConfigSeqInfo::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 22 of file ODRunConfigSeqInfo.h.

{ return "ECAL_SEQUENCE_DAT"; }
bool ODRunConfigSeqInfo::operator!= ( const ODRunConfigSeqInfo r) const [inline]

Definition at line 46 of file ODRunConfigSeqInfo.h.

References alignCSCRings::r.

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

Definition at line 45 of file ODRunConfigSeqInfo.h.

References m_ID.

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

Implements IODConfig.

Definition at line 143 of file ODRunConfigSeqInfo.cc.

References alignCSCRings::e.

{
  this->checkConnection();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_SEQUENCE_DAT ( ecal_config_id, "
                        "sequence_num, num_of_cycles, sequence_type_def_id, description ) "
                        "VALUES (:1, :2, :3 , :4, :5 )");
  } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigSeqInfo::prepareWrite():  "+e.getMessage()));
  }
}
void ODRunConfigSeqInfo::setByID ( int  id) throw (std::runtime_error) [private]

Definition at line 109 of file ODRunConfigSeqInfo.cc.

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

{
   this->checkConnection();

   DateHandler dh(m_env, m_conn);

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

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

     stmt->setSQL("SELECT ecal_config_id, sequence_num, num_of_cycles, sequence_type_def_id, description FROM ECAL_sequence_DAT WHERE sequence_id = :1 ");
     stmt->setInt(1, id);
     
     ResultSet* rset = stmt->executeQuery();
     if (rset->next()) {
       m_ecal_config_id= rset->getInt(1);
       m_seq_num=rset->getInt(2);
       m_cycles=rset->getInt(3);
       int seq_def_id=rset->getInt(4);
       m_description= rset->getString(5);
       m_ID = id;
       m_run_seq.setConnection(m_env, m_conn);
       m_run_seq.setByID(seq_def_id);
     } else {
       throw(std::runtime_error("ODRunConfigSeqInfo::setByID:  Given config_id is not in the database"));
     }
     m_conn->terminateStatement(stmt);
   } catch (SQLException &e) {
     throw(std::runtime_error("ODRunConfigSeqInfo::setByID:  "+e.getMessage()));
   }
}
void ODRunConfigSeqInfo::setDescription ( std::string  x) [inline]

Definition at line 30 of file ODRunConfigSeqInfo.h.

References m_description, and x.

void ODRunConfigSeqInfo::setEcalConfigId ( int  x) [inline]

Definition at line 32 of file ODRunConfigSeqInfo.h.

References m_ecal_config_id, and x.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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

Definition at line 27 of file ODRunConfigSeqInfo.h.

References m_ID.

{ m_ID = id; }
void ODRunConfigSeqInfo::setNumberOfCycles ( int  x) [inline]

Definition at line 34 of file ODRunConfigSeqInfo.h.

References m_cycles, and x.

{ m_cycles = x; }
void ODRunConfigSeqInfo::setRunSeqDef ( const RunSeqDef  runSeqDef)

Definition at line 32 of file ODRunConfigSeqInfo.cc.

{
  if (run_seq != m_run_seq) {
    m_run_seq = run_seq;
  }
}
void ODRunConfigSeqInfo::setSequenceId ( int  x) [inline]

Definition at line 35 of file ODRunConfigSeqInfo.h.

References m_ID, and x.

{ m_ID = x; }
void ODRunConfigSeqInfo::setSequenceNumber ( int  x) [inline]

Definition at line 38 of file ODRunConfigSeqInfo.h.

References m_seq_num, and x.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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

Definition at line 157 of file ODRunConfigSeqInfo.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 {

    // get the run mode



    m_run_seq.setConnection(m_env, m_conn);
    int seq_def_id = m_run_seq.writeDB();


    m_writeStmt->setInt(1, this->getEcalConfigId());
    m_writeStmt->setInt(2, this->getSequenceNumber());
    m_writeStmt->setInt(3, this->getNumberOfCycles());
    m_writeStmt->setInt(4,seq_def_id );
    m_writeStmt->setString(5,this->getDescription() );

    m_writeStmt->executeUpdate();

   } catch (SQLException &e) {
    throw(std::runtime_error("ODRunConfigSeqInfo::writeDB():  "+e.getMessage()));
  }
  if (!this->fetchID()) {
    throw(std::runtime_error("ODRunConfigSeqInfo::writeDB:  Failed to write"));
  }
  cout<< "ODRunConfigSeqInfo::writeDB>> done inserting ODRunConfigSeqInfo with id="<<m_ID<<endl;

}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 17 of file ODRunConfigSeqInfo.h.


Member Data Documentation

Definition at line 53 of file ODRunConfigSeqInfo.h.

Referenced by getNumberOfCycles(), and setNumberOfCycles().

std::string ODRunConfigSeqInfo::m_description [private]

Definition at line 55 of file ODRunConfigSeqInfo.h.

Referenced by getDescription(), and setDescription().

Definition at line 50 of file ODRunConfigSeqInfo.h.

Referenced by getEcalConfigId(), and setEcalConfigId().

int ODRunConfigSeqInfo::m_ID [private]

Definition at line 49 of file ODRunConfigSeqInfo.h.

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

Definition at line 54 of file ODRunConfigSeqInfo.h.

Definition at line 51 of file ODRunConfigSeqInfo.h.

Referenced by getSequenceNumber(), and setSequenceNumber().

Definition at line 52 of file ODRunConfigSeqInfo.h.