#include <OnlineDB/EcalCondDB/interface/ODDCCConfig.h>
Public Member Functions | |
unsigned char * | getDCCClob () const |
std::string | getDCCConfigurationUrl () const |
int | getId () const |
int | getNTestPatternsToLoad () const |
unsigned int | getSize () const |
int | getSMHalf () const |
std::string | getTable () |
std::string | getTestPatternFileUrl () const |
ODDCCConfig () | |
void | setDCCClob (unsigned char *x) |
void | setDCCConfigurationUrl (std::string x) |
void | setId (int id) |
void | setNTestPatternsToLoad (int id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setSize (unsigned int id) |
void | setSMHalf (int id) |
void | setTestPatternFileUrl (std::string x) |
~ODDCCConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODDCCConfig *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 | |
unsigned char * | m_dcc_clob |
std::string | m_dcc_url |
int | m_ID |
int | m_ntest |
unsigned int | m_size |
int | m_sm_half |
std::string | m_test_url |
Friends | |
class | EcalCondDBInterface |
Definition at line 15 of file ODDCCConfig.h.
ODDCCConfig::ODDCCConfig | ( | ) |
Definition at line 15 of file ODDCCConfig.cc.
References clear(), IODConfig::m_config_tag, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, m_size, IODConfig::m_writeStmt, and NULL.
00016 { 00017 m_env = NULL; 00018 m_conn = NULL; 00019 m_writeStmt = NULL; 00020 m_readStmt = NULL; 00021 m_size=0; 00022 m_config_tag=""; 00023 m_ID=0; 00024 clear(); 00025 00026 }
ODDCCConfig::~ODDCCConfig | ( | ) |
Definition at line 191 of file ODDCCConfig.cc.
References m_dcc_url, m_ntest, m_sm_half, and m_test_url.
Referenced by ODDCCConfig().
00191 { 00192 00193 m_dcc_url=""; 00194 m_test_url=""; 00195 m_ntest=0; 00196 m_sm_half=0; 00197 00198 }
void ODDCCConfig::fetchData | ( | ODDCCConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 203 of file ODDCCConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), i, IODConfig::m_readStmt, m_size, IODConfig::readClob(), and HLT_VtxMuL3::result.
00205 { 00206 this->checkConnection(); 00207 result->clear(); 00208 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00209 throw(runtime_error("ODDCCConfig::fetchData(): no Id defined for this ODDCCConfig ")); 00210 } 00211 00212 try { 00213 00214 m_readStmt->setSQL("SELECT * " 00215 "FROM ECAL_DCC_CONFIGURATION " 00216 " where dcc_configuration_id = :1 or dcc_tag=:2 " ); 00217 m_readStmt->setInt(1, result->getId()); 00218 m_readStmt->setString(2, result->getConfigTag()); 00219 ResultSet* rset = m_readStmt->executeQuery(); 00220 00221 rset->next(); 00222 00223 // 1 is the id and 2 is the config tag 00224 00225 result->setId(rset->getInt(1)); 00226 result->setConfigTag(rset->getString(2)); 00227 result->setDCCConfigurationUrl(rset->getString(3)); 00228 result->setTestPatternFileUrl(rset->getString(4)); 00229 result->setNTestPatternsToLoad(rset->getInt(5)); 00230 result->setSMHalf(rset->getInt(6)); 00231 00232 00233 Clob clob = rset->getClob (7); 00234 cout << "Opening the clob in Read only mode" << endl; 00235 clob.open (OCCI_LOB_READONLY); 00236 int clobLength=clob.length (); 00237 cout << "Length of the clob is: " << clobLength << endl; 00238 m_size=clobLength; 00239 unsigned char* buffer = readClob (clob, m_size); 00240 clob.close (); 00241 cout<< "the clob buffer is:"<<endl; 00242 for (int i = 0; i < clobLength; ++i) 00243 cout << (char) buffer[i]; 00244 cout << endl; 00245 00246 00247 result->setDCCClob(buffer ); 00248 00249 } catch (SQLException &e) { 00250 throw(runtime_error("ODDCCConfig::fetchData(): "+e.getMessage())); 00251 } 00252 }
int ODDCCConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 256 of file ODDCCConfig.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), IDBObject::m_conn, and m_ID.
00257 { 00258 if (m_ID!=0) { 00259 return m_ID; 00260 } 00261 00262 this->checkConnection(); 00263 00264 try { 00265 Statement* stmt = m_conn->createStatement(); 00266 stmt->setSQL("SELECT DCC_configuration_id FROM ecal_dcc_configuration " 00267 "WHERE dcc_tag=:dcc_tag " 00268 ); 00269 00270 stmt->setString(1, getConfigTag() ); 00271 00272 00273 ResultSet* rset = stmt->executeQuery(); 00274 00275 if (rset->next()) { 00276 m_ID = rset->getInt(1); 00277 } else { 00278 m_ID = 0; 00279 } 00280 m_conn->terminateStatement(stmt); 00281 } catch (SQLException &e) { 00282 throw(runtime_error("ODDCCConfig::fetchID: "+e.getMessage())); 00283 } 00284 00285 00286 return m_ID; 00287 }
int ODDCCConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 34 of file ODDCCConfig.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00034 { 00035 00036 int result=0; 00037 try { 00038 this->checkConnection(); 00039 00040 m_readStmt = m_conn->createStatement(); 00041 m_readStmt->setSQL("select ecal_dcc_config_sq.NextVal from dual"); 00042 ResultSet* rset = m_readStmt->executeQuery(); 00043 while (rset->next ()){ 00044 result= rset->getInt(1); 00045 } 00046 m_conn->terminateStatement(m_readStmt); 00047 return result; 00048 00049 } catch (SQLException &e) { 00050 throw(runtime_error("ODDCCConfig::fetchNextId(): "+e.getMessage())); 00051 } 00052 00053 }
unsigned char* ODDCCConfig::getDCCClob | ( | ) | const [inline] |
std::string ODDCCConfig::getDCCConfigurationUrl | ( | ) | const [inline] |
Definition at line 30 of file ODDCCConfig.h.
References m_dcc_url.
Referenced by prepareWrite(), and writeDB().
00030 { return m_dcc_url; }
int ODDCCConfig::getId | ( | ) | const [inline] |
int ODDCCConfig::getNTestPatternsToLoad | ( | ) | const [inline] |
Definition at line 36 of file ODDCCConfig.h.
References m_ntest.
Referenced by prepareWrite().
00036 { return m_ntest; }
unsigned int ODDCCConfig::getSize | ( | ) | const [inline] |
int ODDCCConfig::getSMHalf | ( | ) | const [inline] |
Definition at line 39 of file ODDCCConfig.h.
References m_sm_half.
Referenced by prepareWrite().
00039 { return m_sm_half; }
std::string ODDCCConfig::getTable | ( | ) | [inline, virtual] |
std::string ODDCCConfig::getTestPatternFileUrl | ( | ) | const [inline] |
Definition at line 33 of file ODDCCConfig.h.
References m_test_url.
Referenced by prepareWrite().
00033 { return m_test_url; }
void ODDCCConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 58 of file ODDCCConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), fetchNextId(), IODConfig::getConfigTag(), getDCCConfigurationUrl(), getNTestPatternsToLoad(), getSMHalf(), getTestPatternFileUrl(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00060 { 00061 this->checkConnection(); 00062 00063 int next_id=fetchNextId(); 00064 00065 try { 00066 m_writeStmt = m_conn->createStatement(); 00067 m_writeStmt->setSQL("INSERT INTO ECAL_DCC_CONFIGURATION (dcc_configuration_id, dcc_tag, " 00068 " DCC_CONFIGURATION_URL, TESTPATTERN_FILE_URL, " 00069 " N_TESTPATTERNS_TO_LOAD , SM_HALF, " 00070 " dcc_configuration) " 00071 "VALUES (:1, :2, :3, :4, :5, :6 , :7 )"); 00072 m_writeStmt->setInt(1, next_id); 00073 m_writeStmt->setString(2, getConfigTag()); 00074 m_writeStmt->setString(3, getDCCConfigurationUrl()); 00075 m_writeStmt->setString(4, getTestPatternFileUrl()); 00076 m_writeStmt->setInt(5, getNTestPatternsToLoad()); 00077 m_writeStmt->setInt(6, getSMHalf()); 00078 00079 // and now the clob 00080 oracle::occi::Clob clob(m_conn); 00081 clob.setEmpty(); 00082 m_writeStmt->setClob(7,clob); 00083 m_writeStmt->executeUpdate (); 00084 m_ID=next_id; 00085 00086 m_conn->terminateStatement(m_writeStmt); 00087 std::cout<<"DCC Clob inserted into CONFIGURATION with id="<<next_id<<std::endl; 00088 00089 // now we read and update it 00090 m_writeStmt = m_conn->createStatement(); 00091 m_writeStmt->setSQL ("SELECT dcc_configuration FROM ECAL_DCC_CONFIGURATION WHERE" 00092 " dcc_configuration_id=:1 FOR UPDATE"); 00093 00094 std::cout<<"updating the clob 0"<<std::endl; 00095 00096 00097 00098 } catch (SQLException &e) { 00099 throw(runtime_error("ODDCCConfig::prepareWrite(): "+e.getMessage())); 00100 } 00101 00102 std::cout<<"updating the clob 1 "<<std::endl; 00103 00104 00105 }
void ODDCCConfig::setDCCClob | ( | unsigned char * | x | ) | [inline] |
void ODDCCConfig::setDCCConfigurationUrl | ( | std::string | x | ) | [inline] |
void ODDCCConfig::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 108 of file ODDCCConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), mergeAndRegister_online::fname, m_size, IODConfig::setConfigTag(), setDCCConfigurationUrl(), setNTestPatternsToLoad(), setSMHalf(), and setTestPatternFileUrl().
00108 { 00109 00110 // parses the result of the XML parser that is a map of 00111 // string string with variable name variable value 00112 00113 for( std::map<std::string, std::string >::iterator ci= 00114 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00115 00116 if(ci->first== "DCC_CONFIGURATION_ID") setConfigTag(ci->second); 00117 if(ci->first== "TESTPATTERN_FILE_URL") setTestPatternFileUrl(ci->second ); 00118 if(ci->first== "N_TESTPATTERNS_TO_LOAD") setNTestPatternsToLoad(atoi(ci->second.c_str() )); 00119 if(ci->first== "SM_HALF") setSMHalf(atoi(ci->second.c_str() )); 00120 if(ci->first== "DCC_CONFIGURATION_URL") { 00121 std::string fname=ci->second ; 00122 setDCCConfigurationUrl(fname ); 00123 00124 // here we must open the file and read the DCC Clob 00125 std::cout << "Going to read DCC file: " << fname << endl; 00126 00127 ifstream inpFile; 00128 inpFile.open(fname.c_str()); 00129 00130 // tell me size of file 00131 int bufsize = 0; 00132 inpFile.seekg( 0,ios::end ); 00133 bufsize = inpFile.tellg(); 00134 std::cout <<" bufsize ="<<bufsize<< std::endl; 00135 // set file pointer to start again 00136 inpFile.seekg( 0,ios::beg ); 00137 00138 m_size=bufsize; 00139 00140 inpFile.close(); 00141 00142 } 00143 } 00144 00145 }
void ODDCCConfig::setTestPatternFileUrl | ( | std::string | x | ) | [inline] |
Definition at line 32 of file ODDCCConfig.h.
References m_test_url.
Referenced by setParameters().
00032 { m_test_url = x; }
void ODDCCConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 150 of file ODDCCConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), getDCCConfigurationUrl(), m_ID, m_size, IODConfig::m_writeStmt, and IODConfig::populateClob().
00152 { 00153 00154 00155 std::cout<<"updating the clob "<<std::endl; 00156 00157 00158 try { 00159 00160 00161 m_writeStmt->setInt(1, m_ID); 00162 ResultSet* rset = m_writeStmt->executeQuery(); 00163 00164 rset->next (); 00165 oracle::occi::Clob clob = rset->getClob (1); 00166 00167 cout << "Opening the clob in read write mode" << endl; 00168 00169 std::cout << "Populating the clob" << endl; 00170 00171 populateClob (clob, getDCCConfigurationUrl(), m_size); 00172 int clobLength=clob.length (); 00173 cout << "Length of the clob is: " << clobLength << endl; 00174 00175 m_writeStmt->executeUpdate(); 00176 00177 m_writeStmt->closeResultSet (rset); 00178 00179 } catch (SQLException &e) { 00180 throw(runtime_error("ODDCCConfig::writeDB(): "+e.getMessage())); 00181 } 00182 // Now get the ID 00183 if (!this->fetchID()) { 00184 throw(runtime_error("ODDCCConfig::writeDB: Failed to write")); 00185 } 00186 00187 00188 }
friend class EcalCondDBInterface [friend] |
unsigned char* ODDCCConfig::m_dcc_clob [private] |
std::string ODDCCConfig::m_dcc_url [private] |
Definition at line 59 of file ODDCCConfig.h.
Referenced by clear(), getDCCConfigurationUrl(), and setDCCConfigurationUrl().
int ODDCCConfig::m_ID [private] |
Definition at line 57 of file ODDCCConfig.h.
Referenced by fetchID(), getId(), ODDCCConfig(), prepareWrite(), setId(), and writeDB().
int ODDCCConfig::m_ntest [private] |
Definition at line 61 of file ODDCCConfig.h.
Referenced by clear(), getNTestPatternsToLoad(), and setNTestPatternsToLoad().
unsigned int ODDCCConfig::m_size [private] |
Definition at line 63 of file ODDCCConfig.h.
Referenced by fetchData(), getSize(), ODDCCConfig(), setParameters(), setSize(), and writeDB().
int ODDCCConfig::m_sm_half [private] |
std::string ODDCCConfig::m_test_url [private] |
Definition at line 60 of file ODDCCConfig.h.
Referenced by clear(), getTestPatternFileUrl(), and setTestPatternFileUrl().