CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
ODTTCFConfig Class Reference

#include <ODTTCFConfig.h>

Inheritance diagram for ODTTCFConfig:
IODConfig IDBObject

Public Member Functions

int getId () const
 
int getReg30 ()
 
int getRxBC0Delay ()
 
unsigned int getSize () const
 
std::string getTable () override
 
unsigned char * getTTCFClob () const
 
std::string getTTCFConfigurationFile () const
 
 ODTTCFConfig ()
 
void setId (int id)
 
void setParameters (const std::map< std::string, std::string > &my_keys_map)
 
void setReg30 (int x)
 
void setRxBC0Delay (int x)
 
void setSize (unsigned int id)
 
void setTTCFClob (unsigned char *x)
 
void setTTCFConfigurationFile (std::string x)
 
 ~ODTTCFConfig () 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 (ODTTCFConfig *result) noexcept(false)
 
int fetchID () noexcept(false)
 
int fetchNextId () noexcept(false)
 
void prepareWrite () noexcept(false) override
 
void writeDB () noexcept(false)
 

Private Attributes

int m_ID
 
int m_reg_30
 
int m_rxbc0_delay
 
unsigned int m_size
 
unsigned char * m_ttcf_clob
 
std::string m_ttcf_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 ODTTCFConfig.h.

Constructor & Destructor Documentation

ODTTCFConfig::ODTTCFConfig ( )

Definition at line 12 of file ODTTCFConfig.cc.

References hitfit::clear().

12  {
13  m_env = nullptr;
14  m_conn = nullptr;
15  m_writeStmt = nullptr;
16  m_readStmt = nullptr;
17  m_config_tag = "";
18  m_ID = 0;
19  clear();
20  m_size = 0;
21 }
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
unsigned int m_size
Definition: ODTTCFConfig.h:58
Statement * m_readStmt
Definition: IODConfig.h:34
ODTTCFConfig::~ODTTCFConfig ( )
override

Definition at line 25 of file ODTTCFConfig.cc.

25 {}

Member Function Documentation

void ODTTCFConfig::clear ( void  )
private

Definition at line 23 of file ODTTCFConfig.cc.

Referenced by getReg30().

23 {}
void ODTTCFConfig::fetchData ( ODTTCFConfig result)
privatenoexcept

Definition at line 117 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

117  {
118  this->checkConnection();
119  result->clear();
120 
121  if (result->getId() == 0 && (result->getConfigTag().empty())) {
122  throw(std::runtime_error("ODTTCFConfig::fetchData(): no Id defined for this ODTTCFConfig "));
123  }
124 
125  try {
126  m_readStmt->setSQL(
127  "SELECT * "
128  "FROM ECAL_TTCF_CONFIGURATION "
129  " where (ttcf_configuration_id = :1 or ttcf_tag= :2) ");
130  m_readStmt->setInt(1, result->getId());
131  m_readStmt->setString(2, result->getConfigTag());
132  ResultSet* rset = m_readStmt->executeQuery();
133 
134  rset->next();
135 
136  result->setId(rset->getInt(1));
137  result->setConfigTag(rset->getString(2));
138  result->setTTCFConfigurationFile(rset->getString(3));
139  Clob clob = rset->getClob(4);
140  cout << "Opening the clob in Read only mode" << endl;
141  clob.open(OCCI_LOB_READONLY);
142  int clobLength = clob.length();
143  cout << "Length of the clob is: " << clobLength << endl;
144  m_size = clobLength;
145  unsigned char* buffer = readClob(clob, m_size);
146  clob.close();
147  result->setTTCFClob((unsigned char*)buffer);
148 
149  } catch (SQLException& e) {
150  throw(std::runtime_error(std::string("ODTTCFConfig::fetchData(): ") + e.getMessage()));
151  }
152 }
unsigned char * readClob(Clob &clob, int size) noexcept(false)
Definition: IODConfig.h:126
int getId() const
Definition: ODTTCFConfig.h:27
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
unsigned int m_size
Definition: ODTTCFConfig.h:58
void setTTCFClob(unsigned char *x)
Definition: ODTTCFConfig.h:32
oracle::occi::Clob Clob
Definition: IODConfig.h:23
void setId(int id)
Definition: ODTTCFConfig.h:26
void setTTCFConfigurationFile(std::string x)
Definition: ODTTCFConfig.h:29
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
int ODTTCFConfig::fetchID ( )
privatenoexcept

Definition at line 154 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

154  {
155  if (m_ID != 0) {
156  return m_ID;
157  }
158 
159  this->checkConnection();
160 
161  try {
162  Statement* stmt = m_conn->createStatement();
163  stmt->setSQL(
164  "SELECT ttcf_configuration_id FROM ecal_ttcf_configuration "
165  "WHERE ttcf_tag=:ttcf_tag ");
166 
167  stmt->setString(1, getConfigTag());
168 
169  ResultSet* rset = stmt->executeQuery();
170 
171  if (rset->next()) {
172  m_ID = rset->getInt(1);
173  } else {
174  m_ID = 0;
175  }
176  m_conn->terminateStatement(stmt);
177  } catch (SQLException& e) {
178  throw(std::runtime_error(std::string("ODTTCFConfig::fetchID: ") + e.getMessage()));
179  }
180 
181  return m_ID;
182 }
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 ODTTCFConfig::fetchNextId ( )
privatenoexcept

Definition at line 27 of file ODTTCFConfig.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, mps_fire::result, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by getReg30().

27  {
28  int result = 0;
29  try {
30  this->checkConnection();
31  std::cout << "going to fetch new id for TTCF 1" << endl;
32  m_readStmt = m_conn->createStatement();
33  m_readStmt->setSQL("select ecal_ttcf_config_sq.NextVal from dual");
34  ResultSet* rset = m_readStmt->executeQuery();
35  while (rset->next()) {
36  result = rset->getInt(1);
37  }
38  std::cout << "id is : " << result << endl;
39 
40  m_conn->terminateStatement(m_readStmt);
41  return result;
42 
43  } catch (SQLException& e) {
44  throw(std::runtime_error(std::string("ODTTCFConfig::fetchNextId(): ") + e.getMessage()));
45  }
46 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
Statement * m_readStmt
Definition: IODConfig.h:34
int ODTTCFConfig::getId ( void  ) const
inline

Definition at line 27 of file ODTTCFConfig.h.

References m_ID.

27 { return m_ID; }
int ODTTCFConfig::getReg30 ( )
inline
int ODTTCFConfig::getRxBC0Delay ( )
inline

Definition at line 36 of file ODTTCFConfig.h.

References m_rxbc0_delay.

36 { return m_rxbc0_delay; }
unsigned int ODTTCFConfig::getSize ( ) const
inline

Definition at line 24 of file ODTTCFConfig.h.

References m_size.

24 { return m_size; }
unsigned int m_size
Definition: ODTTCFConfig.h:58
std::string ODTTCFConfig::getTable ( )
inlineoverridevirtual

Implements IODConfig.

Definition at line 22 of file ODTTCFConfig.h.

22 { return "ECAL_TTCF_CONFIGURATION"; }
unsigned char* ODTTCFConfig::getTTCFClob ( ) const
inline

Definition at line 33 of file ODTTCFConfig.h.

References m_ttcf_clob.

33 { return m_ttcf_clob; }
unsigned char * m_ttcf_clob
Definition: ODTTCFConfig.h:57
std::string ODTTCFConfig::getTTCFConfigurationFile ( ) const
inline

Definition at line 30 of file ODTTCFConfig.h.

References m_ttcf_file.

30 { return m_ttcf_file; }
std::string m_ttcf_file
Definition: ODTTCFConfig.h:59
void ODTTCFConfig::prepareWrite ( )
overrideprivatevirtualnoexcept

Implements IODConfig.

Definition at line 48 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

48  {
49  this->checkConnection();
50  int next_id = fetchNextId();
51 
52  try {
53  m_writeStmt = m_conn->createStatement();
54  m_writeStmt->setSQL(
55  "INSERT INTO ECAL_TTCF_CONFIGURATION (ttcf_configuration_id, ttcf_tag, "
56  " rxbc0_delay, reg_30 , ttcf_configuration_file , ttcf_configuration ) "
57  "VALUES (:1, :2, :3 , :4, :5, :6)");
58  m_writeStmt->setInt(1, next_id);
59  m_writeStmt->setString(2, getConfigTag());
60 
61  m_writeStmt->setInt(3, getRxBC0Delay());
62  m_writeStmt->setInt(4, getReg30());
63 
64  m_writeStmt->setString(5, getTTCFConfigurationFile());
65 
66  oracle::occi::Clob clob(m_conn);
67  clob.setEmpty();
68  m_writeStmt->setClob(6, clob);
69  m_writeStmt->executeUpdate();
70  m_ID = next_id;
71 
72  m_conn->terminateStatement(m_writeStmt);
73  std::cout << "inserted into CONFIGURATION with id=" << next_id << std::endl;
74 
75  // now we read and update it
76  m_writeStmt = m_conn->createStatement();
77  m_writeStmt->setSQL(
78  "SELECT ttcf_configuration FROM ECAL_TTCF_CONFIGURATION WHERE"
79  " ttcf_configuration_id=:1 FOR UPDATE");
80 
81  std::cout << "updating the clob 0" << std::endl;
82 
83  } catch (SQLException& e) {
84  throw(std::runtime_error(std::string("ODTTCFConfig::prepareWrite(): ") + e.getMessage()));
85  }
86 
87  std::cout << "updating the clob 1 " << std::endl;
88 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:34
Statement * m_writeStmt
Definition: IODConfig.h:33
void checkConnection() const noexcept(false)
Definition: IDBObject.h:36
int getRxBC0Delay()
Definition: ODTTCFConfig.h:36
std::string getTTCFConfigurationFile() const
Definition: ODTTCFConfig.h:30
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20
int fetchNextId() noexcept(false)
Definition: ODTTCFConfig.cc:27
std::string getConfigTag()
Definition: IODConfig.h:30
int getReg30()
Definition: ODTTCFConfig.h:38
void ODTTCFConfig::setId ( int  id)
inline

Definition at line 26 of file ODTTCFConfig.h.

References triggerObjects_cff::id, and m_ID.

void ODTTCFConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 184 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

184  {
185  // parses the result of the XML parser that is a map of
186  // string string with variable name variable value
187 
188  for (std::map<std::string, std::string>::const_iterator ci = my_keys_map.begin(); ci != my_keys_map.end(); ci++) {
189  if (ci->first == "TTCF_CONFIGURATION_ID")
190  setConfigTag(ci->second);
191  if (ci->first == "Configuration") {
192  std::string fname = ci->second;
193  string str3;
194  size_t pos, pose;
195 
196  pos = fname.find("="); // position of "live" in str
197  pose = fname.size(); // position of "]" in str
198  str3 = fname.substr(pos + 1, pose - pos - 2);
199 
200  cout << "fname=" << fname << " and reduced is: " << str3 << endl;
202 
203  // here we must open the file and read the LTC Clob
204  std::cout << "Going to read file: " << str3 << endl;
205 
206  ifstream inpFile;
207  inpFile.open(str3.c_str());
208 
209  // tell me size of file
210  int bufsize = 0;
211  inpFile.seekg(0, ios::end);
212  bufsize = inpFile.tellg();
213  std::cout << " bufsize =" << bufsize << std::endl;
214  // set file pointer to start again
215  inpFile.seekg(0, ios::beg);
216 
217  inpFile.close();
218  m_size = bufsize;
219 
220  } else if (ci->first == "RXBC0_DELAY") {
221  setRxBC0Delay(atoi(ci->second.c_str()));
222  } else if (ci->first == "REG_30") {
223  setReg30(atoi(ci->second.c_str()));
224  }
225  }
226 }
unsigned int m_size
Definition: ODTTCFConfig.h:58
#define end
Definition: vmac.h:39
void setReg30(int x)
Definition: ODTTCFConfig.h:37
void setTTCFConfigurationFile(std::string x)
Definition: ODTTCFConfig.h:29
string fname
main script
void setConfigTag(std::string x)
Definition: IODConfig.h:29
void setRxBC0Delay(int x)
Definition: ODTTCFConfig.h:35
void ODTTCFConfig::setReg30 ( int  x)
inline

Definition at line 37 of file ODTTCFConfig.h.

References m_reg_30, and x.

37 { m_reg_30 = x; }
void ODTTCFConfig::setRxBC0Delay ( int  x)
inline

Definition at line 35 of file ODTTCFConfig.h.

References m_rxbc0_delay, and x.

void ODTTCFConfig::setSize ( unsigned int  id)
inline

Definition at line 23 of file ODTTCFConfig.h.

References triggerObjects_cff::id, and m_size.

23 { m_size = id; }
unsigned int m_size
Definition: ODTTCFConfig.h:58
void ODTTCFConfig::setTTCFClob ( unsigned char *  x)
inline

Definition at line 32 of file ODTTCFConfig.h.

References m_ttcf_clob, and x.

32 { m_ttcf_clob = x; }
unsigned char * m_ttcf_clob
Definition: ODTTCFConfig.h:57
void ODTTCFConfig::setTTCFConfigurationFile ( std::string  x)
inline

Definition at line 29 of file ODTTCFConfig.h.

References m_ttcf_file, and x.

29 { m_ttcf_file = x; }
std::string m_ttcf_file
Definition: ODTTCFConfig.h:59
void ODTTCFConfig::writeDB ( )
privatenoexcept

Definition at line 90 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

90  {
91  std::cout << "updating the clob 2" << std::endl;
92 
93  try {
94  m_writeStmt->setInt(1, m_ID);
95  ResultSet* rset = m_writeStmt->executeQuery();
96 
97  rset->next();
98 
99  oracle::occi::Clob clob = rset->getClob(1);
100  cout << "Opening the clob in read write mode" << endl;
102  int clobLength = clob.length();
103  cout << "Length of the clob is: " << clobLength << endl;
104 
105  m_writeStmt->executeUpdate();
106  m_writeStmt->closeResultSet(rset);
107 
108  } catch (SQLException& e) {
109  throw(std::runtime_error(std::string("ODTTCFConfig::writeDB(): ") + e.getMessage()));
110  }
111  // Now get the ID
112  if (!this->fetchID()) {
113  throw(std::runtime_error("ODTTCFConfig::writeDB: Failed to write"));
114  }
115 }
Statement * m_writeStmt
Definition: IODConfig.h:33
void populateClob(Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
Definition: IODConfig.h:67
unsigned int m_size
Definition: ODTTCFConfig.h:58
int fetchID() noexcept(false)
std::string getTTCFConfigurationFile() const
Definition: ODTTCFConfig.h:30
oracle::occi::SQLException SQLException
Definition: IODConfig.h:20

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODTTCFConfig.h.

Member Data Documentation

int ODTTCFConfig::m_ID
private

Definition at line 56 of file ODTTCFConfig.h.

Referenced by getId(), and setId().

int ODTTCFConfig::m_reg_30
private

Definition at line 62 of file ODTTCFConfig.h.

Referenced by getReg30(), and setReg30().

int ODTTCFConfig::m_rxbc0_delay
private

Definition at line 61 of file ODTTCFConfig.h.

Referenced by getRxBC0Delay(), and setRxBC0Delay().

unsigned int ODTTCFConfig::m_size
private

Definition at line 58 of file ODTTCFConfig.h.

Referenced by getSize(), and setSize().

unsigned char* ODTTCFConfig::m_ttcf_clob
private

Definition at line 57 of file ODTTCFConfig.h.

Referenced by getTTCFClob(), and setTTCFClob().

std::string ODTTCFConfig::m_ttcf_file
private

Definition at line 59 of file ODTTCFConfig.h.

Referenced by getTTCFConfigurationFile(), and setTTCFConfigurationFile().