#include <OnlineDB/EcalCondDB/interface/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< string, 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 14 of file ODTTCciConfig.cc.
References clear(), IODConfig::m_config_tag, m_configuration_script, m_configuration_script_params, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, m_size, IODConfig::m_writeStmt, and NULL.
00015 { 00016 m_env = NULL; 00017 m_conn = NULL; 00018 m_writeStmt = NULL; 00019 m_readStmt = NULL; 00020 m_config_tag=""; 00021 m_configuration_script=""; 00022 m_configuration_script_params=""; 00023 m_ID=0; 00024 clear(); 00025 m_size=0; 00026 }
ODTTCciConfig::~ODTTCciConfig | ( | ) |
Definition at line 28 of file ODTTCciConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), m_configuration_script, m_configuration_script_params, m_trg_mode, m_trg_sleep, and m_ttcci_file.
Referenced by ODTTCciConfig().
00028 { 00029 std::cout <<"entering clear" << std::endl; 00030 m_ttcci_file=""; 00031 m_configuration_script=""; 00032 m_configuration_script_params=""; 00033 m_trg_mode=""; 00034 m_trg_sleep=0; 00035 00036 }
void ODTTCciConfig::fetchData | ( | ODTTCciConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 206 of file ODTTCciConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), i, IODConfig::m_readStmt, m_size, IODConfig::readClob(), and HLT_VtxMuL3::result.
00208 { 00209 this->checkConnection(); 00210 result->clear(); 00211 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00212 throw(runtime_error("ODTTCciConfig::fetchData(): no Id defined for this ODTTCciConfig ")); 00213 } 00214 00215 try { 00216 00217 m_readStmt->setSQL("SELECT * " 00218 "FROM ECAL_TTCci_CONFIGURATION " 00219 " where ( ttcci_configuration_id = :1 or ttcci_tag=:2 )" ); 00220 m_readStmt->setInt(1, result->getId()); 00221 m_readStmt->setString(2, result->getConfigTag()); 00222 ResultSet* rset = m_readStmt->executeQuery(); 00223 00224 rset->next(); 00225 // 1 is the id and 2 is the config tag 00226 00227 result->setId(rset->getInt(1)); 00228 result->setConfigTag(rset->getString(2)); 00229 00230 00231 result->setTTCciConfigurationFile(rset->getString(3)); 00232 result->setTrgMode(rset->getString(4)); 00233 result->setTrgSleep(rset->getInt(5)); 00234 00235 result->setConfigurationScript(rset->getString(7)); 00236 result->setConfigurationScriptParams(rset->getString(8)); 00237 00238 Clob clob = rset->getClob (6); 00239 cout << "Opening the clob in Read only mode" << endl; 00240 clob.open (OCCI_LOB_READONLY); 00241 int clobLength=clob.length (); 00242 cout << "Length of the clob is: " << clobLength << endl; 00243 m_size=clobLength; 00244 unsigned char* buffer = readClob (clob, m_size); 00245 clob.close (); 00246 cout<< "the clob buffer is:"<<endl; 00247 for (int i = 0; i < clobLength; ++i) 00248 cout << (char) buffer[i]; 00249 cout << endl; 00250 00251 00252 result->setTTCciClob(buffer ); 00253 00254 } catch (SQLException &e) { 00255 throw(runtime_error("ODTTCciConfig::fetchData(): "+e.getMessage())); 00256 } 00257 }
int ODTTCciConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 261 of file ODTTCciConfig.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), IDBObject::m_conn, and m_ID.
00262 { 00263 if (m_ID!=0) { 00264 return m_ID; 00265 } 00266 00267 this->checkConnection(); 00268 00269 try { 00270 Statement* stmt = m_conn->createStatement(); 00271 stmt->setSQL("SELECT ttcci_configuration_id FROM ecal_ttcci_configuration " 00272 "WHERE ttcci_tag=:ttcci_tag " 00273 ); 00274 00275 stmt->setString(1, getConfigTag() ); 00276 00277 ResultSet* rset = stmt->executeQuery(); 00278 00279 if (rset->next()) { 00280 m_ID = rset->getInt(1); 00281 } else { 00282 m_ID = 0; 00283 } 00284 m_conn->terminateStatement(stmt); 00285 } catch (SQLException &e) { 00286 throw(runtime_error("ODTTCciConfig::fetchID: "+e.getMessage())); 00287 } 00288 return m_ID; 00289 }
int ODTTCciConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 42 of file ODTTCciConfig.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00042 { 00043 00044 int result=0; 00045 try { 00046 this->checkConnection(); 00047 00048 m_readStmt = m_conn->createStatement(); 00049 m_readStmt->setSQL("select ecal_ttcci_config_sq.NextVal from dual"); 00050 ResultSet* rset = m_readStmt->executeQuery(); 00051 while (rset->next ()){ 00052 result= rset->getInt(1); 00053 } 00054 m_conn->terminateStatement(m_readStmt); 00055 return result; 00056 00057 } catch (SQLException &e) { 00058 throw(runtime_error("ODTTCciConfig::fetchNextId(): "+e.getMessage())); 00059 } 00060 00061 }
std::string ODTTCciConfig::getConfigurationScript | ( | ) | const [inline] |
Definition at line 31 of file ODTTCciConfig.h.
References m_configuration_script.
Referenced by prepareWrite().
00031 { return m_configuration_script; }
std::string ODTTCciConfig::getConfigurationScriptParams | ( | ) | const [inline] |
Definition at line 33 of file ODTTCciConfig.h.
References m_configuration_script_params.
Referenced by prepareWrite().
00033 { return m_configuration_script_params; }
int ODTTCciConfig::getId | ( | ) | const [inline] |
unsigned int ODTTCciConfig::getSize | ( | ) | const [inline] |
std::string ODTTCciConfig::getTable | ( | ) | [inline, virtual] |
std::string ODTTCciConfig::getTrgMode | ( | ) | const [inline] |
Definition at line 37 of file ODTTCciConfig.h.
References m_trg_mode.
Referenced by prepareWrite().
00037 { return m_trg_mode; }
int ODTTCciConfig::getTrgSleep | ( | ) | const [inline] |
Definition at line 39 of file ODTTCciConfig.h.
References m_trg_sleep.
Referenced by prepareWrite().
00039 { return m_trg_sleep; }
unsigned char* ODTTCciConfig::getTTCciClob | ( | ) | const [inline] |
Definition at line 42 of file ODTTCciConfig.h.
References m_ttcci_clob.
00042 { return m_ttcci_clob; }
std::string ODTTCciConfig::getTTCciConfigurationFile | ( | ) | const [inline] |
Definition at line 28 of file ODTTCciConfig.h.
References m_ttcci_file.
Referenced by prepareWrite(), and writeDB().
00028 { return m_ttcci_file; }
void ODTTCciConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 66 of file ODTTCciConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), fetchNextId(), IODConfig::getConfigTag(), getConfigurationScript(), getConfigurationScriptParams(), getTrgMode(), getTrgSleep(), getTTCciConfigurationFile(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00068 { 00069 this->checkConnection(); 00070 00071 int next_id=fetchNextId(); 00072 00073 try { 00074 m_writeStmt = m_conn->createStatement(); 00075 m_writeStmt->setSQL("INSERT INTO ECAL_TTCci_CONFIGURATION (ttcci_configuration_id, ttcci_tag, " 00076 " TTCCI_configuration_file, TRG_MODE, TRG_SLEEP, Configuration, configuration_script, configuration_script_params ) " 00077 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 )"); 00078 m_writeStmt->setInt(1, next_id); 00079 m_writeStmt->setString(2, getConfigTag()); 00080 m_writeStmt->setString(3, getTTCciConfigurationFile()); 00081 m_writeStmt->setString(4, getTrgMode()); 00082 m_writeStmt->setInt(5, getTrgSleep()); 00083 m_writeStmt->setString(7, getConfigurationScript()); 00084 m_writeStmt->setString(8, getConfigurationScriptParams()); 00085 00086 // and now the clob 00087 oracle::occi::Clob clob(m_conn); 00088 clob.setEmpty(); 00089 m_writeStmt->setClob(6,clob); 00090 m_writeStmt->executeUpdate (); 00091 m_ID=next_id; 00092 00093 m_conn->terminateStatement(m_writeStmt); 00094 std::cout<<"TTCci Clob inserted into CONFIGURATION with id="<<next_id<<std::endl; 00095 00096 // now we read and update it 00097 m_writeStmt = m_conn->createStatement(); 00098 m_writeStmt->setSQL ("SELECT Configuration FROM ECAL_TTCci_CONFIGURATION WHERE" 00099 " ttcci_configuration_id=:1 FOR UPDATE"); 00100 00101 std::cout<<"updating the clob 0"<<std::endl; 00102 00103 00104 } catch (SQLException &e) { 00105 throw(runtime_error("ODTTCciConfig::prepareWrite(): "+e.getMessage())); 00106 } 00107 00108 std::cout<<"updating the clob 1 "<<std::endl; 00109 00110 }
void ODTTCciConfig::setConfigurationScript | ( | std::string | x | ) | [inline] |
Definition at line 30 of file ODTTCciConfig.h.
References m_configuration_script.
Referenced by setParameters().
00030 { m_configuration_script = x; }
void ODTTCciConfig::setConfigurationScriptParams | ( | std::string | x | ) | [inline] |
Definition at line 32 of file ODTTCciConfig.h.
References m_configuration_script_params.
Referenced by setParameters().
00032 { m_configuration_script_params = x; }
void ODTTCciConfig::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 112 of file ODTTCciConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), mergeAndRegister_online::fname, m_size, IODConfig::setConfigTag(), setConfigurationScript(), setConfigurationScriptParams(), setTrgMode(), setTrgSleep(), and setTTCciConfigurationFile().
00112 { 00113 00114 // parses the result of the XML parser that is a map of 00115 // string string with variable name variable value 00116 00117 for( std::map<std::string, std::string >::iterator ci= 00118 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00119 00120 if(ci->first== "TRG_MODE") setTrgMode(ci->second); 00121 if(ci->first== "TRG_SLEEP") setTrgSleep(atoi(ci->second.c_str())); 00122 if(ci->first== "TTCci_CONFIGURATION_ID") setConfigTag(ci->second); 00123 if(ci->first== "CONFIGURATION_SCRIPT" ) setConfigurationScript(ci->second); 00124 if(ci->first== "CONFIGURATION_SCRIPT_PARAMS" ) setConfigurationScriptParams(ci->second); 00125 if(ci->first== "CONFIGURATION_SCRIPT_PARAMETERS" ) setConfigurationScriptParams(ci->second); 00126 if(ci->first== "Configuration") { 00127 std::string fname=ci->second ; 00128 string str3; 00129 size_t pos, pose; 00130 00131 pos = fname.find("="); // position of "live" in str 00132 pose = fname.size(); // position of "]" in str 00133 str3 = fname.substr (pos+1, pose-pos-2); 00134 00135 cout << "fname="<<fname<< " and reduced is: "<<str3 << endl; 00136 setTTCciConfigurationFile(str3 ); 00137 00138 00139 // here we must open the file and read the LTC Clob 00140 std::cout << "Going to read file: " << str3 << endl; 00141 00142 ifstream inpFile; 00143 inpFile.open(str3.c_str()); 00144 00145 // tell me size of file 00146 int bufsize = 0; 00147 inpFile.seekg( 0,ios::end ); 00148 bufsize = inpFile.tellg(); 00149 std::cout <<" bufsize ="<<bufsize<< std::endl; 00150 // set file pointer to start again 00151 inpFile.seekg( 0,ios::beg ); 00152 00153 inpFile.close(); 00154 m_size=bufsize; 00155 00156 } 00157 } 00158 00159 }
void ODTTCciConfig::setTrgMode | ( | std::string | x | ) | [inline] |
Definition at line 36 of file ODTTCciConfig.h.
References m_trg_mode.
Referenced by setParameters().
00036 { m_trg_mode = x; }
Definition at line 38 of file ODTTCciConfig.h.
References m_trg_sleep.
Referenced by setParameters().
00038 { m_trg_sleep = id; }
void ODTTCciConfig::setTTCciClob | ( | unsigned char * | x | ) | [inline] |
void ODTTCciConfig::setTTCciConfigurationFile | ( | std::string | x | ) | [inline] |
Definition at line 27 of file ODTTCciConfig.h.
References m_ttcci_file.
Referenced by setParameters().
00027 { m_ttcci_file = x; }
void ODTTCciConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 162 of file ODTTCciConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), getTTCciConfigurationFile(), m_ID, m_size, IODConfig::m_writeStmt, and IODConfig::populateClob().
00164 { 00165 00166 00167 std::cout<<"updating the clob 2"<<std::endl; 00168 00169 00170 try { 00171 00172 00173 m_writeStmt->setInt(1, m_ID); 00174 ResultSet* rset = m_writeStmt->executeQuery(); 00175 00176 while (rset->next ()) 00177 { 00178 oracle::occi::Clob clob = rset->getClob (1); 00179 cout << "Opening the clob in read write mode" << endl; 00180 cout << "Populating the clob" << endl; 00181 populateClob (clob, getTTCciConfigurationFile(), m_size); 00182 int clobLength=clob.length (); 00183 cout << "Length of the clob is: " << clobLength << endl; 00184 // clob.close (); 00185 } 00186 00187 m_writeStmt->executeUpdate(); 00188 00189 m_writeStmt->closeResultSet (rset); 00190 00191 } catch (SQLException &e) { 00192 throw(runtime_error("ODTTCciConfig::writeDB(): "+e.getMessage())); 00193 } 00194 // Now get the ID 00195 if (!this->fetchID()) { 00196 throw(runtime_error("ODTTCciConfig::writeDB: Failed to write")); 00197 } 00198 00199 }
friend class EcalCondDBInterface [friend] |
std::string ODTTCciConfig::m_configuration_script [private] |
Definition at line 62 of file ODTTCciConfig.h.
Referenced by clear(), getConfigurationScript(), ODTTCciConfig(), and setConfigurationScript().
std::string ODTTCciConfig::m_configuration_script_params [private] |
Definition at line 63 of file ODTTCciConfig.h.
Referenced by clear(), getConfigurationScriptParams(), ODTTCciConfig(), and setConfigurationScriptParams().
int ODTTCciConfig::m_ID [private] |
Definition at line 59 of file ODTTCciConfig.h.
Referenced by fetchID(), getId(), ODTTCciConfig(), prepareWrite(), setId(), and writeDB().
int ODTTCciConfig::m_size [private] |
Definition at line 66 of file ODTTCciConfig.h.
Referenced by fetchData(), getSize(), ODTTCciConfig(), setParameters(), setSize(), and writeDB().
std::string ODTTCciConfig::m_trg_mode [private] |
Definition at line 64 of file ODTTCciConfig.h.
Referenced by clear(), getTrgMode(), and setTrgMode().
int ODTTCciConfig::m_trg_sleep [private] |
Definition at line 65 of file ODTTCciConfig.h.
Referenced by clear(), getTrgSleep(), and setTrgSleep().
unsigned char* ODTTCciConfig::m_ttcci_clob [private] |
std::string ODTTCciConfig::m_ttcci_file [private] |
Definition at line 61 of file ODTTCciConfig.h.
Referenced by clear(), getTTCciConfigurationFile(), and setTTCciConfigurationFile().