CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LMFColor.cc
Go to the documentation of this file.
1 #include <stdexcept>
3 
5 
6 using namespace std;
7 using namespace oracle::occi;
8 
10 {
11  m_ID = 0;
12  m_className = "LMFColor";
13  m_stringFields["sname"] = "none";
14  m_stringFields["lname"] = "none";
15  m_intFields["color"] = -1;
16 }
17 
18 LMFColor::LMFColor(oracle::occi::Environment* env,
19  oracle::occi::Connection* conn) : LMFUnique(env, conn)
20 {
21  m_ID = 0;
22  m_className = "LMFColor";
23  m_stringFields["sname"] = "none";
24  m_stringFields["lname"] = "none";
25  m_intFields["color"] = -1;
26 }
27 
29 {
30  m_ID = 0;
31  m_className = "LMFColor";
32  m_stringFields["sname"] = "none";
33  m_stringFields["lname"] = "none";
34  m_intFields["color"] = -1;
35 }
36 
38 {
39  m_ID = 0;
40  m_className = "LMFColor";
41  m_stringFields["sname"] = "none";
42  m_stringFields["lname"] = "none";
43  m_intFields["color"] = -1;
44  setName(color);
45 }
46 
48 {
49 }
50 
51 std::string LMFColor::fetchAllSql(Statement *stmt) const {
52  std::string sql = "SELECT COLOR_ID FROM "
53  "CMS_ECAL_LASER_COND.LMF_COLOR_DEF";
54  stmt->setSQL(sql);
55  return sql;
56 }
57 
59  LMFColor * n = new LMFColor;
61  return n;
62 }
63 
64 std::string LMFColor::fetchIdSql(Statement *stmt) {
65  // the query depends on the object status
66  std::string sql;
67  if ((getInt("color") >= 0) && (getString("sname") != "none")) {
68  sql = "SELECT COLOR_ID FROM CMS_ECAL_LASER_COND.LMF_COLOR_DEF "
69  "WHERE SNAME = :1 AND COLOR_INDEX = :2";
70  stmt->setSQL(sql);
71  stmt->setString(1, getShortName());
72  stmt->setInt(2, getColorIndex());
73  } else if (getInt("color") >= 0) {
74  sql = "SELECT COLOR_ID FROM CMS_ECAL_LASER_COND.LMF_COLOR_DEF "
75  "WHERE COLOR_INDEX = :1";
76  stmt->setSQL(sql);
77  stmt->setInt(1, getColorIndex());
78  } else if (getString("sname") != "") {
79  sql = "SELECT COLOR_ID FROM CMS_ECAL_LASER_COND.LMF_COLOR_DEF "
80  "WHERE SNAME = :1";
81  stmt->setSQL(sql);
82  stmt->setString(1, getShortName());
83  }
84  return sql;
85 }
86 
87 std::string LMFColor::setByIDSql(Statement *stmt, int id) {
88  std::string sql = "SELECT COLOR_INDEX, SNAME, LNAME "
89  "FROM CMS_ECAL_LASER_COND.LMF_COLOR_DEF WHERE COLOR_ID = :1";
90  stmt->setSQL(sql);
91  stmt->setInt(1, id);
92  return sql;
93 }
94 
96  setInt("color", rset->getInt(1));
97  setString("sname", rset->getString(2));
98  setString("lname", rset->getString(3));
99 }
100 
102  boost::ptr_list<LMFUnique> listOfValidColors = fetchAll();
103  boost::ptr_list<LMFUnique>::const_iterator i = listOfValidColors.begin();
104  boost::ptr_list<LMFUnique>::const_iterator e = listOfValidColors.end();
105  bool ret = false;
106  while (i != e) {
107  LMFColor *c = (LMFColor*)&(*i);
108  if (c->getShortName() == getShortName()) {
109  ret = true;
110  i = e;
111  }
112  i++;
113  }
114  return ret;
115 }
std::string m_className
Definition: LMFUnique.h:99
int i
Definition: DBlmapReader.cc:9
std::string fetchAllSql(Statement *stmt) const
Definition: LMFColor.cc:51
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
std::string fetchIdSql(Statement *stmt)
Definition: LMFColor.cc:64
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
LMFColor & setName(const std::string &s="blue")
Definition: LMFColor.h:23
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:19
void getParameters(ResultSet *rset)
Definition: LMFColor.cc:95
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:203
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:102
std::string setByIDSql(Statement *stmt, int id)
Definition: LMFColor.cc:87
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
std::string getShortName() const
Definition: LMFColor.h:44
LMFUnique & setString(std::string key, std::string value)
Definition: LMFUnique.cc:15
virtual boost::ptr_list< LMFUnique > fetchAll() const
Definition: LMFUnique.cc:64
bool isValid()
Definition: LMFColor.cc:101
LMFColor()
Definition: LMFColor.cc:9
int getColorIndex() const
Definition: LMFColor.h:46
std::string getString(std::string fieldname) const
Definition: LMFUnique.cc:194
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23
~LMFColor()
Definition: LMFColor.cc:47
tuple conn
Definition: results_mgr.py:53
LMFUnique * createObject() const
Definition: LMFColor.cc:58
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:104