CMS 3D CMS Logo

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

ODTCCConfig Class Reference

#include <ODTCCConfig.h>

Inheritance diagram for ODTCCConfig:
IODConfig IDBObject

List of all members.

Public Member Functions

int getId () const
unsigned char * getLUTClob () const
std::string getLUTConfigurationFile () const
int getNTestPatternsToLoad () const
unsigned char * getSLBClob () const
std::string getSLBConfigurationFile () const
std::string getTable ()
unsigned char * getTCCClob () const
std::string getTCCConfigurationFile () const
std::string getTestPatternFileUrl () const
 ODTCCConfig ()
void setId (int id)
void setLUTClob (unsigned char *x)
void setLUTConfigurationFile (std::string x)
void setNTestPatternsToLoad (int id)
void setParameters (std::map< std::string, std::string > my_keys_map)
void setSLBClob (unsigned char *x)
void setSLBConfigurationFile (std::string x)
void setTCCClob (unsigned char *x)
void setTCCConfigurationFile (std::string x)
void setTestPatternFileUrl (std::string x)
 ~ODTCCConfig ()

Private Member Functions

void clear ()
void fetchData (ODTCCConfig *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
unsigned char * m_lut_clob
std::string m_lut_file
int m_ntest
unsigned int m_size
unsigned char * m_slb_clob
std::string m_slb_file
unsigned char * m_tcc_clob
std::string m_tcc_file
std::string m_test_url

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 15 of file ODTCCConfig.h.


Constructor & Destructor Documentation

ODTCCConfig::ODTCCConfig ( )

Definition at line 11 of file ODTCCConfig.cc.

References hitfit::clear(), and NULL.

ODTCCConfig::~ODTCCConfig ( )

Definition at line 34 of file ODTCCConfig.cc.

{
}

Member Function Documentation

void ODTCCConfig::clear ( void  ) [private]

Definition at line 24 of file ODTCCConfig.cc.

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

Definition at line 180 of file ODTCCConfig.cc.

References gather_cfg::cout, alignCSCRings::e, i, and query::result.

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

  try {

    m_readStmt->setSQL("SELECT * "
                       "FROM ECAL_TCC_CONFIGURATION d "
                       " where (tcc_configuration_id = :1 or tcc_tag=:2 )" );
    m_readStmt->setInt(1, result->getId());
    m_readStmt->setString(2, result->getConfigTag());
    ResultSet* rset = m_readStmt->executeQuery();

    rset->next();
    // the first is the id 
    result->setId(rset->getInt(1));
    result->setConfigTag(rset->getString(2));

    result->setTCCConfigurationFile(rset->getString(3));
    result->setLUTConfigurationFile(rset->getString(4));
    result->setSLBConfigurationFile(rset->getString(5));
    result->setTestPatternFileUrl(rset->getString(6));
    result->setNTestPatternsToLoad(rset->getInt(7));
    //

    Clob clob1 = rset->getClob (8);
    cout << "Opening the clob in Read only mode" << endl;
    clob1.open (OCCI_LOB_READONLY);
    int clobLength=clob1.length ();
    cout << "Length of the clob1 is: " << clobLength << endl;
    unsigned char* buffer = readClob (clob1, clobLength);
    clob1.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer[i];
    cout << endl;
    result->setTCCClob(buffer );

    Clob clob2 = rset->getClob (9);
    cout << "Opening the clob in Read only mode" << endl;
    clob2.open (OCCI_LOB_READONLY);
    clobLength=clob2.length ();
    cout << "Length of the clob2 is: " << clobLength << endl;
    unsigned char* buffer2 = readClob (clob2, clobLength);
    clob2.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer2[i];
    cout << endl;
    result->setLUTClob(buffer2 );

    Clob clob3 = rset->getClob (10);
    cout << "Opening the clob in Read only mode" << endl;
    clob3.open (OCCI_LOB_READONLY);
    clobLength=clob3.length ();
    cout << "Length of the clob3 is: " << clobLength << endl;
    unsigned char* buffer3 = readClob (clob3, clobLength);
    clob3.close ();
    cout<< "the clob buffer is:"<<endl;  
    for (int i = 0; i < clobLength; ++i)
      cout << (char) buffer3[i];
    cout << endl;
    result->setSLBClob(buffer3 );

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

Definition at line 256 of file ODTCCConfig.cc.

References alignCSCRings::e.

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

  this->checkConnection();

  try {
    Statement* stmt = m_conn->createStatement();
    stmt->setSQL("SELECT tcc_configuration_id FROM ecal_tcc_configuration "
                 "WHERE  tcc_tag=:tcc_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("ODTCCConfig::fetchID:  "+e.getMessage()));
  }

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

Definition at line 38 of file ODTCCConfig.cc.

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

                                                      {

  int result=0;
  try {
    this->checkConnection();

    m_readStmt = m_conn->createStatement(); 
    m_readStmt->setSQL("select ecal_tcc_config_sq.NextVal from dual");
    ResultSet* rset = m_readStmt->executeQuery();
    while (rset->next ()){
      result= rset->getInt(1);
    }
    m_conn->terminateStatement(m_readStmt);
    return result; 

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

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

Definition at line 25 of file ODTCCConfig.h.

References m_ID.

{ return m_ID; }
unsigned char* ODTCCConfig::getLUTClob ( ) const [inline]

Definition at line 42 of file ODTCCConfig.h.

References m_lut_clob.

{ return m_lut_clob; }
std::string ODTCCConfig::getLUTConfigurationFile ( ) const [inline]

Definition at line 30 of file ODTCCConfig.h.

References m_lut_file.

{ return m_lut_file; }
int ODTCCConfig::getNTestPatternsToLoad ( ) const [inline]

Definition at line 36 of file ODTCCConfig.h.

References m_ntest.

{ return m_ntest; }
unsigned char* ODTCCConfig::getSLBClob ( ) const [inline]

Definition at line 45 of file ODTCCConfig.h.

References m_slb_clob.

{ return m_slb_clob; }
std::string ODTCCConfig::getSLBConfigurationFile ( ) const [inline]

Definition at line 32 of file ODTCCConfig.h.

References m_slb_file.

{ return m_slb_file; }
std::string ODTCCConfig::getTable ( ) [inline, virtual]

Implements IODConfig.

Definition at line 22 of file ODTCCConfig.h.

{ return "ECAL_TCC_CONFIGURATION"; }
unsigned char* ODTCCConfig::getTCCClob ( ) const [inline]

Definition at line 39 of file ODTCCConfig.h.

References m_tcc_clob.

{ return m_tcc_clob; }
std::string ODTCCConfig::getTCCConfigurationFile ( ) const [inline]

Definition at line 28 of file ODTCCConfig.h.

References m_tcc_file.

{ return m_tcc_file; }
std::string ODTCCConfig::getTestPatternFileUrl ( ) const [inline]

Definition at line 34 of file ODTCCConfig.h.

References m_test_url.

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

Implements IODConfig.

Definition at line 81 of file ODTCCConfig.cc.

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

{
  this->checkConnection();

  int next_id=fetchNextId();

  try {
    m_writeStmt = m_conn->createStatement();
    m_writeStmt->setSQL("INSERT INTO ECAL_TCC_CONFIGURATION (tcc_configuration_id, tcc_tag, "
                        "Configuration_file, LUT_CONFIGURATION_FILE, SLB_CONFIGURATION_FILE, "
                        "TESTPATTERNFILE_URL , N_TESTPATTERNS_TO_LOAD, "
                        "tcc_configuration, lut_configuration, slb_configuration ) "
                        "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10)");
    m_writeStmt->setInt(1, next_id);
    m_writeStmt->setString(2, getConfigTag());
    m_writeStmt->setString(3, getTCCConfigurationFile());
    m_writeStmt->setString(4, getLUTConfigurationFile());
    m_writeStmt->setString(5, getSLBConfigurationFile());
    m_writeStmt->setString(6, getTestPatternFileUrl());
    m_writeStmt->setInt(7, getNTestPatternsToLoad());
    // and now the clobs
    oracle::occi::Clob clob1(m_conn);
    clob1.setEmpty();
    m_writeStmt->setClob(8,clob1);

    oracle::occi::Clob clob2(m_conn);
    clob2.setEmpty();
    m_writeStmt->setClob(9,clob2);

    oracle::occi::Clob clob3(m_conn);
    clob3.setEmpty();
    m_writeStmt->setClob(10,clob3);

    m_writeStmt->executeUpdate ();
    m_ID=next_id; 

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

    // now we read and update it 
    m_writeStmt = m_conn->createStatement(); 
    m_writeStmt->setSQL ("SELECT tcc_configuration, lut_configuration, slb_configuration FROM ECAL_TCC_CONFIGURATION WHERE"
                         " tcc_configuration_id=:1 FOR UPDATE");

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

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

  std::cout<<"updating the clob 1 "<<std::endl;
  
}
void ODTCCConfig::setId ( int  id) [inline]

Definition at line 24 of file ODTCCConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_ID.

{ m_ID = id; }
void ODTCCConfig::setLUTClob ( unsigned char *  x) [inline]

Definition at line 41 of file ODTCCConfig.h.

References m_lut_clob, and x.

{ m_lut_clob = x; }
void ODTCCConfig::setLUTConfigurationFile ( std::string  x) [inline]

Definition at line 29 of file ODTCCConfig.h.

References m_lut_file, and x.

{ m_lut_file = x; }
void ODTCCConfig::setNTestPatternsToLoad ( int  id) [inline]

Definition at line 35 of file ODTCCConfig.h.

References errorMatrix2Lands_multiChannel::id, and m_ntest.

{ m_ntest = id; }
void ODTCCConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)
void ODTCCConfig::setSLBClob ( unsigned char *  x) [inline]

Definition at line 44 of file ODTCCConfig.h.

References m_slb_clob, and x.

{ m_slb_clob = x; }
void ODTCCConfig::setSLBConfigurationFile ( std::string  x) [inline]

Definition at line 31 of file ODTCCConfig.h.

References m_slb_file, and x.

{ m_slb_file = x; }
void ODTCCConfig::setTCCClob ( unsigned char *  x) [inline]

Definition at line 38 of file ODTCCConfig.h.

References m_tcc_clob, and x.

{ m_tcc_clob = x; }
void ODTCCConfig::setTCCConfigurationFile ( std::string  x) [inline]

Definition at line 27 of file ODTCCConfig.h.

References m_tcc_file, and x.

{ m_tcc_file = x; }
void ODTCCConfig::setTestPatternFileUrl ( std::string  x) [inline]

Definition at line 33 of file ODTCCConfig.h.

References m_test_url, and x.

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

Definition at line 137 of file ODTCCConfig.cc.

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

{

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

  try {

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

    while (rset->next ())
      {
        oracle::occi::Clob clob1 = rset->getClob (1);
        oracle::occi::Clob clob2 = rset->getClob (2);
        oracle::occi::Clob clob3 = rset->getClob (3);
        cout << "Opening the clob in read write mode" << endl;
        cout << "Populating the clobs" << endl;
        populateClob (clob1, getTCCConfigurationFile(), m_size);
        populateClob (clob2, getLUTConfigurationFile(), m_size);
        populateClob (clob3, getSLBConfigurationFile(), m_size);
       
      }

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

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


}

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from IDBObject.

Definition at line 17 of file ODTCCConfig.h.


Member Data Documentation

int ODTCCConfig::m_ID [private]

Definition at line 61 of file ODTCCConfig.h.

Referenced by getId(), and setId().

unsigned char* ODTCCConfig::m_lut_clob [private]

Definition at line 63 of file ODTCCConfig.h.

Referenced by getLUTClob(), and setLUTClob().

std::string ODTCCConfig::m_lut_file [private]

Definition at line 66 of file ODTCCConfig.h.

Referenced by getLUTConfigurationFile(), and setLUTConfigurationFile().

int ODTCCConfig::m_ntest [private]

Definition at line 69 of file ODTCCConfig.h.

Referenced by getNTestPatternsToLoad(), and setNTestPatternsToLoad().

unsigned int ODTCCConfig::m_size [private]

Definition at line 70 of file ODTCCConfig.h.

unsigned char* ODTCCConfig::m_slb_clob [private]

Definition at line 64 of file ODTCCConfig.h.

Referenced by getSLBClob(), and setSLBClob().

std::string ODTCCConfig::m_slb_file [private]

Definition at line 67 of file ODTCCConfig.h.

Referenced by getSLBConfigurationFile(), and setSLBConfigurationFile().

unsigned char* ODTCCConfig::m_tcc_clob [private]

Definition at line 62 of file ODTCCConfig.h.

Referenced by getTCCClob(), and setTCCClob().

std::string ODTCCConfig::m_tcc_file [private]

Definition at line 65 of file ODTCCConfig.h.

Referenced by getTCCConfigurationFile(), and setTCCConfigurationFile().

std::string ODTCCConfig::m_test_url [private]

Definition at line 68 of file ODTCCConfig.h.

Referenced by getTestPatternFileUrl(), and setTestPatternFileUrl().