CMS 3D CMS Logo

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

ODTTCFConfig Class Reference

#include <ODTTCFConfig.h>

Inheritance diagram for ODTTCFConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int getId () const
int getReg30 ()
int getRxBC0Delay ()
unsigned int getSize () const
std::string getTable ()
unsigned char * getTTCFClob () const
std::string getTTCFConfigurationFile () const
 ODTTCFConfig ()
void setId (int id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setReg30 (int x)
void setRxBC0Delay (int x)
void setSize (unsigned int id)
void setTTCFClob (unsigned char *x)
void setTTCFConfigurationFile (std::string x)
 ~ODTTCFConfig ()

Private Member Functions

void clear ()
void fetchData (ODTTCFConfig *result) throw (std::runtime_error)
int fetchID () throw (std::runtime_error)
int fetchNextId () throw (std::runtime_error)
void prepareWrite () throw (std::runtime_error)
void writeDB () throw (std::runtime_error)

Private Attributes

int m_ID
int m_reg_30
int m_rxbc0_delay
unsigned int m_size
unsigned char * m_ttcf_clob
std::string m_ttcf_file

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 15 of file ODTTCFConfig.h.


Constructor & Destructor Documentation

ODTTCFConfig::ODTTCFConfig ( )

Definition at line 12 of file ODTTCFConfig.cc.

References NULL.

ODTTCFConfig::~ODTTCFConfig ( )

Definition at line 30 of file ODTTCFConfig.cc.

{
}

Member Function Documentation

void ODTTCFConfig::clear ( void  ) [private]

Definition at line 25 of file ODTTCFConfig.cc.

                        {

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

Definition at line 139 of file ODTTCFConfig.cc.

References gather_cfg::cout, and query::result.

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

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

  try {

    m_readStmt->setSQL("SELECT *   "
                       "FROM ECAL_TTCF_CONFIGURATION  "
                       " where (ttcf_configuration_id = :1 or ttcf_tag= :2) " );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();

    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));
    result->setTTCFConfigurationFile(rset->getString(3));
    Clob clob = rset->getClob (4);
    cout << "Opening the clob in Read only mode" << endl;
    clob.open (OCCI_LOB_READONLY);
    int clobLength=clob.length ();
    cout << "Length of the clob is: " << clobLength << endl;
    m_size=clobLength;
    unsigned char* buffer = readClob (clob, m_size);
    clob.close ();
    result->setTTCFClob((unsigned char*) buffer );

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

Definition at line 180 of file ODTTCFConfig.cc.

{
  if (m_ID!=0) {
    return m_ID;
  }

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT ttcf_configuration_id FROM ecal_ttcf_configuration "
                 "WHERE  ttcf_tag=:ttcf_tag "
                 );

    stmt->setString(1, getConfigTag() );

    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("ODTTCFConfig::fetchID:  "+e.getMessage()));
  }

    return m_ID;
}
int ODTTCFConfig::fetchNextId ( ) throw (std::runtime_error) [private]

Definition at line 34 of file ODTTCFConfig.cc.

References gather_cfg::cout, and query::result.

                                                       {

  int result=0;
  try {
    this->checkConnection();
    std::cout<< "going to fetch new id for TTCF 1"<<endl;
    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_ttcf_config_sq.NextVal from dual");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    std::cout<< "id is : "<< result<<endl;

    m_conn->terminateStatement(m_readStmt);
    return result; 

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

}
int ODTTCFConfig::getId ( ) const [inline]

Definition at line 27 of file ODTTCFConfig.h.

References m_ID.

{ return m_ID; }
int ODTTCFConfig::getReg30 ( ) [inline]

Definition at line 38 of file ODTTCFConfig.h.

References m_reg_30.

{ return m_reg_30; } 
int ODTTCFConfig::getRxBC0Delay ( ) [inline]

Definition at line 36 of file ODTTCFConfig.h.

References m_rxbc0_delay.

{ return m_rxbc0_delay; } 
unsigned int ODTTCFConfig::getSize ( ) const [inline]

Definition at line 24 of file ODTTCFConfig.h.

References m_size.

{ return m_size; }
std::string ODTTCFConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 22 of file ODTTCFConfig.h.

{ return "ECAL_TTCF_CONFIGURATION"; }
unsigned char* ODTTCFConfig::getTTCFClob ( ) const [inline]

Definition at line 33 of file ODTTCFConfig.h.

References m_ttcf_clob.

{ return m_ttcf_clob; }
std::string ODTTCFConfig::getTTCFConfigurationFile ( ) const [inline]

Definition at line 30 of file ODTTCFConfig.h.

References m_ttcf_file.

{ return m_ttcf_file; }
void ODTTCFConfig::prepareWrite ( ) throw (std::runtime_error) [private, virtual]

Implements IODConfig.

Definition at line 60 of file ODTTCFConfig.cc.

References gather_cfg::cout.

{
  this->checkConnection();
  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_TTCF_CONFIGURATION (ttcf_configuration_id, ttcf_tag, " 
                        " rxbc0_delay, reg_30 , ttcf_configuration_file , ttcf_configuration ) "
                        "VALUES (:1, :2, :3 , :4, :5, :6)");
    m_writeStmt->setInt(1, next_id);
    m_writeStmt->setString(2, getConfigTag());

    m_writeStmt->setInt( 3, getRxBC0Delay() );
    m_writeStmt->setInt( 4, getReg30() );
    
    m_writeStmt->setString(5, getTTCFConfigurationFile());
    
    oracle::occi::Clob clob(m_conn);
    clob.setEmpty();
    m_writeStmt->setClob(6,clob);
    m_writeStmt->executeUpdate ();
    m_ID=next_id; 

    m_conn->terminateStatement(m_writeStmt);
    std::cout<<"inserted into CONFIGURATION with id="<<next_id<<std::endl;

    // now we read and update it 
    m_writeStmt = m_conn->createStatement(); 
    m_writeStmt->setSQL ("SELECT ttcf_configuration FROM ECAL_TTCF_CONFIGURATION WHERE"
                         " ttcf_configuration_id=:1 FOR UPDATE");

  std::cout<<"updating the clob 0"<<std::endl;


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

  std::cout<<"updating the clob 1 "<<std::endl;

}
void ODTTCFConfig::setId ( int  id) [inline]

Definition at line 26 of file ODTTCFConfig.h.

References m_ID.

{ m_ID = id; }
void ODTTCFConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)
void ODTTCFConfig::setReg30 ( int  x) [inline]

Definition at line 37 of file ODTTCFConfig.h.

References m_reg_30, and x.

{ m_reg_30 = x; } 
void ODTTCFConfig::setRxBC0Delay ( int  x) [inline]

Definition at line 35 of file ODTTCFConfig.h.

References m_rxbc0_delay, and x.

void ODTTCFConfig::setSize ( unsigned int  id) [inline]

Definition at line 23 of file ODTTCFConfig.h.

References m_size.

{ m_size = id; }
void ODTTCFConfig::setTTCFClob ( unsigned char *  x) [inline]

Definition at line 32 of file ODTTCFConfig.h.

References m_ttcf_clob, and x.

{ m_ttcf_clob = x; }
void ODTTCFConfig::setTTCFConfigurationFile ( std::string  x) [inline]

Definition at line 29 of file ODTTCFConfig.h.

References m_ttcf_file, and x.

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

Definition at line 104 of file ODTTCFConfig.cc.

References gather_cfg::cout.

{

  std::cout<<"updating the clob 2"<<std::endl;

  try {
    m_writeStmt->setInt(1, m_ID);
    ResultSet* rset = m_writeStmt->executeQuery();

    rset->next ();

    oracle::occi::Clob clob = rset->getClob (1);
    cout << "Opening the clob in read write mode" << endl;
    populateClob (clob, getTTCFConfigurationFile(), m_size);
    int clobLength=clob.length ();
    cout << "Length of the clob is: " << clobLength << endl;

    m_writeStmt->executeUpdate();
    m_writeStmt->closeResultSet (rset);

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


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 17 of file ODTTCFConfig.h.


Member Data Documentation

int ODTTCFConfig::m_ID [private]

Definition at line 58 of file ODTTCFConfig.h.

Referenced by getId(), and setId().

int ODTTCFConfig::m_reg_30 [private]

Definition at line 64 of file ODTTCFConfig.h.

Referenced by getReg30(), and setReg30().

Definition at line 63 of file ODTTCFConfig.h.

Referenced by getRxBC0Delay(), and setRxBC0Delay().

unsigned int ODTTCFConfig::m_size [private]

Definition at line 60 of file ODTTCFConfig.h.

Referenced by getSize(), and setSize().

unsigned char* ODTTCFConfig::m_ttcf_clob [private]

Definition at line 59 of file ODTTCFConfig.h.

Referenced by getTTCFClob(), and setTTCFClob().

std::string ODTTCFConfig::m_ttcf_file [private]

Definition at line 61 of file ODTTCFConfig.h.

Referenced by getTTCFConfigurationFile(), and setTTCFConfigurationFile().