#include <OnlineDB/EcalCondDB/interface/ODTCCConfig.h>
Public Member Functions | |
int | getId () const |
unsigned char * | getLUTClob () const |
std::string | getLUTConfigurationFile () const |
int | getNTestPatternsToLoad () const |
unsigned char * | getSLBClob () const |
std::string | getSLBConfigurationFile () const |
std::string | getTable () |
unsigned char * | getTCCClob () const |
std::string | getTCCConfigurationFile () const |
std::string | getTestPatternFileUrl () const |
ODTCCConfig () | |
void | setId (int id) |
void | setLUTClob (unsigned char *x) |
void | setLUTConfigurationFile (std::string x) |
void | setNTestPatternsToLoad (int id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setSLBClob (unsigned char *x) |
void | setSLBConfigurationFile (std::string x) |
void | setTCCClob (unsigned char *x) |
void | setTCCConfigurationFile (std::string x) |
void | setTestPatternFileUrl (std::string x) |
~ODTCCConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODTCCConfig *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_lut_clob |
std::string | m_lut_file |
int | m_ntest |
unsigned int | m_size |
unsigned char * | m_slb_clob |
std::string | m_slb_file |
unsigned char * | m_tcc_clob |
std::string | m_tcc_file |
std::string | m_test_url |
Friends | |
class | EcalCondDBInterface |
Definition at line 15 of file ODTCCConfig.h.
ODTCCConfig::ODTCCConfig | ( | ) |
Definition at line 10 of file ODTCCConfig.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.
00011 { 00012 m_env = NULL; 00013 m_conn = NULL; 00014 m_writeStmt = NULL; 00015 m_readStmt = NULL; 00016 m_config_tag=""; 00017 00018 m_ID=0; 00019 clear(); 00020 m_size=0; 00021 }
ODTCCConfig::~ODTCCConfig | ( | ) |
Definition at line 23 of file ODTCCConfig.cc.
References m_lut_file, m_ntest, m_slb_file, m_tcc_file, and m_test_url.
Referenced by ODTCCConfig().
00023 { 00024 00025 m_tcc_file=""; 00026 m_lut_file=""; 00027 m_slb_file=""; 00028 m_test_url=""; 00029 m_ntest=0; 00030 }
void ODTCCConfig::fetchData | ( | ODTCCConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 179 of file ODTCCConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), i, IODConfig::m_readStmt, IODConfig::readClob(), and HLT_VtxMuL3::result.
00181 { 00182 this->checkConnection(); 00183 result->clear(); 00184 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00185 throw(runtime_error("ODTCCConfig::fetchData(): no Id defined for this ODTCCConfig ")); 00186 } 00187 00188 try { 00189 00190 m_readStmt->setSQL("SELECT * " 00191 "FROM ECAL_TCC_CONFIGURATION d " 00192 " where (tcc_configuration_id = :1 or tcc_tag=:2 )" ); 00193 m_readStmt->setInt(1, result->getId()); 00194 m_readStmt->setString(2, result->getConfigTag()); 00195 ResultSet* rset = m_readStmt->executeQuery(); 00196 00197 rset->next(); 00198 // the first is the id 00199 result->setId(rset->getInt(1)); 00200 result->setConfigTag(rset->getString(2)); 00201 00202 result->setTCCConfigurationFile(rset->getString(3)); 00203 result->setLUTConfigurationFile(rset->getString(4)); 00204 result->setSLBConfigurationFile(rset->getString(5)); 00205 result->setTestPatternFileUrl(rset->getString(6)); 00206 result->setNTestPatternsToLoad(rset->getInt(7)); 00207 // 00208 00209 Clob clob1 = rset->getClob (8); 00210 cout << "Opening the clob in Read only mode" << endl; 00211 clob1.open (OCCI_LOB_READONLY); 00212 int clobLength=clob1.length (); 00213 cout << "Length of the clob1 is: " << clobLength << endl; 00214 unsigned char* buffer = readClob (clob1, clobLength); 00215 clob1.close (); 00216 cout<< "the clob buffer is:"<<endl; 00217 for (int i = 0; i < clobLength; ++i) 00218 cout << (char) buffer[i]; 00219 cout << endl; 00220 result->setTCCClob(buffer ); 00221 00222 Clob clob2 = rset->getClob (9); 00223 cout << "Opening the clob in Read only mode" << endl; 00224 clob2.open (OCCI_LOB_READONLY); 00225 clobLength=clob2.length (); 00226 cout << "Length of the clob2 is: " << clobLength << endl; 00227 unsigned char* buffer2 = readClob (clob2, clobLength); 00228 clob2.close (); 00229 cout<< "the clob buffer is:"<<endl; 00230 for (int i = 0; i < clobLength; ++i) 00231 cout << (char) buffer2[i]; 00232 cout << endl; 00233 result->setLUTClob(buffer2 ); 00234 00235 Clob clob3 = rset->getClob (10); 00236 cout << "Opening the clob in Read only mode" << endl; 00237 clob3.open (OCCI_LOB_READONLY); 00238 clobLength=clob3.length (); 00239 cout << "Length of the clob3 is: " << clobLength << endl; 00240 unsigned char* buffer3 = readClob (clob3, clobLength); 00241 clob3.close (); 00242 cout<< "the clob buffer is:"<<endl; 00243 for (int i = 0; i < clobLength; ++i) 00244 cout << (char) buffer3[i]; 00245 cout << endl; 00246 result->setSLBClob(buffer3 ); 00247 00248 } catch (SQLException &e) { 00249 throw(runtime_error("ODTCCConfig::fetchData(): "+e.getMessage())); 00250 } 00251 }
int ODTCCConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 255 of file ODTCCConfig.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), IDBObject::m_conn, and m_ID.
00256 { 00257 if (m_ID!=0) { 00258 return m_ID; 00259 } 00260 00261 this->checkConnection(); 00262 00263 try { 00264 Statement* stmt = m_conn->createStatement(); 00265 stmt->setSQL("SELECT tcc_configuration_id FROM ecal_tcc_configuration " 00266 "WHERE tcc_tag=:tcc_tag " 00267 ); 00268 00269 stmt->setString(1, getConfigTag() ); 00270 00271 ResultSet* rset = stmt->executeQuery(); 00272 00273 if (rset->next()) { 00274 m_ID = rset->getInt(1); 00275 } else { 00276 m_ID = 0; 00277 } 00278 m_conn->terminateStatement(stmt); 00279 } catch (SQLException &e) { 00280 throw(runtime_error("ODTCCConfig::fetchID: "+e.getMessage())); 00281 } 00282 00283 return m_ID; 00284 }
int ODTCCConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 37 of file ODTCCConfig.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00037 { 00038 00039 int result=0; 00040 try { 00041 this->checkConnection(); 00042 00043 m_readStmt = m_conn->createStatement(); 00044 m_readStmt->setSQL("select ecal_tcc_config_sq.NextVal from dual"); 00045 ResultSet* rset = m_readStmt->executeQuery(); 00046 while (rset->next ()){ 00047 result= rset->getInt(1); 00048 } 00049 m_conn->terminateStatement(m_readStmt); 00050 return result; 00051 00052 } catch (SQLException &e) { 00053 throw(runtime_error("ODTCCConfig::fetchNextId(): "+e.getMessage())); 00054 } 00055 00056 }
int ODTCCConfig::getId | ( | ) | const [inline] |
unsigned char* ODTCCConfig::getLUTClob | ( | ) | const [inline] |
std::string ODTCCConfig::getLUTConfigurationFile | ( | ) | const [inline] |
Definition at line 30 of file ODTCCConfig.h.
References m_lut_file.
Referenced by prepareWrite(), and writeDB().
00030 { return m_lut_file; }
int ODTCCConfig::getNTestPatternsToLoad | ( | ) | const [inline] |
Definition at line 36 of file ODTCCConfig.h.
References m_ntest.
Referenced by prepareWrite().
00036 { return m_ntest; }
unsigned char* ODTCCConfig::getSLBClob | ( | ) | const [inline] |
std::string ODTCCConfig::getSLBConfigurationFile | ( | ) | const [inline] |
Definition at line 32 of file ODTCCConfig.h.
References m_slb_file.
Referenced by prepareWrite(), and writeDB().
00032 { return m_slb_file; }
std::string ODTCCConfig::getTable | ( | ) | [inline, virtual] |
unsigned char* ODTCCConfig::getTCCClob | ( | ) | const [inline] |
std::string ODTCCConfig::getTCCConfigurationFile | ( | ) | const [inline] |
Definition at line 28 of file ODTCCConfig.h.
References m_tcc_file.
Referenced by prepareWrite(), and writeDB().
00028 { return m_tcc_file; }
std::string ODTCCConfig::getTestPatternFileUrl | ( | ) | const [inline] |
Definition at line 34 of file ODTCCConfig.h.
References m_test_url.
Referenced by prepareWrite().
00034 { return m_test_url; }
void ODTCCConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 80 of file ODTCCConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), fetchNextId(), IODConfig::getConfigTag(), getLUTConfigurationFile(), getNTestPatternsToLoad(), getSLBConfigurationFile(), getTCCConfigurationFile(), getTestPatternFileUrl(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00082 { 00083 this->checkConnection(); 00084 00085 int next_id=fetchNextId(); 00086 00087 try { 00088 m_writeStmt = m_conn->createStatement(); 00089 m_writeStmt->setSQL("INSERT INTO ECAL_TCC_CONFIGURATION (tcc_configuration_id, tcc_tag, " 00090 "Configuration_file, LUT_CONFIGURATION_FILE, SLB_CONFIGURATION_FILE, " 00091 "TESTPATTERNFILE_URL , N_TESTPATTERNS_TO_LOAD, " 00092 "tcc_configuration, lut_configuration, slb_configuration ) " 00093 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 , :9, :10)"); 00094 m_writeStmt->setInt(1, next_id); 00095 m_writeStmt->setString(2, getConfigTag()); 00096 m_writeStmt->setString(3, getTCCConfigurationFile()); 00097 m_writeStmt->setString(4, getLUTConfigurationFile()); 00098 m_writeStmt->setString(5, getSLBConfigurationFile()); 00099 m_writeStmt->setString(6, getTestPatternFileUrl()); 00100 m_writeStmt->setInt(7, getNTestPatternsToLoad()); 00101 // and now the clobs 00102 oracle::occi::Clob clob1(m_conn); 00103 clob1.setEmpty(); 00104 m_writeStmt->setClob(8,clob1); 00105 00106 oracle::occi::Clob clob2(m_conn); 00107 clob2.setEmpty(); 00108 m_writeStmt->setClob(9,clob2); 00109 00110 oracle::occi::Clob clob3(m_conn); 00111 clob3.setEmpty(); 00112 m_writeStmt->setClob(10,clob3); 00113 00114 m_writeStmt->executeUpdate (); 00115 m_ID=next_id; 00116 00117 m_conn->terminateStatement(m_writeStmt); 00118 std::cout<<"TCC 3 empty Clobs inserted into CONFIGURATION with id="<<next_id<<std::endl; 00119 00120 // now we read and update it 00121 m_writeStmt = m_conn->createStatement(); 00122 m_writeStmt->setSQL ("SELECT tcc_configuration, lut_configuration, slb_configuration FROM ECAL_TCC_CONFIGURATION WHERE" 00123 " tcc_configuration_id=:1 FOR UPDATE"); 00124 00125 std::cout<<"updating the clobs 0"<<std::endl; 00126 00127 00128 } catch (SQLException &e) { 00129 throw(runtime_error("ODTCCConfig::prepareWrite(): "+e.getMessage())); 00130 } 00131 00132 std::cout<<"updating the clob 1 "<<std::endl; 00133 00134 }
void ODTCCConfig::setLUTClob | ( | unsigned char * | x | ) | [inline] |
void ODTCCConfig::setLUTConfigurationFile | ( | std::string | x | ) | [inline] |
Definition at line 29 of file ODTCCConfig.h.
References m_lut_file.
Referenced by setParameters().
00029 { m_lut_file = x; }
void ODTCCConfig::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 59 of file ODTCCConfig.cc.
References IODConfig::setConfigTag(), setLUTConfigurationFile(), setNTestPatternsToLoad(), setSLBConfigurationFile(), setTCCConfigurationFile(), and setTestPatternFileUrl().
00059 { 00060 00061 // parses the result of the XML parser that is a map of 00062 // string string with variable name variable value 00063 00064 for( std::map<std::string, std::string >::iterator ci= 00065 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00066 00067 if(ci->first== "TCC_CONFIGURATION_ID") setConfigTag(ci->second); 00068 if(ci->first== "N_TESTPATTERNS_TO_LOAD") setNTestPatternsToLoad(atoi(ci->second.c_str())); 00069 if(ci->first== "LUT_CONFIGURATION_FILE") setLUTConfigurationFile(ci->second ); 00070 if(ci->first== "CONFIGURATION_FILE") setTCCConfigurationFile(ci->second ); 00071 if(ci->first== "SLB_CONFIGURATION_FILE") setSLBConfigurationFile(ci->second ); 00072 if(ci->first== "TESTPATTERNFILE_URL") setTestPatternFileUrl(ci->second ); 00073 00074 } 00075 00076 }
void ODTCCConfig::setSLBClob | ( | unsigned char * | x | ) | [inline] |
void ODTCCConfig::setSLBConfigurationFile | ( | std::string | x | ) | [inline] |
Definition at line 31 of file ODTCCConfig.h.
References m_slb_file.
Referenced by setParameters().
00031 { m_slb_file = x; }
void ODTCCConfig::setTCCClob | ( | unsigned char * | x | ) | [inline] |
void ODTCCConfig::setTCCConfigurationFile | ( | std::string | x | ) | [inline] |
Definition at line 27 of file ODTCCConfig.h.
References m_tcc_file.
Referenced by setParameters().
00027 { m_tcc_file = x; }
void ODTCCConfig::setTestPatternFileUrl | ( | std::string | x | ) | [inline] |
Definition at line 33 of file ODTCCConfig.h.
References m_test_url.
Referenced by setParameters().
00033 { m_test_url = x; }
void ODTCCConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 136 of file ODTCCConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), getLUTConfigurationFile(), getSLBConfigurationFile(), getTCCConfigurationFile(), m_ID, m_size, IODConfig::m_writeStmt, and IODConfig::populateClob().
00138 { 00139 00140 std::cout<<"updating the clob 2"<<std::endl; 00141 00142 try { 00143 00144 m_writeStmt->setInt(1, m_ID); 00145 ResultSet* rset = m_writeStmt->executeQuery(); 00146 00147 while (rset->next ()) 00148 { 00149 oracle::occi::Clob clob1 = rset->getClob (1); 00150 oracle::occi::Clob clob2 = rset->getClob (2); 00151 oracle::occi::Clob clob3 = rset->getClob (3); 00152 cout << "Opening the clob in read write mode" << endl; 00153 cout << "Populating the clobs" << endl; 00154 populateClob (clob1, getTCCConfigurationFile(), m_size); 00155 populateClob (clob2, getLUTConfigurationFile(), m_size); 00156 populateClob (clob3, getSLBConfigurationFile(), m_size); 00157 00158 } 00159 00160 m_writeStmt->executeUpdate(); 00161 m_writeStmt->closeResultSet (rset); 00162 00163 } catch (SQLException &e) { 00164 throw(runtime_error("ODTCCConfig::writeDB(): "+e.getMessage())); 00165 } 00166 // Now get the ID 00167 if (!this->fetchID()) { 00168 throw(runtime_error("ODTCCConfig::writeDB: Failed to write")); 00169 } 00170 00171 00172 }
friend class EcalCondDBInterface [friend] |
int ODTCCConfig::m_ID [private] |
Definition at line 61 of file ODTCCConfig.h.
Referenced by fetchID(), getId(), ODTCCConfig(), prepareWrite(), setId(), and writeDB().
unsigned char* ODTCCConfig::m_lut_clob [private] |
std::string ODTCCConfig::m_lut_file [private] |
Definition at line 66 of file ODTCCConfig.h.
Referenced by clear(), getLUTConfigurationFile(), and setLUTConfigurationFile().
int ODTCCConfig::m_ntest [private] |
Definition at line 69 of file ODTCCConfig.h.
Referenced by clear(), getNTestPatternsToLoad(), and setNTestPatternsToLoad().
unsigned int ODTCCConfig::m_size [private] |
unsigned char* ODTCCConfig::m_slb_clob [private] |
std::string ODTCCConfig::m_slb_file [private] |
Definition at line 67 of file ODTCCConfig.h.
Referenced by clear(), getSLBConfigurationFile(), and setSLBConfigurationFile().
unsigned char* ODTCCConfig::m_tcc_clob [private] |
std::string ODTCCConfig::m_tcc_file [private] |
Definition at line 65 of file ODTCCConfig.h.
Referenced by clear(), getTCCConfigurationFile(), and setTCCConfigurationFile().
std::string ODTCCConfig::m_test_url [private] |
Definition at line 68 of file ODTCCConfig.h.
Referenced by clear(), getTestPatternFileUrl(), and setTestPatternFileUrl().