![]() |
![]() |
#include <OnlineDB/EcalCondDB/interface/DCULVRBTempsDat.h>
Public Member Functions | |
DCULVRBTempsDat () | |
float | getT1 () const |
float | getT2 () const |
float | getT3 () const |
std::string | getTable () |
void | setT1 (float temp) |
void | setT2 (float temp) |
void | setT3 (float temp) |
~DCULVRBTempsDat () | |
Private Member Functions | |
void | fetchData (std::map< EcalLogicID, DCULVRBTempsDat > *fillVec, DCUIOV *iov) throw (std::runtime_error) |
void | prepareWrite () throw (std::runtime_error) |
void | writeArrayDB (const std::map< EcalLogicID, DCULVRBTempsDat > *data, DCUIOV *iov) throw (std::runtime_error) |
void | writeDB (const EcalLogicID *ecid, const DCULVRBTempsDat *item, DCUIOV *iov) throw (std::runtime_error) |
Private Attributes | |
float | m_t1 |
float | m_t2 |
float | m_t3 |
Friends | |
class | EcalCondDBInterface |
Definition at line 12 of file DCULVRBTempsDat.h.
DCULVRBTempsDat::DCULVRBTempsDat | ( | ) |
Definition at line 12 of file DCULVRBTempsDat.cc.
References IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, m_t1, m_t2, m_t3, IDataItem::m_writeStmt, and NULL.
00013 { 00014 m_env = NULL; 00015 m_conn = NULL; 00016 m_writeStmt = NULL; 00017 m_readStmt = NULL; 00018 00019 m_t1 = 0; 00020 m_t2 = 0; 00021 m_t3 = 0; 00022 }
DCULVRBTempsDat::~DCULVRBTempsDat | ( | ) |
void DCULVRBTempsDat::fetchData | ( | std::map< EcalLogicID, DCULVRBTempsDat > * | fillVec, | |
DCUIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 78 of file DCULVRBTempsDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, IDBObject::m_env, IDataItem::m_readStmt, p, setT1(), setT2(), and setT3().
00080 { 00081 this->checkConnection(); 00082 fillMap->clear(); 00083 00084 iov->setConnection(m_env, m_conn); 00085 int iovID = iov->fetchID(); 00086 if (!iovID) { 00087 // throw(runtime_error("DCULVRBTempsDat::writeDB: IOV not in DB")); 00088 return; 00089 } 00090 00091 try { 00092 00093 m_readStmt->setSQL("SELECT cv.name, cv.logic_id, cv.id1, cv.id2, cv.id3, cv.maps_to, " 00094 "d.t1, d.t2, d.t3 " 00095 "FROM channelview cv JOIN dcu_lvrb_temps_dat d " 00096 "ON cv.logic_id = d.logic_id AND cv.name = cv.maps_to " 00097 "WHERE d.iov_id = :iov_id"); 00098 m_readStmt->setInt(1, iovID); 00099 ResultSet* rset = m_readStmt->executeQuery(); 00100 00101 std::pair< EcalLogicID, DCULVRBTempsDat > p; 00102 DCULVRBTempsDat dat; 00103 while(rset->next()) { 00104 p.first = EcalLogicID( rset->getString(1), // name 00105 rset->getInt(2), // logic_id 00106 rset->getInt(3), // id1 00107 rset->getInt(4), // id2 00108 rset->getInt(5), // id3 00109 rset->getString(6)); // maps_to 00110 00111 dat.setT1( rset->getFloat(7) ); 00112 dat.setT2( rset->getFloat(8) ); 00113 dat.setT3( rset->getFloat(9) ); 00114 00115 p.second = dat; 00116 fillMap->insert(p); 00117 } 00118 } catch (SQLException &e) { 00119 throw(runtime_error("DCULVRBTempsDat::fetchData(): "+e.getMessage())); 00120 } 00121 }
float DCULVRBTempsDat::getT1 | ( | ) | const [inline] |
Definition at line 22 of file DCULVRBTempsDat.h.
References m_t1.
Referenced by writeArrayDB().
00022 { return m_t1; }
float DCULVRBTempsDat::getT2 | ( | ) | const [inline] |
Definition at line 25 of file DCULVRBTempsDat.h.
References m_t2.
Referenced by writeArrayDB().
00025 { return m_t2; }
float DCULVRBTempsDat::getT3 | ( | ) | const [inline] |
Definition at line 28 of file DCULVRBTempsDat.h.
References m_t3.
Referenced by writeArrayDB().
00028 { return m_t3; }
std::string DCULVRBTempsDat::getTable | ( | ) | [inline, virtual] |
void DCULVRBTempsDat::prepareWrite | ( | ) | throw (std::runtime_error) [private, virtual] |
Implements IDataItem.
Definition at line 32 of file DCULVRBTempsDat.cc.
References IDBObject::checkConnection(), e, IDBObject::m_conn, and IDataItem::m_writeStmt.
00034 { 00035 this->checkConnection(); 00036 00037 try { 00038 m_writeStmt = m_conn->createStatement(); 00039 m_writeStmt->setSQL("INSERT INTO dcu_lvrb_temps_dat (iov_id, logic_id, " 00040 "t1, t2, t3) " 00041 "VALUES (:iov_id, :logic_id, " 00042 ":3, :4, :5)"); 00043 } catch (SQLException &e) { 00044 throw(runtime_error("DCULVRBTempsDat::prepareWrite(): "+e.getMessage())); 00045 } 00046 }
void DCULVRBTempsDat::setT1 | ( | float | temp | ) | [inline] |
void DCULVRBTempsDat::setT2 | ( | float | temp | ) | [inline] |
void DCULVRBTempsDat::setT3 | ( | float | temp | ) | [inline] |
void DCULVRBTempsDat::writeArrayDB | ( | const std::map< EcalLogicID, DCULVRBTempsDat > * | data, | |
DCUIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 123 of file DCULVRBTempsDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), count, data, e, EcalLogicID::getLogicID(), getT1(), getT2(), getT3(), IDataItem::m_writeStmt, p, x, y, and z.
00125 { 00126 this->checkConnection(); 00127 this->checkPrepare(); 00128 00129 int iovID = iov->fetchID(); 00130 if (!iovID) { throw(runtime_error("DCULVRBTempsDat::writeArrayDB: IOV not in DB")); } 00131 00132 00133 int nrows=data->size(); 00134 int* ids= new int[nrows]; 00135 int* iovid_vec= new int[nrows]; 00136 float* xx= new float[nrows]; 00137 float* yy= new float[nrows]; 00138 float* zz= new float[nrows]; 00139 00140 ub2* ids_len= new ub2[nrows]; 00141 ub2* iov_len= new ub2[nrows]; 00142 ub2* x_len= new ub2[nrows]; 00143 ub2* y_len= new ub2[nrows]; 00144 ub2* z_len= new ub2[nrows]; 00145 00146 00147 const EcalLogicID* channel; 00148 const DCULVRBTempsDat* dataitem; 00149 int count=0; 00150 typedef map< EcalLogicID, DCULVRBTempsDat >::const_iterator CI; 00151 for (CI p = data->begin(); p != data->end(); ++p) { 00152 channel = &(p->first); 00153 int logicID = channel->getLogicID(); 00154 if (!logicID) { throw(runtime_error("DCULVRBTempsDat::writeArrayDB: Bad EcalLogicID")); } 00155 ids[count]=logicID; 00156 iovid_vec[count]=iovID; 00157 00158 dataitem = &(p->second); 00159 // dataIface.writeDB( channel, dataitem, iov); 00160 float x=dataitem->getT1(); 00161 float y=dataitem->getT2(); 00162 float z=dataitem->getT3(); 00163 00164 00165 00166 xx[count]=x; 00167 yy[count]=y; 00168 zz[count]=z; 00169 00170 00171 ids_len[count]=sizeof(ids[count]); 00172 iov_len[count]=sizeof(iovid_vec[count]); 00173 00174 x_len[count]=sizeof(xx[count]); 00175 y_len[count]=sizeof(yy[count]); 00176 z_len[count]=sizeof(zz[count]); 00177 00178 00179 count++; 00180 } 00181 00182 00183 try { 00184 m_writeStmt->setDataBuffer(1, (dvoid*)iovid_vec, OCCIINT, sizeof(iovid_vec[0]),iov_len); 00185 m_writeStmt->setDataBuffer(2, (dvoid*)ids, OCCIINT, sizeof(ids[0]), ids_len ); 00186 m_writeStmt->setDataBuffer(3, (dvoid*)xx, OCCIFLOAT , sizeof(xx[0]), x_len ); 00187 m_writeStmt->setDataBuffer(4, (dvoid*)yy, OCCIFLOAT , sizeof(yy[0]), y_len ); 00188 m_writeStmt->setDataBuffer(5, (dvoid*)zz, OCCIFLOAT , sizeof(zz[0]), z_len ); 00189 00190 00191 m_writeStmt->executeArrayUpdate(nrows); 00192 00193 delete [] ids; 00194 delete [] iovid_vec; 00195 delete [] xx; 00196 delete [] yy; 00197 delete [] zz; 00198 00199 delete [] ids_len; 00200 delete [] iov_len; 00201 delete [] x_len; 00202 delete [] y_len; 00203 delete [] z_len; 00204 00205 00206 } catch (SQLException &e) { 00207 throw(runtime_error("DCULVRBTempsDat::writeArrayDB(): "+e.getMessage())); 00208 } 00209 }
void DCULVRBTempsDat::writeDB | ( | const EcalLogicID * | ecid, | |
const DCULVRBTempsDat * | item, | |||
DCUIOV * | iov | |||
) | throw (std::runtime_error) [private] |
Definition at line 50 of file DCULVRBTempsDat.cc.
References IDBObject::checkConnection(), IDataItem::checkPrepare(), e, and IDataItem::m_writeStmt.
00052 { 00053 this->checkConnection(); 00054 this->checkPrepare(); 00055 00056 int iovID = iov->fetchID(); 00057 if (!iovID) { throw(runtime_error("DCULVRBTempsDat::writeDB: IOV not in DB")); } 00058 00059 int logicID = ecid->getLogicID(); 00060 if (!logicID) { throw(runtime_error("DCULVRBTempsDat::writeDB: Bad EcalLogicID")); } 00061 00062 try { 00063 m_writeStmt->setInt(1, iovID); 00064 m_writeStmt->setInt(2, logicID); 00065 00066 m_writeStmt->setFloat(3, item->getT1() ); 00067 m_writeStmt->setFloat(4, item->getT2() ); 00068 m_writeStmt->setFloat(5, item->getT3() ); 00069 00070 m_writeStmt->executeUpdate(); 00071 } catch (SQLException &e) { 00072 throw(runtime_error("DCULVRBTempsDat::writeDB(): "+e.getMessage())); 00073 } 00074 }
friend class EcalCondDBInterface [friend] |
float DCULVRBTempsDat::m_t1 [private] |
Definition at line 45 of file DCULVRBTempsDat.h.
Referenced by DCULVRBTempsDat(), getT1(), and setT1().
float DCULVRBTempsDat::m_t2 [private] |
Definition at line 46 of file DCULVRBTempsDat.h.
Referenced by DCULVRBTempsDat(), getT2(), and setT2().
float DCULVRBTempsDat::m_t3 [private] |
Definition at line 47 of file DCULVRBTempsDat.h.
Referenced by DCULVRBTempsDat(), getT3(), and setT3().