CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
LMFUnique Class Reference

#include <LMFUnique.h>

Inheritance diagram for LMFUnique:
IUniqueDBObject IDBObject LMFColor LMFDat LMFIOV LMFLmrSubIOV LMFPrimVers LMFRunIOV LMFRunTag LMFSeqDat LMFTrigType

Public Types

typedef oracle::occi::ResultSet ResultSet
 
typedef oracle::occi::Statement Statement
 

Public Member Functions

void attach (std::string name, LMFUnique *u)
 
void debug ()
 
virtual void dump () const
 
virtual void dump (int n) const
 
virtual bool exists ()
 
virtual std::list< std::unique_ptr< LMFUnique > > fetchAll () const noexcept(false)
 
int fetchID () noexcept(false) override
 
std::string getClassName ()
 
std::string getClassName () const
 
int getID () const
 
int getInt (std::string fieldname) const
 
std::string getString (std::string fieldname) const
 
virtual bool isValid () const
 
virtual bool isValid ()
 
 LMFUnique ()
 
 LMFUnique (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
 LMFUnique (EcalDBConnection *c)
 
void nodebug ()
 
virtual bool operator< (const LMFUnique &r)
 
virtual bool operator<= (const LMFUnique &r)
 
std::string sequencePostfix (const Tm &t)
 
void setByID (int id) noexcept(false) override
 
LMFUniquesetInt (std::string key, int value)
 
LMFUniquesetString (std::string key, std::string value)
 
void startProfiling ()
 
void stopProfiling ()
 
 ~LMFUnique () override
 
- Public Member Functions inherited from IDBObject
oracle::occi::Connection * getConn () const
 
oracle::occi::Environment * getEnv () const
 
void setConnection (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 
virtual ~IDBObject ()
 

Protected Member Functions

virtual void getParameters (ResultSet *rset)
 
virtual void setClassName (std::string s)
 
virtual int writeDB () noexcept(false)
 
virtual int writeForeignKeys () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 

Protected Attributes

bool _profiling
 
std::string m_className
 
char m_debug
 
std::map< std::string, LMFUnique * > m_foreignKeys
 
std::map< std::string, int > m_intFields
 
std::map< std::string, std::string > m_stringFields
 
- Protected Attributes inherited from IUniqueDBObject
int m_ID
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Private Member Functions

virtual LMFUniquecreateObject () const
 
virtual std::string fetchAllSql (Statement *stmt) const
 
virtual std::string fetchIdSql (Statement *stmt)
 
virtual void fetchParentIDs ()
 
virtual std::string setByIDSql (Statement *stmt, int id)
 
virtual std::string writeDBSql (Statement *stmt)
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 

Detailed Description

Definition at line 21 of file LMFUnique.h.

Member Typedef Documentation

◆ ResultSet

typedef oracle::occi::ResultSet LMFUnique::ResultSet

Definition at line 23 of file LMFUnique.h.

◆ Statement

typedef oracle::occi::Statement LMFUnique::Statement

Definition at line 24 of file LMFUnique.h.

Constructor & Destructor Documentation

◆ LMFUnique() [1/3]

LMFUnique::LMFUnique ( )
inline

Definition at line 27 of file LMFUnique.h.

References _profiling, IDBObject::m_conn, IDBObject::m_env, IUniqueDBObject::m_ID, nodebug(), and setClassName().

27  {
28  _profiling = false;
29  m_env = nullptr;
30  m_conn = nullptr;
31  m_ID = 0;
32  setClassName("LMFUnique");
33  nodebug();
34  }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void nodebug()
Definition: LMFUnique.h:75
bool _profiling
Definition: LMFUnique.h:107
virtual void setClassName(std::string s)
Definition: LMFUnique.h:97

◆ LMFUnique() [2/3]

LMFUnique::LMFUnique ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)
inline

Definition at line 35 of file LMFUnique.h.

References _profiling, getInfo::conn, web.browse_db::env, IUniqueDBObject::m_ID, nodebug(), setClassName(), and IDBObject::setConnection().

35  {
36  _profiling = false;
37  m_ID = 0;
38  setClassName("LMFUnique");
39  nodebug();
41  }
void nodebug()
Definition: LMFUnique.h:75
bool _profiling
Definition: LMFUnique.h:107
virtual void setClassName(std::string s)
Definition: LMFUnique.h:97
conn
Definition: getInfo.py:9
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ LMFUnique() [3/3]

LMFUnique::LMFUnique ( EcalDBConnection c)
inline

Definition at line 42 of file LMFUnique.h.

References _profiling, c, IUniqueDBObject::m_ID, nodebug(), setClassName(), and IDBObject::setConnection().

42  {
43  _profiling = false;
44  m_ID = 0;
45  setClassName("LMFUnique");
46  nodebug();
47  setConnection(c->getEnv(), c->getConn());
48  }
void nodebug()
Definition: LMFUnique.h:75
bool _profiling
Definition: LMFUnique.h:107
virtual void setClassName(std::string s)
Definition: LMFUnique.h:97
void setConnection(oracle::occi::Environment *env, oracle::occi::Connection *conn)
Definition: IDBObject.h:23

◆ ~LMFUnique()

LMFUnique::~LMFUnique ( )
override

Definition at line 7 of file LMFUnique.cc.

7 {}

Member Function Documentation

◆ attach()

void LMFUnique::attach ( std::string  name,
LMFUnique u 
)

Definition at line 48 of file LMFUnique.cc.

References mps_fire::i, and Skims_PA_cff::name.

Referenced by LMFCorrCoefDatComponent::setLMFLmrSubIOV(), LMFDat::setLMFRunIOV(), and LMFRunIOV::setSequence().

48  {
49  std::map<std::string, LMFUnique*>::const_iterator i = m_foreignKeys.find(name);
50  if (i != m_foreignKeys.end()) {
51  if (i->second != u) {
52  m_foreignKeys[name] = u;
53  m_ID = 0;
54  }
55  } else {
56  m_foreignKeys[name] = u;
57  m_ID = 0;
58  }
59 }
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106

◆ createObject()

LMFUnique * LMFUnique::createObject ( ) const
privatevirtual

Reimplemented in LMFColor, LMFRunTag, LMFIOV, LMFPrimVers, LMFTrigType, LMFCorrVers, and LMFSeqVers.

Definition at line 173 of file LMFUnique.cc.

173  {
174  /* this method should return a pointer to a newly created object */
175  return nullptr;
176 }

◆ debug()

void LMFUnique::debug ( )
inline

Definition at line 74 of file LMFUnique.h.

References m_debug.

Referenced by LMFCorrCoefDat::fetchBetween(), LMFPnPrimDat::LMFPnPrimDat(), and LMFDat::writeDB().

74 { m_debug = 1; }
char m_debug
Definition: LMFUnique.h:100

◆ dump() [1/2]

void LMFUnique::dump ( void  ) const
virtual

Reimplemented in LMFDat, LMFRunIOV, and LMFIOV.

Definition at line 104 of file LMFUnique.cc.

References submitPVValidationJobs::dump.

Referenced by LMFRunIOV::dump(), LMFDat::dump(), LMFCorrCoefDat::fetch(), and LMFSeqDat::writeDBSql().

104 { dump(0); }
virtual void dump() const
Definition: LMFUnique.cc:104

◆ dump() [2/2]

void LMFUnique::dump ( int  n) const
virtual

Reimplemented in LMFDat.

Definition at line 106 of file LMFUnique.cc.

References gather_cfg::cout, cuy::ii, sistrip::SpyUtilities::isValid(), crabWrapper::key, dqmiodumpmetadata::n, and AlCaHLTBitMon_QueryRunRegistry::string.

106  {
107  /*
108  This method is used to dump the content of an object
109  Indent data if the object is contained inside another object
110  */
111  std::string m_indent = "";
112  std::string m_trail = "";
113  m_trail.resize(70 - 31 - n * 2, '#');
114  m_indent.resize(n * 2, ' ');
115  m_indent += "|";
116  // start of object
117  cout << m_indent << "#################" << setw(15) << m_className << " " << m_trail << endl;
118  cout << m_indent << "Address: " << this << endl;
119  cout << m_indent << "Connection params : " << m_env << ", " << m_conn << endl;
120  // object ID in the DB
121  cout << m_indent << "ID" << setw(18) << ": " << m_ID;
122  if (m_ID == 0) {
123  cout << " *** NULL ID ***";
124  }
125  if (!isValid()) {
126  cout << " INVALID ***";
127  }
128  cout << endl;
129  // iterate over string fields
130  std::map<std::string, std::string>::const_iterator is = m_stringFields.begin();
131  std::map<std::string, std::string>::const_iterator es = m_stringFields.end();
132  while (is != es) {
133  std::string key = is->first;
134  cout << m_indent << key << setw(20 - key.length()) << ": " << is->second << endl;
135  is++;
136  }
137  // iterate over integer fields
138  std::map<std::string, int>::const_iterator ii = m_intFields.begin();
139  std::map<std::string, int>::const_iterator ei = m_intFields.end();
140  while (ii != ei) {
141  std::string key = ii->first;
142  cout << m_indent << key << setw(20 - key.length()) << ": " << ii->second << endl;
143  ii++;
144  }
145  cout << m_indent << "#################" << setw(15) << m_className << " " << m_trail << endl;
146  // iterate over foreign keys
147  std::map<std::string, LMFUnique*>::const_iterator ik = m_foreignKeys.begin();
148  std::map<std::string, LMFUnique*>::const_iterator ek = m_foreignKeys.end();
149  m_indent.clear();
150  m_indent.resize((n + 1) * 2, ' ');
151  while (ik != ek) {
152  cout << m_indent << "Foreign Key: " << ik->first << endl;
153  ik->second->dump(n + 1);
154  ik++;
155  }
156 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
virtual bool isValid() const
Definition: LMFUnique.h:52
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:102
ii
Definition: cuy.py:589
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:104

◆ exists()

bool LMFUnique::exists ( )
virtual

Definition at line 158 of file LMFUnique.cc.

References runTheMatrix::ret.

158  {
159  fetchID();
160  bool ret = false;
161  if (m_ID > 0) {
162  ret = true;
163  }
164  return ret;
165 }
ret
prodAgent to be discontinued
int fetchID() noexcept(false) override
Definition: LMFUnique.cc:197

◆ fetchAll()

std::list< std::unique_ptr< LMFUnique > > LMFUnique::fetchAll ( ) const
virtualnoexcept

Definition at line 61 of file LMFUnique.cc.

References gather_cfg::cout, createObject(), MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, cmsLHEtoEOSManager::l, EcalTangentSkim_cfg::o, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LMFDefFabric::initialize(), and LMFColor::isValid().

61  {
62  /*
63  Returns a list of pointers to DB objects
64  */
65  std::list<std::unique_ptr<LMFUnique>> l;
66  this->checkConnection();
67 
68  try {
69  Statement* stmt = m_conn->createStatement();
70  std::string sql = fetchAllSql(stmt);
71  if (!sql.empty()) {
72  if (m_debug) {
73  cout << m_className + ": Query " + sql << endl;
74  }
75  ResultSet* rset = stmt->executeQuery();
76  while (rset->next() != 0) {
78  if (m_debug) {
79  o->debug();
80  }
81  if (o != nullptr) {
82  o->setByID(rset->getInt(1));
83  if (m_debug) {
84  o->dump();
85  }
86  try {
87  l.emplace_back(o);
88  } catch (std::exception& e) {
89  throw(std::runtime_error(m_className + "::fetchAll: " + e.what()));
90  }
91  }
92  }
93  }
94  m_conn->terminateStatement(stmt);
95  } catch (SQLException& e) {
96  throw(std::runtime_error(m_className + "::fetchAll: " + e.getMessage()));
97  }
98  if (m_debug) {
99  cout << m_className << ": list size = " << l.size() << endl;
100  }
101  return l;
102 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
virtual LMFUnique * createObject() const
Definition: LMFUnique.cc:173
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
virtual std::string fetchAllSql(Statement *stmt) const
Definition: LMFUnique.cc:167
char m_debug
Definition: LMFUnique.h:100

◆ fetchAllSql()

std::string LMFUnique::fetchAllSql ( Statement stmt) const
privatevirtual

Reimplemented in LMFColor, LMFRunTag, LMFPrimVers, LMFTrigType, LMFCorrVers, and LMFSeqVers.

Definition at line 167 of file LMFUnique.cc.

167  {
168  /* this method should setup a Statement to select the unique IDs of the
169  objects to return */
170  return "";
171 }

◆ fetchID()

int LMFUnique::fetchID ( )
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 197 of file LMFUnique.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, mps_fire::i, dqmiodumpmetadata::n, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LMFDat::getLMFRunIOVID(), LMFColor::setColor(), LMFColor::setName(), and LMFTrigType::setName().

197  {
198  /*
199  This method fetch the ID of the object from the database according
200  to the given specifications.
201 
202  It is assumed that there is only one object in the database with the
203  given specifications. In case more than one object can be retrieved
204  this method throws an exception.
205 
206  Since not all the specifications can define completely the object
207  itself, at the end, we setup the object based on its ID.
208  */
209  // Return tag from memory if available
210  if (m_ID) {
211  return m_ID;
212  }
213 
214  this->checkConnection();
215 
216  // fetch this ID
217  try {
218  Statement* stmt = m_conn->createStatement();
219  // prepare the sql query
220  std::string sql = fetchIdSql(stmt);
221  if (!sql.empty()) {
222  if (m_debug) {
223  cout << m_className + ": Query " + sql << endl;
224  }
225 
226  ResultSet* rset = stmt->executeQuery();
227  if (rset->next() != 0) {
228  m_ID = rset->getInt(1);
229  } else {
230  m_ID = 0;
231  }
232  if (m_debug) {
233  cout << m_className + ": ID set to " << m_ID << endl;
234  }
235  int n = rset->getNumArrayRows();
236  if (m_debug) {
237  cout << m_className + ": Returned " << n << " rows" << endl;
238  }
239  if (n > 1) {
240  throw(std::runtime_error(m_className + "::fetchID: too many rows returned " + "executing query " + sql));
241  m_ID = 0;
242  }
243  }
244  m_conn->terminateStatement(stmt);
245  } catch (SQLException& e) {
246  throw(std::runtime_error(m_className + "::fetchID: " + e.getMessage()));
247  }
248  // given the ID of this object setup it completely
249  if (m_ID > 0) {
250  setByID(m_ID);
251  }
252  // if foreignKeys are there, set these objects too
253  map<string, LMFUnique*>::iterator i = m_foreignKeys.begin();
254  map<string, LMFUnique*>::iterator e = m_foreignKeys.end();
255  while (i != e) {
256  if (i->second->getID() == 0) {
257  i->second->fetchID();
258  }
259  i++;
260  }
261  if (m_debug) {
262  cout << m_className << ": fetchID:: returning " << m_ID << endl;
263  }
264  return m_ID;
265 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106
void setByID(int id) noexcept(false) override
Definition: LMFUnique.cc:267
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
virtual std::string fetchIdSql(Statement *stmt)
Definition: LMFUnique.h:86
char m_debug
Definition: LMFUnique.h:100

◆ fetchIdSql()

virtual std::string LMFUnique::fetchIdSql ( Statement stmt)
inlineprivatevirtual

Reimplemented in LMFLmrSubIOV, LMFSeqDat, LMFRunIOV, LMFColor, LMFRunTag, LMFIOV, LMFPrimVers, LMFTrigType, LMFCorrVers, and LMFSeqVers.

Definition at line 86 of file LMFUnique.h.

86 { return ""; }

◆ fetchParentIDs()

virtual void LMFUnique::fetchParentIDs ( )
inlineprivatevirtual

Reimplemented in LMFSeqDat, and LMFIOV.

Definition at line 90 of file LMFUnique.h.

90 {}

◆ getClassName() [1/2]

std::string LMFUnique::getClassName ( )
inline

Definition at line 60 of file LMFUnique.h.

References m_className.

60 { return m_className; }
std::string m_className
Definition: LMFUnique.h:99

◆ getClassName() [2/2]

std::string LMFUnique::getClassName ( ) const
inline

Definition at line 61 of file LMFUnique.h.

References m_className.

61 { return m_className; }
std::string m_className
Definition: LMFUnique.h:99

◆ getID()

int LMFUnique::getID ( ) const
inline

◆ getInt()

int LMFUnique::getInt ( std::string  fieldname) const

◆ getParameters()

virtual void LMFUnique::getParameters ( ResultSet rset)
inlineprotectedvirtual

Reimplemented in LMFLmrSubIOV, LMFSeqDat, LMFRunIOV, LMFColor, LMFRunTag, LMFIOV, LMFPrimVers, LMFTrigType, LMFCorrVers, and LMFSeqVers.

Definition at line 94 of file LMFUnique.h.

94 {}

◆ getString()

std::string LMFUnique::getString ( std::string  fieldname) const

◆ isValid() [1/2]

virtual bool LMFUnique::isValid ( void  ) const
inlinevirtual

Reimplemented in LMFSeqDat.

Definition at line 52 of file LMFUnique.h.

Referenced by ntupleDataFormat._Object::_checkIsValid(), and core.AutoHandle.AutoHandle::ReallyLoad().

52 { return true; }

◆ isValid() [2/2]

virtual bool LMFUnique::isValid ( void  )
inlinevirtual

◆ nodebug()

void LMFUnique::nodebug ( )
inline

Definition at line 75 of file LMFUnique.h.

References m_debug.

Referenced by LMFUnique().

75 { m_debug = 0; }
char m_debug
Definition: LMFUnique.h:100

◆ operator<()

virtual bool LMFUnique::operator< ( const LMFUnique r)
inlinevirtual

Definition at line 79 of file LMFUnique.h.

References IUniqueDBObject::m_ID, and alignCSCRings::r.

79 { return (m_ID < r.m_ID); }

◆ operator<=()

virtual bool LMFUnique::operator<= ( const LMFUnique r)
inlinevirtual

Definition at line 80 of file LMFUnique.h.

References IUniqueDBObject::m_ID, and alignCSCRings::r.

80 { return (m_ID <= r.m_ID); }

◆ sequencePostfix()

std::string LMFUnique::sequencePostfix ( const Tm t)

◆ setByID()

void LMFUnique::setByID ( int  id)
overridevirtualnoexcept

Implements IUniqueDBObject.

Definition at line 267 of file LMFUnique.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, triggerObjects_cff::id, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LMFCorrCoefDat::fetch(), LMFRunIOV::fetchBySequence(), LMFRunIOV::getLMFColor(), LMFLmrSubIOV::getLMFIOV(), LMFCorrCoefDatComponent::getLMFLmrSubIOV(), LMFDat::getLMFRunIOV(), LMFRunIOV::getLMFRunTag(), and LMFRunIOV::getSequence().

267  {
268  /*
269  Given the ID of an object setup it
270  */
271  if (m_debug) {
272  cout << m_className << ": Setting this object as ID = " << id << endl;
273  }
274  this->checkConnection();
275  try {
276  Statement* stmt = m_conn->createStatement();
277  std::string sql = setByIDSql(stmt, id);
278  if (sql.empty()) {
279  throw(std::runtime_error(m_className + "::setByID: [empty sql])"));
280  }
281  if (m_debug) {
282  cout << m_className + ": " + sql << endl;
283  }
284 
285  ResultSet* rset = stmt->executeQuery();
286  if (rset->next() != 0) {
287  // setup the concrete object
288  getParameters(rset);
289  m_ID = id;
290  if (m_debug) {
291  cout << m_className + ": Setting done. ID set to " << m_ID << endl;
292  }
293  } else {
294  throw(std::runtime_error(m_className + "::setByID: Given id is not in the database"));
295  }
296  m_conn->terminateStatement(stmt);
297  } catch (SQLException& e) {
298  throw(std::runtime_error(m_className + "::setByID: " + e.getMessage()));
299  }
300 }
std::string m_className
Definition: LMFUnique.h:99
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:23
virtual std::string setByIDSql(Statement *stmt, int id)
Definition: LMFUnique.h:88
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
char m_debug
Definition: LMFUnique.h:100
virtual void getParameters(ResultSet *rset)
Definition: LMFUnique.h:94

◆ setByIDSql()

virtual std::string LMFUnique::setByIDSql ( Statement stmt,
int  id 
)
inlineprivatevirtual

Reimplemented in LMFLmrSubIOV, LMFSeqDat, LMFRunIOV, LMFColor, LMFRunTag, LMFIOV, LMFPrimVers, LMFTrigType, LMFCorrVers, and LMFSeqVers.

Definition at line 88 of file LMFUnique.h.

88 { return ""; }

◆ setClassName()

virtual void LMFUnique::setClassName ( std::string  s)
inlineprotectedvirtual

◆ setInt()

LMFUnique & LMFUnique::setInt ( std::string  key,
int  value 
)

Definition at line 31 of file LMFUnique.cc.

References mps_fire::i, crabWrapper::key, and relativeConstraints::value.

Referenced by LMFDat::getLMFRunIOVID(), LMFRunTag::getParameters(), LMFColor::getParameters(), LMFSeqDat::getParameters(), LMFColor::setColor(), LMFRunIOV::setColor(), LMFRunIOV::setColorIndex(), LMFCorrCoefDatComponent::setLMFLmrSubIOV(), LMFDat::setLMFRunIOV(), LMFRunIOV::setLMFRunTag(), LMFRunIOV::setLmr(), LMFColor::setName(), LMFRunIOV::setSequence(), LMFSeqDat::setSequenceNumber(), LMFRunIOV::setTriggerType(), LMFRunTag::setVersion(), LMFSeqDat::setVmax(), and LMFSeqDat::setVmin().

31  {
32  // check if this key exists
33  std::map<std::string, int>::const_iterator i = m_intFields.find(key);
34  if (i != m_intFields.end()) {
35  // the key exist: check if it changed: reset the ID of the object
36  if (i->second != value) {
38  m_ID = 0;
39  }
40  } else {
41  // create this key and reset the ID of the object
43  m_ID = 0;
44  }
45  return *this;
46 }
Definition: value.py:1
std::map< std::string, int > m_intFields
Definition: LMFUnique.h:104

◆ setString()

LMFUnique & LMFUnique::setString ( std::string  key,
std::string  value 
)

Definition at line 14 of file LMFUnique.cc.

References mps_fire::i, crabWrapper::key, and relativeConstraints::value.

Referenced by LMFCorrVers::getParameters(), LMFSeqVers::getParameters(), LMFTrigType::getParameters(), LMFPrimVers::getParameters(), LMFRunTag::getParameters(), LMFColor::getParameters(), LMFSeqDat::getParameters(), LMFCorrVers::LMFCorrVers(), LMFPrimVers::LMFPrimVers(), LMFSeqVers::LMFSeqVers(), LMFColor::setColor(), LMFPrimVers::setDescription(), LMFRunTag::setGeneralTag(), LMFColor::setName(), LMFTrigType::setName(), LMFTrigType::setNames(), LMFSeqDat::setSequenceStart(), LMFSeqDat::setSequenceStop(), LMFRunIOV::setSubRunEnd(), LMFRunIOV::setSubRunStart(), and LMFRunIOV::setSubRunType().

14  {
15  // check if this key exists
16  std::map<std::string, std::string>::const_iterator i = m_stringFields.find(key);
17  if (i != m_stringFields.end()) {
18  // the key exist: check if it changed: reset the ID of the object
19  if (i->second != value) {
21  m_ID = 0;
22  }
23  } else {
24  // create this key and reset the ID of the object
26  m_ID = 0;
27  }
28  return *this;
29 }
std::map< std::string, std::string > m_stringFields
Definition: LMFUnique.h:102
Definition: value.py:1

◆ startProfiling()

void LMFUnique::startProfiling ( )
inline

Definition at line 81 of file LMFUnique.h.

References _profiling.

81 { _profiling = true; }
bool _profiling
Definition: LMFUnique.h:107

◆ stopProfiling()

void LMFUnique::stopProfiling ( )
inline

Definition at line 82 of file LMFUnique.h.

References _profiling.

82 { _profiling = false; }
bool _profiling
Definition: LMFUnique.h:107

◆ writeDB()

int LMFUnique::writeDB ( )
protectedvirtualnoexcept

Reimplemented in LMFDat, LMFColoredTable, and LMFCorrCoefDatComponent.

Definition at line 316 of file LMFUnique.cc.

References gather_cfg::cout, debug, submitPVValidationJobs::dump, MillePedeFileConverter_cfg::e, mps_fire::end, and AlCaHLTBitMon_QueryRunRegistry::string.

316  {
317  clock_t start = 0;
318  clock_t end = 0;
319  if (_profiling) {
320  start = clock();
321  }
322  // write the associated objects first (foreign keys must exist before use)
324  // see if this data is already in the DB
325  if (!(this->fetchID())) {
326  // check the connectioin
327  this->checkConnection();
328 
329  // write new tag to the DB
330  std::string sql = "";
331  try {
332  Statement* stmt = m_conn->createStatement();
333 
334  sql = writeDBSql(stmt);
335  if (!sql.empty()) {
336  if (m_debug) {
337  cout << m_className + ": " + sql << endl;
338  }
339  stmt->executeUpdate();
340  }
341  m_conn->commit();
342  m_conn->terminateStatement(stmt);
343  } catch (SQLException& e) {
344  debug();
345  dump();
346  throw(std::runtime_error(m_className + "::writeDB: " + e.getMessage() + " while executing query " + sql));
347  }
348  // now get the id
349  if (this->fetchID() == 0) {
350  throw(std::runtime_error(m_className + "::writeDB: Failed to write"));
351  }
352  }
353  if (_profiling) {
354  end = clock();
355  if (m_debug) {
356  std::cout << m_className << ":: Spent time in writeDB:" << ((double)(end - start)) / CLOCKS_PER_SEC << " s"
357  << endl;
358  }
359  }
360  return m_ID;
361 }
std::string m_className
Definition: LMFUnique.h:99
Definition: start.py:1
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
bool _profiling
Definition: LMFUnique.h:107
virtual std::string writeDBSql(Statement *stmt)
Definition: LMFUnique.h:85
oracle::occi::Statement Statement
Definition: LMFUnique.h:24
virtual void dump() const
Definition: LMFUnique.cc:104
virtual int writeForeignKeys() noexcept(false)
Definition: LMFUnique.cc:302
char m_debug
Definition: LMFUnique.h:100
void debug()
Definition: LMFUnique.h:74
int fetchID() noexcept(false) override
Definition: LMFUnique.cc:197

◆ writeDBSql()

virtual std::string LMFUnique::writeDBSql ( Statement stmt)
inlineprivatevirtual

Reimplemented in LMFLmrSubIOV, LMFSeqDat, LMFRunIOV, and LMFIOV.

Definition at line 85 of file LMFUnique.h.

85 { return ""; }

◆ writeForeignKeys()

int LMFUnique::writeForeignKeys ( )
protectedvirtualnoexcept

Definition at line 302 of file LMFUnique.cc.

References submitPVResolutionJobs::count, MillePedeFileConverter_cfg::e, and mps_fire::i.

Referenced by LMFDat::writeDB().

302  {
303  std::map<std::string, LMFUnique*>::const_iterator i = m_foreignKeys.begin();
304  std::map<std::string, LMFUnique*>::const_iterator e = m_foreignKeys.end();
305  int count = 0;
306  while (i != e) {
307  if (i->second->getID() == 0) {
308  i->second->writeDB();
309  count++;
310  }
311  i++;
312  }
313  return count;
314 }
std::map< std::string, LMFUnique * > m_foreignKeys
Definition: LMFUnique.h:106

Friends And Related Function Documentation

◆ EcalCondDBInterface

friend class EcalCondDBInterface
friend

Definition at line 25 of file LMFUnique.h.

Member Data Documentation

◆ _profiling

bool LMFUnique::_profiling
protected

Definition at line 107 of file LMFUnique.h.

Referenced by LMFUnique(), startProfiling(), and stopProfiling().

◆ m_className

std::string LMFUnique::m_className
protected

◆ m_debug

char LMFUnique::m_debug
protected

◆ m_foreignKeys

std::map<std::string, LMFUnique *> LMFUnique::m_foreignKeys
protected

Definition at line 106 of file LMFUnique.h.

Referenced by LMFDat::getLMFRunIOVID(), LMFDat::isValid(), and LMFDat::writeDB().

◆ m_intFields

std::map<std::string, int> LMFUnique::m_intFields
protected

◆ m_stringFields

std::map<std::string, std::string> LMFUnique::m_stringFields
protected