Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:02

0001 #include "OnlineDB/EcalCondDB/interface/LMFRunTag.h"
0002 
0003 using namespace std;
0004 using namespace oracle::occi;
0005 
0006 LMFRunTag::LMFRunTag() : LMFUnique() {
0007   setClassName("LMFRunTag");
0008   m_stringFields["gen_tag"] = "default";
0009   m_intFields["version"] = 1;
0010 }
0011 
0012 LMFRunTag::LMFRunTag(oracle::occi::Environment *env, oracle::occi::Connection *conn) : LMFUnique(env, conn) {
0013   setClassName("LMFRunTag");
0014   m_stringFields["gen_tag"] = "default";
0015   m_intFields["version"] = 1;
0016 }
0017 
0018 LMFRunTag::LMFRunTag(EcalDBConnection *c) : LMFUnique(c) {
0019   setClassName("LMFRunTag");
0020   m_stringFields["gen_tag"] = "default";
0021   m_intFields["version"] = 1;
0022 }
0023 
0024 LMFRunTag::~LMFRunTag() {}
0025 
0026 string LMFRunTag::getGeneralTag() const { return getString("gen_tag"); }
0027 
0028 LMFRunTag &LMFRunTag::setGeneralTag(const string &genTag) {
0029   setString("gen_tag", genTag);
0030   return *this;
0031 }
0032 
0033 LMFRunTag &LMFRunTag::setVersion(int v) {
0034   setInt("version", v);
0035   return *this;
0036 }
0037 
0038 int LMFRunTag::getVersion() const { return getInt("version"); }
0039 
0040 std::string LMFRunTag::fetchIdSql(Statement *stmt) {
0041   std::string sql =
0042       "SELECT tag_id FROM CMS_ECAL_LASER_COND.lmf_run_tag WHERE "
0043       "gen_tag    = :1 AND version = :2";
0044   stmt->setSQL(sql);
0045   stmt->setString(1, getGeneralTag());
0046   stmt->setInt(2, getVersion());
0047   return sql;
0048 }
0049 
0050 std::string LMFRunTag::setByIDSql(Statement *stmt, int id) {
0051   std::string sql =
0052       "SELECT gen_tag, version FROM "
0053       "CMS_ECAL_LASER_COND.lmf_run_tag "
0054       "WHERE tag_id = :1";
0055   stmt->setSQL(sql);
0056   stmt->setInt(1, id);
0057   return sql;
0058 }
0059 
0060 void LMFRunTag::getParameters(ResultSet *rset) {
0061   setString("gen_tag", rset->getString(1));
0062   setInt("version", rset->getInt(2));
0063 }
0064 
0065 LMFUnique *LMFRunTag::createObject() const {
0066   LMFRunTag *t = new LMFRunTag;
0067   t->setConnection(m_env, m_conn);
0068   return t;
0069 }
0070 
0071 std::string LMFRunTag::fetchAllSql(Statement *stmt) const {
0072   std::string sql = "SELECT TAG_ID FROM CMS_ECAL_LASER_COND.LMF_RUN_TAG";
0073   stmt->setSQL(sql);
0074   return sql;
0075 }
0076 
0077 bool LMFRunTag::isValid() {
0078   bool ret = true;
0079   if (getVersion() <= 0) {
0080     ret = false;
0081   }
0082   if (getGeneralTag().length() <= 0) {
0083     ret = false;
0084   }
0085   return ret;
0086 }