#include <OnlineDB/EcalCondDB/interface/ODScanConfig.h>
Public Member Functions | |
int | getFromVal () const |
int | getId () const |
std::string | getScanType () const |
int | getStep () const |
std::string | getTable () |
int | getToVal () const |
int | getTypeId () const |
ODScanConfig () | |
void | setFromVal (int x) |
void | setId (int id) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setScanType (std::string x) |
void | setStep (int x) |
void | setToVal (int x) |
void | setTypeId (int x) |
~ODScanConfig () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODScanConfig *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_from_val |
int | m_ID |
int | m_step |
int | m_to_val |
std::string | m_type |
int | m_type_id |
Friends | |
class | EcalCondDBInterface |
Definition at line 9 of file ODScanConfig.h.
ODScanConfig::ODScanConfig | ( | ) |
Definition at line 10 of file ODScanConfig.cc.
References clear(), IODConfig::m_config_tag, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, 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 m_ID=0; 00018 clear(); 00019 }
ODScanConfig::~ODScanConfig | ( | ) |
Definition at line 27 of file ODScanConfig.cc.
References m_from_val, m_step, m_to_val, m_type, and m_type_id.
Referenced by ODScanConfig().
00027 { 00028 00029 m_type_id=0; 00030 m_type=""; 00031 m_from_val=0; 00032 m_to_val=0; 00033 m_step=0; 00034 00035 }
void ODScanConfig::fetchData | ( | ODScanConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 130 of file ODScanConfig.cc.
References IDBObject::checkConnection(), e, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
00132 { 00133 this->checkConnection(); 00134 result->clear(); 00135 if(result->getId()==0 && (result->getConfigTag()=="") ){ 00136 throw(runtime_error("ODScanConfig::fetchData(): no Id defined for this ODScanConfig ")); 00137 } 00138 00139 try { 00140 00141 m_readStmt->setSQL("SELECT * " 00142 "FROM ECAL_SCAN_DAT " 00143 " where (scan_id = :1 or scan_tag=:2 )" ); 00144 m_readStmt->setInt(1, result->getId()); 00145 m_readStmt->setString(2, result->getConfigTag()); 00146 00147 ResultSet* rset = m_readStmt->executeQuery(); 00148 00149 rset->next(); 00150 00151 // id 1 is the scan_id 00152 result->setId(rset->getInt(1)); 00153 result->setConfigTag(rset->getString(2)); 00154 result->setTypeId( rset->getInt(3) ); 00155 result->setScanType( rset->getString(4) ); 00156 result->setFromVal( rset->getInt(5) ); 00157 result->setToVal( rset->getInt(6) ); 00158 result->setStep( rset->getInt(7) ); 00159 00160 } catch (SQLException &e) { 00161 throw(runtime_error("ODScanConfig::fetchData(): "+e.getMessage())); 00162 } 00163 }
int ODScanConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 165 of file ODScanConfig.cc.
References IDBObject::checkConnection(), e, IODConfig::getConfigTag(), IDBObject::m_conn, and m_ID.
00166 { 00167 // Return from memory if available 00168 if (m_ID!=0) { 00169 return m_ID; 00170 } 00171 00172 this->checkConnection(); 00173 00174 try { 00175 Statement* stmt = m_conn->createStatement(); 00176 stmt->setSQL("SELECT scan_id FROM ecal_scan_dat " 00177 "WHERE scan_tag=:scan_tag "); 00178 00179 stmt->setString(1, getConfigTag() ); 00180 00181 ResultSet* rset = stmt->executeQuery(); 00182 00183 if (rset->next()) { 00184 m_ID = rset->getInt(1); 00185 } else { 00186 m_ID = 0; 00187 } 00188 m_conn->terminateStatement(stmt); 00189 } catch (SQLException &e) { 00190 throw(runtime_error("ODScanConfig::fetchID: "+e.getMessage())); 00191 } 00192 00193 return m_ID; 00194 }
int ODScanConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 37 of file ODScanConfig.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_scan_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("ODScanConfig::fetchNextId(): "+e.getMessage())); 00054 } 00055 00056 }
int ODScanConfig::getFromVal | ( | ) | const [inline] |
int ODScanConfig::getId | ( | ) | const [inline] |
std::string ODScanConfig::getScanType | ( | ) | const [inline] |
int ODScanConfig::getStep | ( | ) | const [inline] |
std::string ODScanConfig::getTable | ( | ) | [inline, virtual] |
int ODScanConfig::getToVal | ( | ) | const [inline] |
int ODScanConfig::getTypeId | ( | ) | const [inline] |
void ODScanConfig::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 78 of file ODScanConfig.cc.
References IDBObject::checkConnection(), e, fetchNextId(), IDBObject::m_conn, m_ID, and IODConfig::m_writeStmt.
00080 { 00081 this->checkConnection(); 00082 int next_id=fetchNextId(); 00083 00084 try { 00085 m_writeStmt = m_conn->createStatement(); 00086 m_writeStmt->setSQL("INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ," 00087 " type_id, scan_type , FROM_VAL , TO_VAL, STEP )" 00088 " VALUES ( :1, :2, :3, :4, :5, :6, :7)"); 00089 m_writeStmt->setInt(1, next_id); 00090 m_ID=next_id; 00091 00092 } catch (SQLException &e) { 00093 throw(runtime_error("ODScanConfig::prepareWrite(): "+e.getMessage())); 00094 } 00095 }
Definition at line 27 of file ODScanConfig.h.
References m_from_val.
Referenced by setParameters().
00027 { m_from_val = x; }
void ODScanConfig::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 59 of file ODScanConfig.cc.
References IODConfig::setConfigTag(), setFromVal(), setScanType(), setStep(), setToVal(), and setTypeId().
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== "SCAN_ID") setConfigTag(ci->second); 00068 if(ci->first== "TYPE_ID") setTypeId(atoi(ci->second.c_str()) ); 00069 if(ci->first== "TYPE" || ci->first== "SCAN_TYPE") setScanType(ci->second.c_str() ); 00070 if(ci->first== "FROM" ||ci->first== "FROM_VAL" ) setFromVal(atoi(ci->second.c_str() )); 00071 if(ci->first== "TO" ||ci->first== "TO_VAL" ) setToVal(atoi(ci->second.c_str() )); 00072 if(ci->first== "STEP") setStep(atoi(ci->second.c_str() )); 00073 00074 } 00075 00076 }
void ODScanConfig::setScanType | ( | std::string | x | ) | [inline] |
void ODScanConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 97 of file ODScanConfig.cc.
References IDBObject::checkConnection(), IODConfig::checkPrepare(), e, and IODConfig::m_writeStmt.
00099 { 00100 this->checkConnection(); 00101 this->checkPrepare(); 00102 00103 try { 00104 00105 // number 1 is the id 00106 m_writeStmt->setString(2, this->getConfigTag()); 00107 00108 m_writeStmt->setInt(3, this->getTypeId()); 00109 m_writeStmt->setString(4, this->getScanType() ); 00110 m_writeStmt->setInt(5, this->getFromVal() ); 00111 m_writeStmt->setInt(6, this->getToVal() ); 00112 m_writeStmt->setInt(7, this->getStep() ); 00113 00114 m_writeStmt->executeUpdate(); 00115 00116 00117 } catch (SQLException &e) { 00118 throw(runtime_error("ODScanConfig::writeDB(): "+e.getMessage())); 00119 } 00120 // Now get the ID 00121 if (!this->fetchID()) { 00122 throw(runtime_error("ODScanConfig::writeDB: Failed to write")); 00123 } 00124 00125 }
friend class EcalCondDBInterface [friend] |
int ODScanConfig::m_from_val [private] |
Definition at line 51 of file ODScanConfig.h.
Referenced by clear(), getFromVal(), and setFromVal().
int ODScanConfig::m_ID [private] |
Definition at line 47 of file ODScanConfig.h.
Referenced by fetchID(), getId(), ODScanConfig(), prepareWrite(), and setId().
int ODScanConfig::m_step [private] |
int ODScanConfig::m_to_val [private] |
std::string ODScanConfig::m_type [private] |
Definition at line 50 of file ODScanConfig.h.
Referenced by clear(), getScanType(), and setScanType().
int ODScanConfig::m_type_id [private] |