#include <OnlineDB/EcalCondDB/interface/ODSRPConfig.h>
Public Member Functions | |
int | getAutomaticMasks () const |
std::string | getConfigFile () const |
int | getDebugMode () const |
int | getDummyMode () const |
int | getId () const |
std::string | getPatternDirectory () const |
int | getSRP0BunchAdjustPosition () const |
unsigned char * | getSRPClob () const |
std::string | getTable () |
ODSRPConfig () | |
void | setAutomaticMasks (int x) |
void | setConfigFile (std::string x) |
void | setDebugMode (int x) |
void | setDummyMode (int x) |
void | setId (int id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setPatternDirectory (std::string x) |
void | setSRP0BunchAdjustPosition (int x) |
void | setSRPClob (unsigned char *x) |
~ODSRPConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODSRPConfig *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_auto |
int | m_bnch |
int | m_debug |
int | m_dummy |
std::string | m_file |
int | m_ID |
std::string | m_patdir |
unsigned int | m_size |
unsigned char * | m_srp_clob |
Friends | |
class | EcalCondDBInterface |
Definition at line 17 of file ODSRPConfig.h.
ODSRPConfig::ODSRPConfig | ( | ) |
Definition at line 10 of file ODSRPConfig.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 }
ODSRPConfig::~ODSRPConfig | ( | ) |
Definition at line 23 of file ODSRPConfig.cc.
References m_auto, m_bnch, m_debug, m_dummy, m_file, and m_patdir.
Referenced by ODSRPConfig().
00023 { 00024 // strcpy((char *)m_srp_clob, ""); 00025 m_debug=0; 00026 m_dummy=0; 00027 m_file=""; 00028 m_patdir=""; 00029 m_auto=0; 00030 m_bnch=0; 00031 00032 }
void ODSRPConfig::fetchData | ( | ODSRPConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 193 of file ODSRPConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), i, IODConfig::m_readStmt, IODConfig::readClob(), and HLT_VtxMuL3::result.
00195 { 00196 this->checkConnection(); 00197 result->clear(); 00198 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00199 throw(runtime_error("ODSRPConfig::fetchData(): no Id defined for this ODSRPConfig ")); 00200 } 00201 00202 try { 00203 00204 m_readStmt->setSQL("SELECT * " 00205 " FROM ECAL_SRP_CONFIGURATION " 00206 " where (srp_configuration_id = :1 or srp_tag=:2 )" ); 00207 m_readStmt->setInt(1, result->getId()); 00208 m_readStmt->setString(2, result->getConfigTag()); 00209 ResultSet* rset = m_readStmt->executeQuery(); 00210 00211 rset->next(); 00212 // 1 is the id and 2 is the config tag 00213 00214 result->setId(rset->getInt(1)); 00215 result->setConfigTag(rset->getString(2)); 00216 00217 result->setDebugMode(rset->getInt(3)); 00218 result->setDummyMode(rset->getInt(4)); 00219 result->setPatternDirectory(rset->getString(5)); 00220 result->setAutomaticMasks(rset->getInt(6)); 00221 result->setSRP0BunchAdjustPosition(rset->getInt(7)); 00222 result->setConfigFile(rset->getString(8)); 00223 00224 Clob clob = rset->getClob(9); 00225 cout << "Opening the clob in Read only mode" << endl; 00226 clob.open (OCCI_LOB_READONLY); 00227 int clobLength=clob.length (); 00228 cout << "Length of the clob is: " << clobLength << endl; 00229 unsigned char* buffer = readClob (clob, clobLength); 00230 clob.close (); 00231 cout<< "the clob buffer is:"<<endl; 00232 for (int i = 0; i < clobLength; ++i) 00233 cout << (char) buffer[i]; 00234 cout << endl; 00235 00236 00237 result->setSRPClob(buffer ); 00238 00239 } catch (SQLException &e) { 00240 throw(runtime_error("ODSRPConfig::fetchData(): "+e.getMessage())); 00241 } 00242 }
int ODSRPConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 246 of file ODSRPConfig.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), IDBObject::m_conn, and m_ID.
00247 { 00248 // Return from memory if available 00249 if (m_ID!=0) { 00250 return m_ID; 00251 } 00252 00253 this->checkConnection(); 00254 00255 try { 00256 Statement* stmt = m_conn->createStatement(); 00257 stmt->setSQL("SELECT srp_configuration_id FROM ecal_srp_configuration " 00258 "WHERE srp_tag=:srp_tag " 00259 ); 00260 00261 stmt->setString(1, getConfigTag() ); 00262 00263 ResultSet* rset = stmt->executeQuery(); 00264 00265 if (rset->next()) { 00266 m_ID = rset->getInt(1); 00267 } else { 00268 m_ID = 0; 00269 } 00270 m_conn->terminateStatement(stmt); 00271 } catch (SQLException &e) { 00272 throw(runtime_error("ODSRPConfig::fetchID: "+e.getMessage())); 00273 } 00274 00275 return m_ID; 00276 }
int ODSRPConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 38 of file ODSRPConfig.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00038 { 00039 00040 int result=0; 00041 try { 00042 this->checkConnection(); 00043 00044 m_readStmt = m_conn->createStatement(); 00045 m_readStmt->setSQL("select ecal_srp_config_sq.NextVal from dual"); 00046 ResultSet* rset = m_readStmt->executeQuery(); 00047 while (rset->next ()){ 00048 result= rset->getInt(1); 00049 } 00050 m_conn->terminateStatement(m_readStmt); 00051 return result; 00052 00053 } catch (SQLException &e) { 00054 throw(runtime_error("ODSRPConfig::fetchNextId(): "+e.getMessage())); 00055 } 00056 00057 }
int ODSRPConfig::getAutomaticMasks | ( | ) | const [inline] |
Definition at line 39 of file ODSRPConfig.h.
References m_auto.
Referenced by prepareWrite().
00039 { return m_auto; }
std::string ODSRPConfig::getConfigFile | ( | ) | const [inline] |
Definition at line 45 of file ODSRPConfig.h.
References m_file.
Referenced by prepareWrite(), and writeDB().
00045 { return m_file; }
int ODSRPConfig::getDebugMode | ( | ) | const [inline] |
Definition at line 30 of file ODSRPConfig.h.
References m_debug.
Referenced by prepareWrite().
00030 { return m_debug; }
int ODSRPConfig::getDummyMode | ( | ) | const [inline] |
Definition at line 33 of file ODSRPConfig.h.
References m_dummy.
Referenced by prepareWrite().
00033 { return m_dummy; }
int ODSRPConfig::getId | ( | ) | const [inline] |
std::string ODSRPConfig::getPatternDirectory | ( | ) | const [inline] |
Definition at line 36 of file ODSRPConfig.h.
References m_patdir.
Referenced by prepareWrite().
00036 { return m_patdir; }
int ODSRPConfig::getSRP0BunchAdjustPosition | ( | ) | const [inline] |
Definition at line 42 of file ODSRPConfig.h.
References m_bnch.
Referenced by prepareWrite().
00042 { return m_bnch; }
unsigned char* ODSRPConfig::getSRPClob | ( | ) | const [inline] |
std::string ODSRPConfig::getTable | ( | ) | [inline, virtual] |
void ODSRPConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 107 of file ODSRPConfig.cc.
References IDBObject::checkConnection(), GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), fetchNextId(), getAutomaticMasks(), getConfigFile(), IODConfig::getConfigTag(), getDebugMode(), getDummyMode(), getPatternDirectory(), getSRP0BunchAdjustPosition(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00109 { 00110 this->checkConnection(); 00111 00112 int next_id=fetchNextId(); 00113 00114 try { 00115 m_writeStmt = m_conn->createStatement(); 00116 m_writeStmt->setSQL("INSERT INTO ECAL_SRP_CONFIGURATION (srp_configuration_id, srp_tag, " 00117 " DEBUGMODE, DUMMYMODE, PATTERN_DIRECTORY, AUTOMATIC_MASKS, " 00118 " SRP0BUNCHADJUSTPOSITION, SRP_CONFIG_FILE, SRP_CONFIGURATION ) " 00119 "VALUES (:1, :2, :3, :4, :5, :6, :7, :8, :9 )"); 00120 m_writeStmt->setInt(1, next_id); 00121 m_writeStmt->setString(2, getConfigTag()); 00122 m_writeStmt->setInt(3, getDebugMode()); 00123 m_writeStmt->setInt(4, getDummyMode()); 00124 m_writeStmt->setString(5, getPatternDirectory()); 00125 m_writeStmt->setInt(6, getAutomaticMasks()); 00126 m_writeStmt->setInt(7, getSRP0BunchAdjustPosition()); 00127 m_writeStmt->setString(8, getConfigFile()); 00128 00129 // and now the clob 00130 oracle::occi::Clob clob(m_conn); 00131 clob.setEmpty(); 00132 m_writeStmt->setClob(9,clob); 00133 m_writeStmt->executeUpdate (); 00134 m_ID=next_id; 00135 00136 m_conn->terminateStatement(m_writeStmt); 00137 std::cout<<"SRP Clob inserted into CONFIGURATION with id="<<next_id<<std::endl; 00138 00139 // now we read and update it 00140 m_writeStmt = m_conn->createStatement(); 00141 m_writeStmt->setSQL ("SELECT srp_configuration FROM ECAL_SRP_CONFIGURATION WHERE" 00142 " srp_configuration_id=:1 FOR UPDATE"); 00143 00144 std::cout<<"updating the clob 0"<<std::endl; 00145 00146 00147 } catch (SQLException &e) { 00148 throw(runtime_error("ODSRPConfig::prepareWrite(): "+e.getMessage())); 00149 } 00150 00151 std::cout<<"updating the clob 1 "<<std::endl; 00152 00153 }
void ODSRPConfig::setConfigFile | ( | std::string | x | ) | [inline] |
void ODSRPConfig::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 62 of file ODSRPConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, end, lat::endl(), mergeAndRegister_online::fname, m_size, setAutomaticMasks(), setConfigFile(), IODConfig::setConfigTag(), setDebugMode(), setDummyMode(), setPatternDirectory(), and setSRP0BunchAdjustPosition().
00062 { 00063 00064 // parses the result of the XML parser that is a map of 00065 // string string with variable name variable value 00066 00067 00068 for( std::map<std::string, std::string >::iterator ci= 00069 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00070 00071 if(ci->first== "SRP_CONFIGURATION_ID") setConfigTag(ci->second); 00072 if(ci->first== "debugMode") setDebugMode(atoi(ci->second.c_str())); 00073 if(ci->first== "dummyMode") setDummyMode(atoi(ci->second.c_str())); 00074 if(ci->first== "PatternDirectory") setPatternDirectory(ci->second); 00075 if(ci->first== "AutomaticMasks") setAutomaticMasks(atoi(ci->second.c_str())); 00076 if(ci->first== "SRP0BunchAdjustPosition") setSRP0BunchAdjustPosition(atoi(ci->second.c_str())); 00077 if(ci->first== "SRP_CONFIG_FILE") { 00078 std::string fname=ci->second ; 00079 00080 cout << "fname="<<fname << endl; 00081 setConfigFile(fname); 00082 00083 00084 // here we must open the file and read the LTC Clob 00085 std::cout << "Going to read SRP file: " << fname << endl; 00086 00087 ifstream inpFile; 00088 inpFile.open(fname.c_str()); 00089 00090 // tell me size of file 00091 int bufsize = 0; 00092 inpFile.seekg( 0,ios::end ); 00093 bufsize = inpFile.tellg(); 00094 std::cout <<" bufsize ="<<bufsize<< std::endl; 00095 // set file pointer to start again 00096 inpFile.seekg( 0,ios::beg ); 00097 00098 m_size=bufsize; 00099 00100 inpFile.close(); 00101 00102 } 00103 } 00104 00105 }
void ODSRPConfig::setPatternDirectory | ( | std::string | x | ) | [inline] |
void ODSRPConfig::setSRPClob | ( | unsigned char * | x | ) | [inline] |
void ODSRPConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 156 of file ODSRPConfig.cc.
References GenMuonPlsPt100GeV_cfg::cout, e, lat::endl(), getConfigFile(), m_ID, m_size, IODConfig::m_writeStmt, and IODConfig::populateClob().
00158 { 00159 00160 std::cout<<"updating the clob 2"<<std::endl; 00161 00162 try { 00163 m_writeStmt->setInt(1, m_ID); 00164 ResultSet* rset = m_writeStmt->executeQuery(); 00165 00166 while (rset->next ()) 00167 { 00168 oracle::occi::Clob clob = rset->getClob (1); 00169 cout << "Opening the clob in read write mode" << endl; 00170 cout << "Populating the clob" << endl; 00171 populateClob (clob, getConfigFile(), m_size ); 00172 int clobLength=clob.length (); 00173 cout << "Length of the clob after writing is: " << clobLength << endl; 00174 00175 } 00176 00177 m_writeStmt->executeUpdate(); 00178 00179 m_writeStmt->closeResultSet (rset); 00180 00181 } catch (SQLException &e) { 00182 throw(runtime_error("ODSRPConfig::writeDB(): "+e.getMessage())); 00183 } 00184 // Now get the ID 00185 if (!this->fetchID()) { 00186 throw(runtime_error("ODSRPConfig::writeDB: Failed to write")); 00187 } 00188 00189 00190 }
friend class EcalCondDBInterface [friend] |
int ODSRPConfig::m_auto [private] |
Definition at line 69 of file ODSRPConfig.h.
Referenced by clear(), getAutomaticMasks(), and setAutomaticMasks().
int ODSRPConfig::m_bnch [private] |
Definition at line 70 of file ODSRPConfig.h.
Referenced by clear(), getSRP0BunchAdjustPosition(), and setSRP0BunchAdjustPosition().
int ODSRPConfig::m_debug [private] |
Definition at line 65 of file ODSRPConfig.h.
Referenced by clear(), getDebugMode(), and setDebugMode().
int ODSRPConfig::m_dummy [private] |
Definition at line 66 of file ODSRPConfig.h.
Referenced by clear(), getDummyMode(), and setDummyMode().
std::string ODSRPConfig::m_file [private] |
Definition at line 67 of file ODSRPConfig.h.
Referenced by clear(), getConfigFile(), and setConfigFile().
int ODSRPConfig::m_ID [private] |
Definition at line 63 of file ODSRPConfig.h.
Referenced by fetchID(), getId(), ODSRPConfig(), prepareWrite(), setId(), and writeDB().
std::string ODSRPConfig::m_patdir [private] |
Definition at line 68 of file ODSRPConfig.h.
Referenced by clear(), getPatternDirectory(), and setPatternDirectory().
unsigned int ODSRPConfig::m_size [private] |
Definition at line 71 of file ODSRPConfig.h.
Referenced by ODSRPConfig(), setParameters(), and writeDB().
unsigned char* ODSRPConfig::m_srp_clob [private] |