#include <OnlineDB/EcalCondDB/interface/ODCond2ConfInfo.h>
Public Member Functions | |
int | fetchID () throw (std::runtime_error) |
int | fetchNextId () throw (std::runtime_error) |
Tm | getDBDate () const |
std::string | getDescription () const |
int | getId () const |
std::string | getLocation () const |
Tm | getRecordDate () const |
int | getRunNumber () const |
std::string | getTable () |
std::string | getType () const |
ODCond2ConfInfo () | |
void | setDBDate (Tm x) |
void | setDescription (std::string x) |
void | setId (int id) |
void | setLocation (std::string x) |
void | setParameters (std::map< string, string > my_keys_map) |
void | setRecordDate (Tm x) |
void | setRunNumber (int id) |
void | setType (std::string x) |
~ODCond2ConfInfo () | |
Private Member Functions | |
void | clear () |
void | fetchData (ODCond2ConfInfo *result) throw (std::runtime_error) |
void | fetchParents () throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeDB () throw (std::runtime_error) |
Private Attributes | |
Tm | m_db_time |
std::string | m_desc |
int | m_ID |
std::string | m_loc |
int | m_loc_id |
Tm | m_rec_time |
int | m_run |
int | m_typ_id |
std::string | m_type |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file ODCond2ConfInfo.h.
ODCond2ConfInfo::ODCond2ConfInfo | ( | ) |
Definition at line 12 of file ODCond2ConfInfo.cc.
References clear(), IODConfig::m_config_tag, IDBObject::m_conn, IDBObject::m_env, m_ID, IODConfig::m_readStmt, IODConfig::m_writeStmt, and NULL.
00013 { 00014 m_env = NULL; 00015 m_conn = NULL; 00016 m_writeStmt = NULL; 00017 m_readStmt = NULL; 00018 m_config_tag=""; 00019 m_ID=0; 00020 clear(); 00021 }
ODCond2ConfInfo::~ODCond2ConfInfo | ( | ) |
Definition at line 24 of file ODCond2ConfInfo.cc.
References m_db_time, m_desc, m_loc, m_loc_id, m_rec_time, m_run, m_typ_id, and m_type.
Referenced by ODCond2ConfInfo().
00024 { 00025 m_type=""; 00026 m_loc=""; 00027 m_run=0; 00028 m_desc=""; 00029 m_rec_time = Tm(); 00030 m_db_time = Tm(); 00031 m_typ_id=0; 00032 m_loc_id=0; 00033 00034 00035 }
void ODCond2ConfInfo::fetchData | ( | ODCond2ConfInfo * | result | ) | throw (std::runtime_error) [private] |
Definition at line 187 of file ODCond2ConfInfo.cc.
References IDBObject::checkConnection(), DateHandler::dateToTm(), e, getTable(), IDBObject::m_conn, m_db_time, IDBObject::m_env, IODConfig::m_readStmt, m_rec_time, and HLT_VtxMuL3::result.
00189 { 00190 this->checkConnection(); 00191 result->clear(); 00192 00193 DateHandler dh(m_env, m_conn); 00194 00195 00196 if(result->getId()==0 ){ 00197 throw(runtime_error("ODCond2ConfInfo::fetchData(): no Id defined for this ODCond2ConfInfo ")); 00198 } 00199 00200 try { 00201 00202 m_readStmt->setSQL("SELECT rec_id, REC_TYPE, rec_date, location, " 00203 "run_number, short_desc, db_timestamp FROM " + getTable() + " , COND2CONF_TYPE_DEF , location_def " 00204 " where rec_id = :1 AND COND2CONF_TYPE_DEF.def_id=" 00205 +getTable()+".REC_TYPE_ID AND location_def.def_id=LOCATION_ID "); 00206 m_readStmt->setInt(1, result->getId()); 00207 ResultSet* rset = m_readStmt->executeQuery(); 00208 00209 rset->next(); 00210 00211 // 1 is the id and 2 is the config tag and 3 is the version 00212 00213 00214 00215 00216 // result->setId(rset->getInt(1)); 00217 00218 00219 result->setType(rset->getString(2)); 00220 Date startDate = rset->getDate(3); 00221 result->setLocation(rset->getString(4)); 00222 result->setRunNumber(rset->getInt(5)); 00223 result->setDescription(rset->getString(6)); 00224 Date endDate = rset->getDate(7); 00225 00226 m_rec_time = dh.dateToTm( startDate ); 00227 m_db_time = dh.dateToTm( endDate ); 00228 00229 } catch (SQLException &e) { 00230 throw(runtime_error("ODCond2ConfInfo::fetchData(): "+e.getMessage())); 00231 } 00232 }
int ODCond2ConfInfo::fetchID | ( | ) | throw (std::runtime_error) |
Definition at line 234 of file ODCond2ConfInfo.cc.
References IDBObject::checkConnection(), e, fetchParents(), getDescription(), getRunNumber(), getTable(), IDBObject::m_conn, m_ID, and m_typ_id.
00235 { 00236 // Return from memory if available 00237 if (m_ID!=0) { 00238 return m_ID; 00239 } 00240 00241 this->checkConnection(); 00242 00243 00244 fetchParents(); 00245 00246 try { 00247 Statement* stmt = m_conn->createStatement(); 00248 stmt->setSQL("SELECT rec_id FROM "+ getTable()+ 00249 "WHERE rec_type_id=:1 and (run_number=:2 or short_desc=:3 ) order by rec_id DESC " ); 00250 00251 stmt->setInt(1, m_typ_id ); 00252 stmt->setInt(2, getRunNumber() ); 00253 stmt->setString(3, getDescription() ); 00254 00255 ResultSet* rset = stmt->executeQuery(); 00256 00257 if (rset->next()) { 00258 m_ID = rset->getInt(1); 00259 } else { 00260 m_ID = 0; 00261 } 00262 m_conn->terminateStatement(stmt); 00263 } catch (SQLException &e) { 00264 throw(runtime_error("ODCond2ConfInfo::fetchID: "+e.getMessage())); 00265 } 00266 00267 return m_ID; 00268 }
int ODCond2ConfInfo::fetchNextId | ( | ) | throw (std::runtime_error) |
Definition at line 45 of file ODCond2ConfInfo.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IODConfig::m_readStmt, and HLT_VtxMuL3::result.
Referenced by prepareWrite().
00045 { 00046 00047 int result=0; 00048 try { 00049 this->checkConnection(); 00050 00051 m_readStmt = m_conn->createStatement(); 00052 m_readStmt->setSQL("select COND2CONF_INFO_SQ.NextVal from DUAL "); 00053 ResultSet* rset = m_readStmt->executeQuery(); 00054 while (rset->next ()){ 00055 result= rset->getInt(1); 00056 } 00057 result++; 00058 m_conn->terminateStatement(m_readStmt); 00059 return result; 00060 00061 } catch (SQLException &e) { 00062 throw(runtime_error("ODCond2ConfInfo::fetchNextId(): "+e.getMessage())); 00063 } 00064 00065 }
void ODCond2ConfInfo::fetchParents | ( | ) | throw (std::runtime_error) [private] |
Definition at line 67 of file ODCond2ConfInfo.cc.
References IDBObject::checkConnection(), e, getLocation(), getType(), IDBObject::m_conn, m_loc_id, IODConfig::m_readStmt, and m_typ_id.
Referenced by fetchID(), and prepareWrite().
00067 { 00068 00069 00070 00071 if(m_typ_id==0) { 00072 00073 if(getType()!=""){ 00074 try { 00075 this->checkConnection(); 00076 m_readStmt = m_conn->createStatement(); 00077 m_readStmt->setSQL("select def_id from COND2CONF_TYPE_DEF where rec_type="+getType()); 00078 ResultSet* rset = m_readStmt->executeQuery(); 00079 while (rset->next ()){ 00080 m_typ_id= rset->getInt(1); 00081 } 00082 m_conn->terminateStatement(m_readStmt); 00083 00084 00085 } catch (SQLException &e) { 00086 throw(runtime_error("ODCond2ConfInfo::fetchParents(): "+e.getMessage())); 00087 } 00088 } 00089 } 00090 if(m_loc_id==0){ 00091 if(getLocation()!=""){ 00092 try { 00093 this->checkConnection(); 00094 m_readStmt = m_conn->createStatement(); 00095 m_readStmt->setSQL("select def_id from location_def where location="+getLocation()); 00096 ResultSet* rset = m_readStmt->executeQuery(); 00097 while (rset->next ()){ 00098 m_loc_id= rset->getInt(1); 00099 } 00100 m_conn->terminateStatement(m_readStmt); 00101 } catch (SQLException &e) { 00102 throw(runtime_error("ODCond2ConfInfo::fetchParents(): "+e.getMessage())); 00103 } 00104 } 00105 } 00106 00107 }
Tm ODCond2ConfInfo::getDBDate | ( | ) | const [inline] |
std::string ODCond2ConfInfo::getDescription | ( | ) | const [inline] |
Definition at line 37 of file ODCond2ConfInfo.h.
References m_desc.
Referenced by fetchID().
00037 { return m_desc ; }
int ODCond2ConfInfo::getId | ( | ) | const [inline] |
Definition at line 22 of file ODCond2ConfInfo.h.
References m_ID.
Referenced by prepareWrite().
00022 { return m_ID; }
std::string ODCond2ConfInfo::getLocation | ( | ) | const [inline] |
Definition at line 31 of file ODCond2ConfInfo.h.
References m_loc.
Referenced by fetchParents().
00031 { return m_loc; }
Tm ODCond2ConfInfo::getRecordDate | ( | ) | const [inline] |
Definition at line 28 of file ODCond2ConfInfo.h.
References m_rec_time.
00028 { return m_rec_time; }
int ODCond2ConfInfo::getRunNumber | ( | ) | const [inline] |
Definition at line 34 of file ODCond2ConfInfo.h.
References m_run.
Referenced by fetchID().
00034 { return m_run; }
std::string ODCond2ConfInfo::getTable | ( | ) | [inline, virtual] |
Implements IODConfig.
Definition at line 19 of file ODCond2ConfInfo.h.
Referenced by fetchData(), fetchID(), and prepareWrite().
std::string ODCond2ConfInfo::getType | ( | ) | const [inline] |
Definition at line 25 of file ODCond2ConfInfo.h.
References m_type.
Referenced by fetchParents().
00025 { return m_type; }
void ODCond2ConfInfo::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IODConfig.
Definition at line 109 of file ODCond2ConfInfo.cc.
References IDBObject::checkConnection(), e, fetchNextId(), fetchParents(), getId(), getTable(), IDBObject::m_conn, m_ID, m_loc_id, m_typ_id, and IODConfig::m_writeStmt.
00111 { 00112 this->checkConnection(); 00113 00114 int next_id=0; 00115 if(getId()==0){ 00116 next_id=fetchNextId(); 00117 } 00118 00119 fetchParents(); 00120 try { 00121 m_writeStmt = m_conn->createStatement(); 00122 m_writeStmt->setSQL("INSERT INTO "+getTable()+" ( rec_id, rec_type_id, rec_date, " 00123 "location_id, run_number, short_desc ) " 00124 " VALUES ( :1, :2, :3 , :4, :5, :6 ) " ); 00125 00126 m_writeStmt->setInt(1, next_id); 00127 m_writeStmt->setInt(3, m_typ_id); 00128 m_writeStmt->setInt(4, m_loc_id); 00129 00130 m_ID=next_id; 00131 00132 } catch (SQLException &e) { 00133 throw(runtime_error("ODCond2ConfInfo::prepareWrite(): "+e.getMessage())); 00134 } 00135 00136 }
void ODCond2ConfInfo::setDescription | ( | std::string | x | ) | [inline] |
void ODCond2ConfInfo::setLocation | ( | std::string | x | ) | [inline] |
void ODCond2ConfInfo::setParameters | ( | std::map< string, string > | my_keys_map | ) |
Definition at line 138 of file ODCond2ConfInfo.cc.
References GenMuonPlsPt100GeV_cfg::cout, and lat::endl().
00138 { 00139 00140 // parses the result of the XML parser that is a map of 00141 // string string with variable name variable value 00142 00143 for( std::map<std::string, std::string >::iterator ci= 00144 my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) { 00145 00146 // if(ci->first== "TAG") setConfigTag(ci->second); 00147 00148 } 00149 std::cout<< "method not yet implemented"<< std::endl; 00150 00151 }
void ODCond2ConfInfo::setType | ( | std::string | x | ) | [inline] |
void ODCond2ConfInfo::writeDB | ( | ) | throw (std::runtime_error) [private] |
Definition at line 154 of file ODCond2ConfInfo.cc.
References IDBObject::checkConnection(), IODConfig::checkPrepare(), e, Tm::isNull(), IDBObject::m_conn, IDBObject::m_env, m_rec_time, IODConfig::m_writeStmt, and DateHandler::tmToDate().
00156 { 00157 this->checkConnection(); 00158 this->checkPrepare(); 00159 00160 00161 DateHandler dh(m_env, m_conn); 00162 if (m_rec_time.isNull()) { 00163 int very_old_time=0; 00164 m_rec_time = Tm(very_old_time); 00165 } 00166 00167 try { 00168 00169 m_writeStmt->setDate(3, dh.tmToDate(this->m_rec_time)); 00170 m_writeStmt->setInt(5, this->getRunNumber()); 00171 m_writeStmt->setString(6, this->getDescription()); 00172 00173 m_writeStmt->executeUpdate(); 00174 00175 00176 } catch (SQLException &e) { 00177 throw(runtime_error("ODCond2ConfInfo::writeDB(): "+e.getMessage())); 00178 } 00179 // Now get the ID 00180 if (!this->fetchID()) { 00181 throw(runtime_error("ODCond2ConfInfo::writeDB: Failed to write")); 00182 } 00183 00184 }
friend class EcalCondDBInterface [friend] |
Tm ODCond2ConfInfo::m_db_time [private] |
Definition at line 68 of file ODCond2ConfInfo.h.
Referenced by clear(), fetchData(), getDBDate(), and setDBDate().
std::string ODCond2ConfInfo::m_desc [private] |
Definition at line 67 of file ODCond2ConfInfo.h.
Referenced by clear(), getDescription(), and setDescription().
int ODCond2ConfInfo::m_ID [private] |
Definition at line 62 of file ODCond2ConfInfo.h.
Referenced by fetchID(), getId(), ODCond2ConfInfo(), prepareWrite(), and setId().
std::string ODCond2ConfInfo::m_loc [private] |
Definition at line 65 of file ODCond2ConfInfo.h.
Referenced by clear(), getLocation(), and setLocation().
int ODCond2ConfInfo::m_loc_id [private] |
Definition at line 69 of file ODCond2ConfInfo.h.
Referenced by clear(), fetchParents(), and prepareWrite().
Tm ODCond2ConfInfo::m_rec_time [private] |
Definition at line 64 of file ODCond2ConfInfo.h.
Referenced by clear(), fetchData(), getRecordDate(), setRecordDate(), and writeDB().
int ODCond2ConfInfo::m_run [private] |
Definition at line 66 of file ODCond2ConfInfo.h.
Referenced by clear(), getRunNumber(), and setRunNumber().
int ODCond2ConfInfo::m_typ_id [private] |
Definition at line 70 of file ODCond2ConfInfo.h.
Referenced by clear(), fetchID(), fetchParents(), and prepareWrite().
std::string ODCond2ConfInfo::m_type [private] |