#include <ODLTCConfig.h>
Public Member Functions | |
int | getId () const |
unsigned char * | getLTCClob () const |
std::string | getLTCConfigurationFile () const |
unsigned int | getSize () const |
std::string | getTable () |
ODLTCConfig () | |
void | setId (int id) |
void | setLTCClob (unsigned char *x) |
void | setLTCConfigurationFile (std::string x) |
void | setParameters (std::map< std::string, std::string > my_keys_map) |
void | setSize (unsigned int id) |
~ODLTCConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODLTCConfig *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_ltc_clob |
std::string | m_ltc_file |
int | m_size |
Friends | |
class | EcalCondDBInterface |
Definition at line 15 of file ODLTCConfig.h.
ODLTCConfig::ODLTCConfig | ( | ) |
Definition at line 13 of file ODLTCConfig.cc.
References hitfit::clear(), and NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_size=0; m_ID=0; clear(); }
ODLTCConfig::~ODLTCConfig | ( | ) |
Definition at line 29 of file ODLTCConfig.cc.
{
// delete [] m_ltc_clob;
}
void ODLTCConfig::clear | ( | void | ) | [private] |
Definition at line 190 of file ODLTCConfig.cc.
{ // strcpy((char *)m_ltc_clob, ""); m_ltc_file=""; }
void ODLTCConfig::fetchData | ( | ODLTCConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 199 of file ODLTCConfig.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("ODLTCConfig::fetchData(): no Id defined for this ODLTCConfig ")); } try { m_readStmt->setSQL("SELECT * " "FROM ECAL_LTC_CONFIGURATION " " where (ltc_configuration_id = :1 or LTC_tag=:2 )" ); m_readStmt->setInt(1, result->getId()); m_readStmt->setString(2, result->getConfigTag()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); // 1 is the id and 2 is the config tag result->setId(rset->getInt(1)); result->setConfigTag(rset->getString(2)); result->setLTCConfigurationFile(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, clobLength); clob.close (); cout<< "the clob buffer is:"<<endl; for (int i = 0; i < clobLength; ++i) cout << (char) buffer[i]; cout << endl; result->setLTCClob(buffer ); } catch (SQLException &e) { throw(std::runtime_error("ODLTCConfig::fetchData(): "+e.getMessage())); } }
int ODLTCConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 248 of file ODLTCConfig.cc.
References alignCSCRings::e.
{ if (m_ID!=0) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT ltc_configuration_id FROM ecal_ltc_configuration " "WHERE ltc_tag=:ltc_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("ODLTCConfig::fetchID: "+e.getMessage())); } return m_ID; }
int ODLTCConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 34 of file ODLTCConfig.cc.
References alignCSCRings::e, and query::result.
{ int result=0; try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select ecal_ltc_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("ODLTCConfig::fetchNextId(): "+e.getMessage())); } }
int ODLTCConfig::getId | ( | ) | const [inline] |
unsigned char* ODLTCConfig::getLTCClob | ( | ) | const [inline] |
std::string ODLTCConfig::getLTCConfigurationFile | ( | ) | const [inline] |
unsigned int ODLTCConfig::getSize | ( | ) | const [inline] |
std::string ODLTCConfig::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 22 of file ODLTCConfig.h.
{ return "ECAL_LTC_CONFIGURATION"; }
void ODLTCConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 58 of file ODLTCConfig.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_LTC_CONFIGURATION (ltc_configuration_id, ltc_tag, " " LTC_CONFIGURATION_file, " " Configuration ) " "VALUES (:1, :2, :3, :4 )"); m_writeStmt->setInt(1, next_id); m_writeStmt->setString(2, this->getConfigTag()); m_writeStmt->setString(3, getLTCConfigurationFile()); // and now the clob oracle::occi::Clob clob(m_conn); clob.setEmpty(); m_writeStmt->setClob(4,clob); m_writeStmt->executeUpdate (); m_ID=next_id; m_conn->terminateStatement(m_writeStmt); std::cout<<"LTC Clob inserted into CONFIGURATION with id="<<next_id<<std::endl; // now we read and update it m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL ("SELECT Configuration FROM ECAL_LTC_CONFIGURATION WHERE" " ltc_configuration_id=:1 FOR UPDATE"); std::cout<<"updating the clob 0"<<std::endl; } catch (SQLException &e) { throw(std::runtime_error("ODLTCConfig::prepareWrite(): "+e.getMessage())); } std::cout<<"updating the clob 1 "<<std::endl; }
void ODLTCConfig::setId | ( | int | id | ) | [inline] |
Definition at line 24 of file ODLTCConfig.h.
References errorMatrix2Lands_multiChannel::id, and m_ID.
void ODLTCConfig::setLTCClob | ( | unsigned char * | x | ) | [inline] |
void ODLTCConfig::setLTCConfigurationFile | ( | std::string | x | ) | [inline] |
void ODLTCConfig::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void ODLTCConfig::setSize | ( | unsigned int | id | ) | [inline] |
Definition at line 27 of file ODLTCConfig.h.
References errorMatrix2Lands_multiChannel::id, and m_size.
void ODLTCConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 148 of file ODLTCConfig.cc.
References gather_cfg::cout, and alignCSCRings::e.
{ std::cout<<"updating the clob "<<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; std::cout << "Populating the clob" << endl; populateClob (clob, getLTCConfigurationFile(), m_size); int clobLength=clob.length (); cout << "Length of the clob is: " << clobLength << endl; // clob.close (); m_writeStmt->executeUpdate(); m_writeStmt->closeResultSet (rset); } catch (SQLException &e) { throw(std::runtime_error("ODLTCConfig::writeDB(): "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODLTCConfig::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 17 of file ODLTCConfig.h.
int ODLTCConfig::m_ID [private] |
Definition at line 49 of file ODLTCConfig.h.
unsigned char* ODLTCConfig::m_ltc_clob [private] |
Definition at line 50 of file ODLTCConfig.h.
Referenced by getLTCClob(), and setLTCClob().
std::string ODLTCConfig::m_ltc_file [private] |
Definition at line 51 of file ODLTCConfig.h.
Referenced by getLTCConfigurationFile(), and setLTCConfigurationFile().
int ODLTCConfig::m_size [private] |
Definition at line 52 of file ODLTCConfig.h.