#include <ODTTCFConfig.h>
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 |
Definition at line 15 of file ODTTCFConfig.h.
ODTTCFConfig::ODTTCFConfig | ( | ) |
Definition at line 12 of file ODTTCFConfig.cc.
References hitfit::clear(), and NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_ID=0; clear(); m_size=0; }
ODTTCFConfig::~ODTTCFConfig | ( | ) |
Definition at line 30 of file ODTTCFConfig.cc.
{ }
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, alignCSCRings::e, 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.
References alignCSCRings::e.
{ 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, alignCSCRings::e, 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] |
int ODTTCFConfig::getReg30 | ( | ) | [inline] |
int ODTTCFConfig::getRxBC0Delay | ( | ) | [inline] |
unsigned int ODTTCFConfig::getSize | ( | ) | const [inline] |
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] |
std::string ODTTCFConfig::getTTCFConfigurationFile | ( | ) | const [inline] |
void ODTTCFConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 60 of file ODTTCFConfig.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_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 errorMatrix2Lands_multiChannel::id, and m_ID.
void ODTTCFConfig::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void ODTTCFConfig::setReg30 | ( | int | x | ) | [inline] |
void ODTTCFConfig::setRxBC0Delay | ( | int | x | ) | [inline] |
Definition at line 35 of file ODTTCFConfig.h.
References m_rxbc0_delay, and x.
{ m_rxbc0_delay = x; }
void ODTTCFConfig::setSize | ( | unsigned int | id | ) | [inline] |
Definition at line 23 of file ODTTCFConfig.h.
References errorMatrix2Lands_multiChannel::id, and m_size.
void ODTTCFConfig::setTTCFClob | ( | unsigned char * | x | ) | [inline] |
void ODTTCFConfig::setTTCFConfigurationFile | ( | std::string | x | ) | [inline] |
void ODTTCFConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 104 of file ODTTCFConfig.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(); 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")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 17 of file ODTTCFConfig.h.
int ODTTCFConfig::m_ID [private] |
Definition at line 58 of file ODTTCFConfig.h.
int ODTTCFConfig::m_reg_30 [private] |
Definition at line 64 of file ODTTCFConfig.h.
Referenced by getReg30(), and setReg30().
int ODTTCFConfig::m_rxbc0_delay [private] |
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.
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().