#include <ODTTCciConfig.h>
Public Member Functions | |
std::string | getConfigurationScript () const |
std::string | getConfigurationScriptParams () const |
int | getId () const |
unsigned int | getSize () const |
std::string | getTable () |
std::string | getTrgMode () const |
int | getTrgSleep () const |
unsigned char * | getTTCciClob () const |
std::string | getTTCciConfigurationFile () const |
ODTTCciConfig () | |
void | setConfigurationScript (std::string x) |
void | setConfigurationScriptParams (std::string x) |
void | setId (int id) |
void | setParameters (std::map< std::string, std::string > my_keys_map) |
void | setSize (unsigned int id) |
void | setTrgMode (std::string x) |
void | setTrgSleep (int id) |
void | setTTCciClob (unsigned char *x) |
void | setTTCciConfigurationFile (std::string x) |
~ODTTCciConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODTTCciConfig *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 | |
std::string | m_configuration_script |
std::string | m_configuration_script_params |
int | m_ID |
int | m_size |
std::string | m_trg_mode |
int | m_trg_sleep |
unsigned char * | m_ttcci_clob |
std::string | m_ttcci_file |
Friends | |
class | EcalCondDBInterface |
Definition at line 15 of file ODTTCciConfig.h.
ODTTCciConfig::ODTTCciConfig | ( | ) |
Definition at line 15 of file ODTTCciConfig.cc.
References NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_configuration_script=""; m_configuration_script_params=""; m_ID=0; clear(); m_size=0; }
ODTTCciConfig::~ODTTCciConfig | ( | ) |
Definition at line 39 of file ODTTCciConfig.cc.
{ }
void ODTTCciConfig::clear | ( | void | ) | [private] |
Definition at line 29 of file ODTTCciConfig.cc.
References gather_cfg::cout.
{ std::cout <<"entering clear" << std::endl; m_ttcci_file=""; m_configuration_script=""; m_configuration_script_params=""; m_trg_mode=""; m_trg_sleep=0; }
void ODTTCciConfig::fetchData | ( | ODTTCciConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 207 of file ODTTCciConfig.cc.
References gather_cfg::cout, i, and query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0 && (result->getConfigTag()=="") ){ throw(std::runtime_error("ODTTCciConfig::fetchData(): no Id defined for this ODTTCciConfig ")); } try { m_readStmt->setSQL("SELECT * " "FROM ECAL_TTCci_CONFIGURATION " " where ( ttcci_configuration_id = :1 or ttcci_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->setTTCciConfigurationFile(rset->getString(3)); result->setTrgMode(rset->getString(4)); result->setTrgSleep(rset->getInt(5)); result->setConfigurationScript(rset->getString(7)); result->setConfigurationScriptParams(rset->getString(8)); Clob clob = rset->getClob (6); 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 (); cout<< "the clob buffer is:"<<endl; for (int i = 0; i < clobLength; ++i) cout << (char) buffer[i]; cout << endl; result->setTTCciClob(buffer ); } catch (SQLException &e) { throw(std::runtime_error("ODTTCciConfig::fetchData(): "+e.getMessage())); } }
int ODTTCciConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 262 of file ODTTCciConfig.cc.
{ if (m_ID!=0) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT ttcci_configuration_id FROM ecal_ttcci_configuration " "WHERE ttcci_tag=:ttcci_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("ODTTCciConfig::fetchID: "+e.getMessage())); } return m_ID; }
int ODTTCciConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 43 of file ODTTCciConfig.cc.
References query::result.
{ int result=0; try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select ecal_ttcci_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("ODTTCciConfig::fetchNextId(): "+e.getMessage())); } }
std::string ODTTCciConfig::getConfigurationScript | ( | ) | const [inline] |
Definition at line 31 of file ODTTCciConfig.h.
References m_configuration_script.
{ return m_configuration_script; }
std::string ODTTCciConfig::getConfigurationScriptParams | ( | ) | const [inline] |
Definition at line 33 of file ODTTCciConfig.h.
References m_configuration_script_params.
{ return m_configuration_script_params; }
int ODTTCciConfig::getId | ( | ) | const [inline] |
unsigned int ODTTCciConfig::getSize | ( | ) | const [inline] |
std::string ODTTCciConfig::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 22 of file ODTTCciConfig.h.
{ return "ECAL_TTCci_CONFIGURATION"; }
std::string ODTTCciConfig::getTrgMode | ( | ) | const [inline] |
int ODTTCciConfig::getTrgSleep | ( | ) | const [inline] |
unsigned char* ODTTCciConfig::getTTCciClob | ( | ) | const [inline] |
std::string ODTTCciConfig::getTTCciConfigurationFile | ( | ) | const [inline] |
void ODTTCciConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 67 of file ODTTCciConfig.cc.
References gather_cfg::cout.
{ this->checkConnection(); int next_id=fetchNextId(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO ECAL_TTCci_CONFIGURATION (ttcci_configuration_id, ttcci_tag, " " TTCCI_configuration_file, TRG_MODE, TRG_SLEEP, Configuration, configuration_script, configuration_script_params ) " "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 )"); m_writeStmt->setInt(1, next_id); m_writeStmt->setString(2, getConfigTag()); m_writeStmt->setString(3, getTTCciConfigurationFile()); m_writeStmt->setString(4, getTrgMode()); m_writeStmt->setInt(5, getTrgSleep()); m_writeStmt->setString(7, getConfigurationScript()); m_writeStmt->setString(8, getConfigurationScriptParams()); // and now the clob 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<<"TTCci 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_TTCci_CONFIGURATION WHERE" " ttcci_configuration_id=:1 FOR UPDATE"); std::cout<<"updating the clob 0"<<std::endl; } catch (SQLException &e) { throw(std::runtime_error("ODTTCciConfig::prepareWrite(): "+e.getMessage())); } std::cout<<"updating the clob 1 "<<std::endl; }
void ODTTCciConfig::setConfigurationScript | ( | std::string | x | ) | [inline] |
Definition at line 30 of file ODTTCciConfig.h.
References m_configuration_script, and x.
{ m_configuration_script = x; }
void ODTTCciConfig::setConfigurationScriptParams | ( | std::string | x | ) | [inline] |
Definition at line 32 of file ODTTCciConfig.h.
References m_configuration_script_params, and x.
{ m_configuration_script_params = x; }
void ODTTCciConfig::setId | ( | int | id | ) | [inline] |
void ODTTCciConfig::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void ODTTCciConfig::setSize | ( | unsigned int | id | ) | [inline] |
void ODTTCciConfig::setTrgMode | ( | std::string | x | ) | [inline] |
void ODTTCciConfig::setTrgSleep | ( | int | id | ) | [inline] |
void ODTTCciConfig::setTTCciClob | ( | unsigned char * | x | ) | [inline] |
Definition at line 41 of file ODTTCciConfig.h.
References m_ttcci_clob, and x.
{ m_ttcci_clob = x; }
void ODTTCciConfig::setTTCciConfigurationFile | ( | std::string | x | ) | [inline] |
Definition at line 27 of file ODTTCciConfig.h.
References m_ttcci_file, and x.
{ m_ttcci_file = x; }
void ODTTCciConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 163 of file ODTTCciConfig.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(); while (rset->next ()) { oracle::occi::Clob clob = rset->getClob (1); cout << "Opening the clob in read write mode" << endl; cout << "Populating the clob" << endl; populateClob (clob, getTTCciConfigurationFile(), 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("ODTTCciConfig::writeDB(): "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODTTCciConfig::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 17 of file ODTTCciConfig.h.
std::string ODTTCciConfig::m_configuration_script [private] |
Definition at line 62 of file ODTTCciConfig.h.
Referenced by getConfigurationScript(), and setConfigurationScript().
std::string ODTTCciConfig::m_configuration_script_params [private] |
Definition at line 63 of file ODTTCciConfig.h.
Referenced by getConfigurationScriptParams(), and setConfigurationScriptParams().
int ODTTCciConfig::m_ID [private] |
Definition at line 59 of file ODTTCciConfig.h.
int ODTTCciConfig::m_size [private] |
Definition at line 66 of file ODTTCciConfig.h.
std::string ODTTCciConfig::m_trg_mode [private] |
Definition at line 64 of file ODTTCciConfig.h.
Referenced by getTrgMode(), and setTrgMode().
int ODTTCciConfig::m_trg_sleep [private] |
Definition at line 65 of file ODTTCciConfig.h.
Referenced by getTrgSleep(), and setTrgSleep().
unsigned char* ODTTCciConfig::m_ttcci_clob [private] |
Definition at line 60 of file ODTTCciConfig.h.
Referenced by getTTCciClob(), and setTTCciClob().
std::string ODTTCciConfig::m_ttcci_file [private] |
Definition at line 61 of file ODTTCciConfig.h.
Referenced by getTTCciConfigurationFile(), and setTTCciConfigurationFile().