CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODTTCciConfig Class Reference

#include <ODTTCciConfig.h>

Inheritance diagram for ODTTCciConfig:
IODConfig IDBObject

Public Member Functions

std::string getConfigurationScript () const
 
std::string getConfigurationScriptParams () const
 
int getId () const
 
unsigned int getSize () const
 
std::string getTable () override
 
std::string getTrgMode () const
 
int getTrgSleep () const
 
unsigned char * getTTCciClob () const
 
std::string getTTCciConfigurationFile () const
 
 ODTTCciConfig ()
 
void setConfigurationScript (std::string x)
 
void setConfigurationScriptParams (std::string x)
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setSize (unsigned int id)
 
void setTrgMode (std::string x)
 
void setTrgSleep (int id)
 
void setTTCciClob (unsigned char *x)
 
void setTTCciConfigurationFile (std::string x)
 
 ~ODTTCciConfig () override
 
- Public Member Functions inherited from IODConfig
std::string getConfigTag ()
 
void setConfigTag (std::string x)
 
- 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 ()
 

Private Member Functions

void clear ()
 
void fetchData (ODTTCciConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

std::string m_configuration_script
 
std::string m_configuration_script_params
 
int m_ID
 
int m_size
 
std::string m_trg_mode
 
int m_trg_sleep
 
unsigned char * m_ttcci_clob
 
std::string m_ttcci_file
 

Friends

class EcalCondDBInterface
 

Additional Inherited Members

- Public Types inherited from IODConfig
typedef oracle::occi::Clob Clob
 
typedef oracle::occi::SQLException SQLException
 
typedef oracle::occi::Statement Statement
 
typedef oracle::occi::Stream Stream
 
- Public Attributes inherited from IODConfig
std::string m_config_tag
 
- Static Public Attributes inherited from IDBObject
static int const ECALDB_NROWS = 1024
 
- Protected Member Functions inherited from IODConfig
void checkPrepare () noexcept(false)
 
void createReadStatement () noexcept(false)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
 
unsigned char * readClob (Clob &clob, int size) noexcept(false)
 
void setPrefetchRowCount (int ncount) noexcept(false)
 
void terminateReadStatement () noexcept(false)
 
void terminateWriteStatement () noexcept(false)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const noexcept(false)
 
- Protected Attributes inherited from IODConfig
Statementm_readStmt
 
Statementm_writeStmt
 
- Protected Attributes inherited from IDBObject
oracle::occi::Connection * m_conn
 
oracle::occi::Environment * m_env
 

Detailed Description

Definition at line 15 of file ODTTCciConfig.h.

Constructor & Destructor Documentation

ODTTCciConfig::ODTTCciConfig ( )

Definition at line 15 of file ODTTCciConfig.cc.

References clear().

15  {
16  m_env = nullptr;
17  m_conn = nullptr;
18  m_writeStmt = nullptr;
19  m_readStmt = nullptr;
20  m_config_tag = "";
23  m_ID = 0;
24  clear();
25  m_size = 0;
26 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:33
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
std::string m_config_tag
Definition: IODConfig.h:25
std::string m_configuration_script
Definition: ODTTCciConfig.h:59
std::string m_configuration_script_params
Definition: ODTTCciConfig.h:60
Statement * m_readStmt
Definition: IODConfig.h:34
ODTTCciConfig::~ODTTCciConfig ( )
override

Definition at line 37 of file ODTTCciConfig.cc.

37 {}

Member Function Documentation

void ODTTCciConfig::clear ( void  )
private

Definition at line 28 of file ODTTCciConfig.cc.

References gather_cfg::cout.

28  {
29  std::cout << "entering clear" << std::endl;
30  m_ttcci_file = "";
33  m_trg_mode = "";
34  m_trg_sleep = 0;
35 }
std::string m_configuration_script
Definition: ODTTCciConfig.h:59
std::string m_ttcci_file
Definition: ODTTCciConfig.h:58
std::string m_trg_mode
Definition: ODTTCciConfig.h:61
std::string m_configuration_script_params
Definition: ODTTCciConfig.h:60
tuple cout
Definition: gather_cfg.py:144
void ODTTCciConfig::fetchData ( ODTTCciConfig result)
privatenoexcept

Definition at line 182 of file ODTTCciConfig.cc.

References edmScanValgrind::buffer, gather_cfg::cout, alignCSCRings::e, mps_fire::i, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

182  {
183  this->checkConnection();
184  result->clear();
185  if (result->getId() == 0 && (result->getConfigTag().empty())) {
186  throw(std::runtime_error("ODTTCciConfig::fetchData(): no Id defined for this ODTTCciConfig "));
187  }
188 
189  try {
190  m_readStmt->setSQL(
191  "SELECT * "
192  "FROM ECAL_TTCci_CONFIGURATION "
193  " where ( ttcci_configuration_id = :1 or ttcci_tag=:2 )");
194  m_readStmt->setInt(1, result->getId());
195  m_readStmt->setString(2, result->getConfigTag());
196  ResultSet* rset = m_readStmt->executeQuery();
197 
198  rset->next();
199  // 1 is the id and 2 is the config tag
200 
201  result->setId(rset->getInt(1));
202  result->setConfigTag(rset->getString(2));
203 
204  result->setTTCciConfigurationFile(rset->getString(3));
205  result->setTrgMode(rset->getString(4));
206  result->setTrgSleep(rset->getInt(5));
207 
208  result->setConfigurationScript(rset->getString(7));
209  result->setConfigurationScriptParams(rset->getString(8));
210 
211  Clob clob = rset->getClob(6);
212  cout << "Opening the clob in Read only mode" << endl;
213  clob.open(OCCI_LOB_READONLY);
214  int clobLength = clob.length();
215  cout << "Length of the clob is: " << clobLength << endl;
216  m_size = clobLength;
217  unsigned char* buffer = readClob(clob, m_size);
218  clob.close();
219  cout << "the clob buffer is:" << endl;
220  for (int i = 0; i < clobLength; ++i)
221  cout << (char)buffer[i];
222  cout << endl;
223 
224  result->setTTCciClob(buffer);
225 
226  } catch (SQLException& e) {
227  throw(std::runtime_error(std::string("ODTTCciConfig::fetchData(): ") + e.getMessage()));
228  }
229 }
void setConfigurationScript(std::string x)
Definition: ODTTCciConfig.h:30
unsigned char * readClob(Clob &clob, int size) noexcept(false)
Definition: IODConfig.h:124
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
void setTTCciClob(unsigned char *x)
Definition: ODTTCciConfig.h:40
void setId(int id)
Definition: ODTTCciConfig.h:24
void setTTCciConfigurationFile(std::string x)
Definition: ODTTCciConfig.h:27
void setTrgMode(std::string x)
Definition: ODTTCciConfig.h:35
int getId() const
Definition: ODTTCciConfig.h:25
oracle::occi::Clob Clob
Definition: IODConfig.h:23
void setConfigurationScriptParams(std::string x)
Definition: ODTTCciConfig.h:32
void setTrgSleep(int id)
Definition: ODTTCciConfig.h:37
void setConfigTag(std::string x)
Definition: IODConfig.h:29
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
std::string getConfigTag()
Definition: IODConfig.h:30
tuple cout
Definition: gather_cfg.py:144
int ODTTCciConfig::fetchID ( )
privatenoexcept

Definition at line 231 of file ODTTCciConfig.cc.

References alignCSCRings::e, and AlCaHLTBitMon_QueryRunRegistry::string.

231  {
232  if (m_ID != 0) {
233  return m_ID;
234  }
235 
236  this->checkConnection();
237 
238  try {
239  Statement* stmt = m_conn->createStatement();
240  stmt->setSQL(
241  "SELECT ttcci_configuration_id FROM ecal_ttcci_configuration "
242  "WHERE ttcci_tag=:ttcci_tag ");
243 
244  stmt->setString(1, getConfigTag());
245 
246  ResultSet* rset = stmt->executeQuery();
247 
248  if (rset->next()) {
249  m_ID = rset->getInt(1);
250  } else {
251  m_ID = 0;
252  }
253  m_conn->terminateStatement(stmt);
254  } catch (SQLException& e) {
255  throw(std::runtime_error(std::string("ODTTCciConfig::fetchID: ") + e.getMessage()));
256  }
257  return m_ID;
258 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::Statement Statement
Definition: IODConfig.h:21
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
int ODTTCciConfig::fetchNextId ( )
privatenoexcept

Definition at line 39 of file ODTTCciConfig.cc.

References alignCSCRings::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

39  {
40  int result = 0;
41  try {
42  this->checkConnection();
43 
44  m_readStmt = m_conn->createStatement();
45  m_readStmt->setSQL("select ecal_ttcci_config_sq.NextVal from dual");
46  ResultSet* rset = m_readStmt->executeQuery();
47  while (rset->next()) {
48  result = rset->getInt(1);
49  }
50  m_conn->terminateStatement(m_readStmt);
51  return result;
52 
53  } catch (SQLException& e) {
54  throw(std::runtime_error(std::string("ODTTCciConfig::fetchNextId(): ") + e.getMessage()));
55  }
56 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
tuple result
Definition: mps_fire.py:311
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
std::string ODTTCciConfig::getConfigurationScript ( ) const
inline

Definition at line 31 of file ODTTCciConfig.h.

References m_configuration_script.

31 { return m_configuration_script; }
std::string m_configuration_script
Definition: ODTTCciConfig.h:59
std::string ODTTCciConfig::getConfigurationScriptParams ( ) const
inline

Definition at line 33 of file ODTTCciConfig.h.

References m_configuration_script_params.

std::string m_configuration_script_params
Definition: ODTTCciConfig.h:60
int ODTTCciConfig::getId ( void  ) const
inline

Definition at line 25 of file ODTTCciConfig.h.

References m_ID.

25 { return m_ID; }
unsigned int ODTTCciConfig::getSize ( ) const
inline

Definition at line 43 of file ODTTCciConfig.h.

References m_size.

43 { return m_size; }
std::string ODTTCciConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODTTCciConfig.h.

22 { return "ECAL_TTCci_CONFIGURATION"; }
std::string ODTTCciConfig::getTrgMode ( ) const
inline

Definition at line 36 of file ODTTCciConfig.h.

References m_trg_mode.

36 { return m_trg_mode; }
std::string m_trg_mode
Definition: ODTTCciConfig.h:61
int ODTTCciConfig::getTrgSleep ( ) const
inline

Definition at line 38 of file ODTTCciConfig.h.

References m_trg_sleep.

38 { return m_trg_sleep; }
unsigned char* ODTTCciConfig::getTTCciClob ( ) const
inline

Definition at line 41 of file ODTTCciConfig.h.

References m_ttcci_clob.

41 { return m_ttcci_clob; }
unsigned char * m_ttcci_clob
Definition: ODTTCciConfig.h:57
std::string ODTTCciConfig::getTTCciConfigurationFile ( ) const
inline

Definition at line 28 of file ODTTCciConfig.h.

References m_ttcci_file.

28 { return m_ttcci_file; }
std::string m_ttcci_file
Definition: ODTTCciConfig.h:58
void ODTTCciConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 58 of file ODTTCciConfig.cc.

References gather_cfg::cout, alignCSCRings::e, and AlCaHLTBitMon_QueryRunRegistry::string.

58  {
59  this->checkConnection();
60 
61  int next_id = fetchNextId();
62 
63  try {
64  m_writeStmt = m_conn->createStatement();
65  m_writeStmt->setSQL(
66  "INSERT INTO ECAL_TTCci_CONFIGURATION (ttcci_configuration_id, ttcci_tag, "
67  " TTCCI_configuration_file, TRG_MODE, TRG_SLEEP, Configuration, configuration_script, "
68  "configuration_script_params ) "
69  "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 )");
70  m_writeStmt->setInt(1, next_id);
71  m_writeStmt->setString(2, getConfigTag());
72  m_writeStmt->setString(3, getTTCciConfigurationFile());
73  m_writeStmt->setString(4, getTrgMode());
74  m_writeStmt->setInt(5, getTrgSleep());
75  m_writeStmt->setString(7, getConfigurationScript());
77 
78  // and now the clob
79  oracle::occi::Clob clob(m_conn);
80  clob.setEmpty();
81  m_writeStmt->setClob(6, clob);
82  m_writeStmt->executeUpdate();
83  m_ID = next_id;
84 
85  m_conn->terminateStatement(m_writeStmt);
86  std::cout << "TTCci Clob inserted into CONFIGURATION with id=" << next_id << std::endl;
87 
88  // now we read and update it
89  m_writeStmt = m_conn->createStatement();
90  m_writeStmt->setSQL(
91  "SELECT Configuration FROM ECAL_TTCci_CONFIGURATION WHERE"
92  " ttcci_configuration_id=:1 FOR UPDATE");
93 
94  std::cout << "updating the clob 0" << std::endl;
95 
96  } catch (SQLException& e) {
97  throw(std::runtime_error(std::string("ODTTCciConfig::prepareWrite(): ") + e.getMessage()));
98  }
99 
100  std::cout << "updating the clob 1 " << std::endl;
101 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
std::string getConfigurationScript() const
Definition: ODTTCciConfig.h:31
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
std::string getTTCciConfigurationFile() const
Definition: ODTTCciConfig.h:28
int getTrgSleep() const
Definition: ODTTCciConfig.h:38
std::string getConfigurationScriptParams() const
Definition: ODTTCciConfig.h:33
int fetchNextId() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
std::string getConfigTag()
Definition: IODConfig.h:30
tuple cout
Definition: gather_cfg.py:144
std::string getTrgMode() const
Definition: ODTTCciConfig.h:36
void ODTTCciConfig::setConfigurationScript ( std::string  x)
inline

Definition at line 30 of file ODTTCciConfig.h.

References m_configuration_script, and x.

std::string m_configuration_script
Definition: ODTTCciConfig.h:59
void ODTTCciConfig::setConfigurationScriptParams ( std::string  x)
inline

Definition at line 32 of file ODTTCciConfig.h.

References m_configuration_script_params, and x.

std::string m_configuration_script_params
Definition: ODTTCciConfig.h:60
void ODTTCciConfig::setId ( int  id)
inline

Definition at line 24 of file ODTTCciConfig.h.

References gpuClustering::id, and m_ID.

24 { m_ID = id; }
uint16_t *__restrict__ id
void ODTTCciConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 103 of file ODTTCciConfig.cc.

References gather_cfg::cout, dataset::end, alignmentValidation::fname, and AlCaHLTBitMon_QueryRunRegistry::string.

103  {
104  // parses the result of the XML parser that is a map of
105  // string string with variable name variable value
106 
107  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
108  if (ci->first == "TRG_MODE")
109  setTrgMode(ci->second);
110  if (ci->first == "TRG_SLEEP")
111  setTrgSleep(atoi(ci->second.c_str()));
112  if (ci->first == "TTCci_CONFIGURATION_ID")
113  setConfigTag(ci->second);
114  if (ci->first == "CONFIGURATION_SCRIPT")
115  setConfigurationScript(ci->second);
116  if (ci->first == "CONFIGURATION_SCRIPT_PARAMS")
117  setConfigurationScriptParams(ci->second);
118  if (ci->first == "CONFIGURATION_SCRIPT_PARAMETERS")
119  setConfigurationScriptParams(ci->second);
120  if (ci->first == "Configuration") {
121  std::string fname = ci->second;
122  string str3;
123  size_t pos, pose;
124 
125  pos = fname.find('='); // position of "live" in str
126  pose = fname.size(); // position of "]" in str
127  str3 = fname.substr(pos + 1, pose - pos - 2);
128 
129  cout << "fname=" << fname << " and reduced is: " << str3 << endl;
131 
132  // here we must open the file and read the LTC Clob
133  std::cout << "Going to read file: " << str3 << endl;
134 
135  ifstream inpFile;
136  inpFile.open(str3.c_str());
137 
138  // tell me size of file
139  int bufsize = 0;
140  inpFile.seekg(0, ios::end);
141  bufsize = inpFile.tellg();
142  std::cout << " bufsize =" << bufsize << std::endl;
143  // set file pointer to start again
144  inpFile.seekg(0, ios::beg);
145 
146  inpFile.close();
147  m_size = bufsize;
148  }
149  }
150 }
void setConfigurationScript(std::string x)
Definition: ODTTCciConfig.h:30
void setTTCciConfigurationFile(std::string x)
Definition: ODTTCciConfig.h:27
void setTrgMode(std::string x)
Definition: ODTTCciConfig.h:35
void setConfigurationScriptParams(std::string x)
Definition: ODTTCciConfig.h:32
void setTrgSleep(int id)
Definition: ODTTCciConfig.h:37
string fname
main script
void setConfigTag(std::string x)
Definition: IODConfig.h:29
string end
Definition: dataset.py:937
tuple cout
Definition: gather_cfg.py:144
void ODTTCciConfig::setSize ( unsigned int  id)
inline

Definition at line 42 of file ODTTCciConfig.h.

References gpuClustering::id, and m_size.

42 { m_size = id; }
uint16_t *__restrict__ id
void ODTTCciConfig::setTrgMode ( std::string  x)
inline

Definition at line 35 of file ODTTCciConfig.h.

References m_trg_mode, and x.

35 { m_trg_mode = x; }
std::string m_trg_mode
Definition: ODTTCciConfig.h:61
void ODTTCciConfig::setTrgSleep ( int  id)
inline

Definition at line 37 of file ODTTCciConfig.h.

References gpuClustering::id, and m_trg_sleep.

37 { m_trg_sleep = id; }
uint16_t *__restrict__ id
void ODTTCciConfig::setTTCciClob ( unsigned char *  x)
inline

Definition at line 40 of file ODTTCciConfig.h.

References m_ttcci_clob, and x.

40 { m_ttcci_clob = x; }
unsigned char * m_ttcci_clob
Definition: ODTTCciConfig.h:57
void ODTTCciConfig::setTTCciConfigurationFile ( std::string  x)
inline

Definition at line 27 of file ODTTCciConfig.h.

References m_ttcci_file, and x.

27 { m_ttcci_file = x; }
std::string m_ttcci_file
Definition: ODTTCciConfig.h:58
void ODTTCciConfig::writeDB ( )
privatenoexcept

Definition at line 152 of file ODTTCciConfig.cc.

References gather_cfg::cout, alignCSCRings::e, and AlCaHLTBitMon_QueryRunRegistry::string.

152  {
153  std::cout << "updating the clob 2" << std::endl;
154 
155  try {
156  m_writeStmt->setInt(1, m_ID);
157  ResultSet* rset = m_writeStmt->executeQuery();
158 
159  while (rset->next()) {
160  oracle::occi::Clob clob = rset->getClob(1);
161  cout << "Opening the clob in read write mode" << endl;
162  cout << "Populating the clob" << endl;
164  int clobLength = clob.length();
165  cout << "Length of the clob is: " << clobLength << endl;
166  // clob.close ();
167  }
168 
169  m_writeStmt->executeUpdate();
170 
171  m_writeStmt->closeResultSet(rset);
172 
173  } catch (SQLException& e) {
174  throw(std::runtime_error(std::string("ODTTCciConfig::writeDB(): ") + e.getMessage()));
175  }
176  // Now get the ID
177  if (!this->fetchID()) {
178  throw(std::runtime_error("ODTTCciConfig::writeDB: Failed to write"));
179  }
180 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void populateClob(Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
Definition: IODConfig.h:67
std::string getTTCciConfigurationFile() const
Definition: ODTTCciConfig.h:28
int fetchID() noexcept(false)
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
tuple cout
Definition: gather_cfg.py:144

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODTTCciConfig.h.

Member Data Documentation

std::string ODTTCciConfig::m_configuration_script
private

Definition at line 59 of file ODTTCciConfig.h.

Referenced by getConfigurationScript(), and setConfigurationScript().

std::string ODTTCciConfig::m_configuration_script_params
private

Definition at line 60 of file ODTTCciConfig.h.

Referenced by getConfigurationScriptParams(), and setConfigurationScriptParams().

int ODTTCciConfig::m_ID
private

Definition at line 56 of file ODTTCciConfig.h.

Referenced by getId(), and setId().

int ODTTCciConfig::m_size
private

Definition at line 63 of file ODTTCciConfig.h.

Referenced by getSize(), and setSize().

std::string ODTTCciConfig::m_trg_mode
private

Definition at line 61 of file ODTTCciConfig.h.

Referenced by getTrgMode(), and setTrgMode().

int ODTTCciConfig::m_trg_sleep
private

Definition at line 62 of file ODTTCciConfig.h.

Referenced by getTrgSleep(), and setTrgSleep().

unsigned char* ODTTCciConfig::m_ttcci_clob
private

Definition at line 57 of file ODTTCciConfig.h.

Referenced by getTTCciClob(), and setTTCciClob().

std::string ODTTCciConfig::m_ttcci_file
private

Definition at line 58 of file ODTTCciConfig.h.

Referenced by getTTCciConfigurationFile(), and setTTCciConfigurationFile().