#include <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< std::string, std::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 11 of file ODScanConfig.cc.
References hitfit::clear(), and NULL.
{ m_env = NULL; m_conn = NULL; m_writeStmt = NULL; m_readStmt = NULL; m_config_tag=""; m_ID=0; clear(); }
ODScanConfig::~ODScanConfig | ( | ) |
Definition at line 24 of file ODScanConfig.cc.
{ }
void ODScanConfig::clear | ( | void | ) | [private] |
Definition at line 28 of file ODScanConfig.cc.
{ m_type_id=0; m_type=""; m_from_val=0; m_to_val=0; m_step=0; }
void ODScanConfig::fetchData | ( | ODScanConfig * | result | ) | throw (std::runtime_error) [private] |
Definition at line 131 of file ODScanConfig.cc.
References alignCSCRings::e, and query::result.
{ this->checkConnection(); result->clear(); if(result->getId()==0 && (result->getConfigTag()=="") ){ throw(std::runtime_error("ODScanConfig::fetchData(): no Id defined for this ODScanConfig ")); } try { m_readStmt->setSQL("SELECT * " "FROM ECAL_SCAN_DAT " " where (scan_id = :1 or scan_tag=:2 )" ); m_readStmt->setInt(1, result->getId()); m_readStmt->setString(2, result->getConfigTag()); ResultSet* rset = m_readStmt->executeQuery(); rset->next(); // id 1 is the scan_id result->setId(rset->getInt(1)); result->setConfigTag(rset->getString(2)); result->setTypeId( rset->getInt(3) ); result->setScanType( rset->getString(4) ); result->setFromVal( rset->getInt(5) ); result->setToVal( rset->getInt(6) ); result->setStep( rset->getInt(7) ); } catch (SQLException &e) { throw(std::runtime_error("ODScanConfig::fetchData(): "+e.getMessage())); } }
int ODScanConfig::fetchID | ( | ) | throw (std::runtime_error) [private] |
Definition at line 166 of file ODScanConfig.cc.
References alignCSCRings::e.
{ // Return from memory if available if (m_ID!=0) { return m_ID; } this->checkConnection(); try { Statement* stmt = m_conn->createStatement(); stmt->setSQL("SELECT scan_id FROM ecal_scan_dat " "WHERE scan_tag=:scan_tag "); stmt->setString(1, getConfigTag() ); ResultSet* rset = stmt->executeQuery(); if (rset->next()) { m_ID = rset->getInt(1); } else { m_ID = 0; } m_conn->terminateStatement(stmt); } catch (SQLException &e) { throw(std::runtime_error("ODScanConfig::fetchID: "+e.getMessage())); } return m_ID; }
int ODScanConfig::fetchNextId | ( | ) | throw (std::runtime_error) [private] |
Definition at line 38 of file ODScanConfig.cc.
References alignCSCRings::e, and query::result.
{ int result=0; try { this->checkConnection(); m_readStmt = m_conn->createStatement(); m_readStmt->setSQL("select ecal_scan_config_sq.NextVal from dual"); ResultSet* rset = m_readStmt->executeQuery(); while (rset->next ()){ result= rset->getInt(1); } m_conn->terminateStatement(m_readStmt); return result; } catch (SQLException &e) { throw(std::runtime_error("ODScanConfig::fetchNextId(): "+e.getMessage())); } }
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 79 of file ODScanConfig.cc.
References alignCSCRings::e.
{ this->checkConnection(); int next_id=fetchNextId(); try { m_writeStmt = m_conn->createStatement(); m_writeStmt->setSQL("INSERT INTO ECAL_scan_dat ( scan_id, scan_tag ," " type_id, scan_type , FROM_VAL , TO_VAL, STEP )" " VALUES ( :1, :2, :3, :4, :5, :6, :7)"); m_writeStmt->setInt(1, next_id); m_ID=next_id; } catch (SQLException &e) { throw(std::runtime_error("ODScanConfig::prepareWrite(): "+e.getMessage())); } }
void ODScanConfig::setFromVal | ( | int | x | ) | [inline] |
void ODScanConfig::setId | ( | int | id | ) | [inline] |
Definition at line 18 of file ODScanConfig.h.
References errorMatrix2Lands_multiChannel::id, and m_ID.
void ODScanConfig::setParameters | ( | std::map< std::string, std::string > | my_keys_map | ) |
void ODScanConfig::setScanType | ( | std::string | x | ) | [inline] |
void ODScanConfig::setStep | ( | int | x | ) | [inline] |
void ODScanConfig::setToVal | ( | int | x | ) | [inline] |
void ODScanConfig::setTypeId | ( | int | x | ) | [inline] |
void ODScanConfig::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 98 of file ODScanConfig.cc.
References alignCSCRings::e.
{ this->checkConnection(); this->checkPrepare(); try { // number 1 is the id m_writeStmt->setString(2, this->getConfigTag()); m_writeStmt->setInt(3, this->getTypeId()); m_writeStmt->setString(4, this->getScanType() ); m_writeStmt->setInt(5, this->getFromVal() ); m_writeStmt->setInt(6, this->getToVal() ); m_writeStmt->setInt(7, this->getStep() ); m_writeStmt->executeUpdate(); } catch (SQLException &e) { throw(std::runtime_error("ODScanConfig::writeDB(): "+e.getMessage())); } // Now get the ID if (!this->fetchID()) { throw(std::runtime_error("ODScanConfig::writeDB: Failed to write")); } }
friend class EcalCondDBInterface [friend] |
Reimplemented from IDBObject.
Definition at line 11 of file ODScanConfig.h.
int ODScanConfig::m_from_val [private] |
Definition at line 51 of file ODScanConfig.h.
Referenced by getFromVal(), and setFromVal().
int ODScanConfig::m_ID [private] |
Definition at line 47 of file ODScanConfig.h.
int ODScanConfig::m_step [private] |
Definition at line 53 of file ODScanConfig.h.
int ODScanConfig::m_to_val [private] |
Definition at line 52 of file ODScanConfig.h.
Referenced by getToVal(), and setToVal().
std::string ODScanConfig::m_type [private] |
Definition at line 50 of file ODScanConfig.h.
Referenced by getScanType(), and setScanType().
int ODScanConfig::m_type_id [private] |
Definition at line 49 of file ODScanConfig.h.
Referenced by getTypeId(), and setTypeId().