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 ()
 
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 ()
 
- 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)
 
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(), and NULL.

13 {
14  m_env = NULL;
15  m_conn = NULL;
16  m_writeStmt = NULL;
17  m_readStmt = NULL;
18  m_config_tag="";
19  m_ID=0;
20  clear();
21  m_size=0;
22 }
oracle::occi::Environment * m_env
Definition: IDBObject.h:38
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
unsigned int m_size
Definition: ODTTCFConfig.h:60
Statement * m_readStmt
Definition: IODConfig.h:37
ODTTCFConfig::~ODTTCFConfig ( )

Definition at line 30 of file ODTTCFConfig.cc.

31 {
32 }

Member Function Documentation

void ODTTCFConfig::clear ( void  )
private

Definition at line 25 of file ODTTCFConfig.cc.

Referenced by getReg30().

25  {
26 
27 }
void ODTTCFConfig::fetchData ( ODTTCFConfig result)
privatenoexcept

Definition at line 139 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

141 {
142  this->checkConnection();
143  result->clear();
144 
145  if(result->getId()==0 && (result->getConfigTag()=="") ){
146  throw(std::runtime_error("ODTTCFConfig::fetchData(): no Id defined for this ODTTCFConfig "));
147  }
148 
149  try {
150 
151  m_readStmt->setSQL("SELECT * "
152  "FROM ECAL_TTCF_CONFIGURATION "
153  " where (ttcf_configuration_id = :1 or ttcf_tag= :2) " );
154  m_readStmt->setInt(1, result->getId());
155  m_readStmt->setString(2, result->getConfigTag());
156  ResultSet* rset = m_readStmt->executeQuery();
157 
158  rset->next();
159 
160  result->setId(rset->getInt(1));
161  result->setConfigTag(rset->getString(2));
162  result->setTTCFConfigurationFile(rset->getString(3));
163  Clob clob = rset->getClob (4);
164  cout << "Opening the clob in Read only mode" << endl;
165  clob.open (OCCI_LOB_READONLY);
166  int clobLength=clob.length ();
167  cout << "Length of the clob is: " << clobLength << endl;
168  m_size=clobLength;
169  unsigned char* buffer = readClob (clob, m_size);
170  clob.close ();
171  result->setTTCFClob((unsigned char*) buffer );
172 
173  } catch (SQLException &e) {
174  throw(std::runtime_error("ODTTCFConfig::fetchData(): "+e.getMessage()));
175  }
176 }
unsigned char * readClob(Clob &clob, int size) noexcept(false)
Definition: IODConfig.h:154
int getId() const
Definition: ODTTCFConfig.h:27
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
unsigned int m_size
Definition: ODTTCFConfig.h:60
void setTTCFClob(unsigned char *x)
Definition: ODTTCFConfig.h:32
oracle::occi::Clob Clob
Definition: IODConfig.h:25
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:31
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
int ODTTCFConfig::fetchID ( )
privatenoexcept

Definition at line 180 of file ODTTCFConfig.cc.

References MillePedeFileConverter_cfg::e.

Referenced by getReg30().

181 {
182  if (m_ID!=0) {
183  return m_ID;
184  }
185 
186  this->checkConnection();
187 
188  try {
189  Statement* stmt = m_conn->createStatement();
190  stmt->setSQL("SELECT ttcf_configuration_id FROM ecal_ttcf_configuration "
191  "WHERE ttcf_tag=:ttcf_tag "
192  );
193 
194  stmt->setString(1, getConfigTag() );
195 
196  ResultSet* rset = stmt->executeQuery();
197 
198  if (rset->next()) {
199  m_ID = rset->getInt(1);
200  } else {
201  m_ID = 0;
202  }
203  m_conn->terminateStatement(stmt);
204  } catch (SQLException &e) {
205  throw(std::runtime_error("ODTTCFConfig::fetchID: "+e.getMessage()));
206  }
207 
208  return m_ID;
209 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
std::string getConfigTag()
Definition: IODConfig.h:32
int ODTTCFConfig::fetchNextId ( )
privatenoexcept

Definition at line 34 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

34  {
35 
36  int result=0;
37  try {
38  this->checkConnection();
39  std::cout<< "going to fetch new id for TTCF 1"<<endl;
40  m_readStmt = m_conn->createStatement();
41  m_readStmt->setSQL("select ecal_ttcf_config_sq.NextVal from dual");
42  ResultSet* rset = m_readStmt->executeQuery();
43  while (rset->next ()){
44  result= rset->getInt(1);
45  }
46  std::cout<< "id is : "<< result<<endl;
47 
48  m_conn->terminateStatement(m_readStmt);
49  return result;
50 
51  } catch (SQLException &e) {
52  throw(std::runtime_error("ODTTCFConfig::fetchNextId(): "+e.getMessage()));
53  }
54 
55 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
Statement * m_readStmt
Definition: IODConfig.h:37
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:60
std::string ODTTCFConfig::getTable ( )
inlinevirtual

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:59
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:61
void ODTTCFConfig::prepareWrite ( )
privatevirtualnoexcept

Implements IODConfig.

Definition at line 60 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

62 {
63  this->checkConnection();
64  int next_id=fetchNextId();
65 
66  try {
67  m_writeStmt = m_conn->createStatement();
68  m_writeStmt->setSQL("INSERT INTO ECAL_TTCF_CONFIGURATION (ttcf_configuration_id, ttcf_tag, "
69  " rxbc0_delay, reg_30 , ttcf_configuration_file , ttcf_configuration ) "
70  "VALUES (:1, :2, :3 , :4, :5, :6)");
71  m_writeStmt->setInt(1, next_id);
72  m_writeStmt->setString(2, getConfigTag());
73 
74  m_writeStmt->setInt( 3, getRxBC0Delay() );
75  m_writeStmt->setInt( 4, getReg30() );
76 
77  m_writeStmt->setString(5, getTTCFConfigurationFile());
78 
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<<"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 ("SELECT ttcf_configuration FROM ECAL_TTCF_CONFIGURATION WHERE"
91  " ttcf_configuration_id=:1 FOR UPDATE");
92 
93  std::cout<<"updating the clob 0"<<std::endl;
94 
95 
96  } catch (SQLException &e) {
97  throw(std::runtime_error("ODTTCFConfig::prepareWrite(): "+e.getMessage()));
98  }
99 
100  std::cout<<"updating the clob 1 "<<std::endl;
101 
102 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
void checkConnection() const noexcept(false)
Definition: IDBObject.h:41
int getRxBC0Delay()
Definition: ODTTCFConfig.h:36
std::string getTTCFConfigurationFile() const
Definition: ODTTCFConfig.h:30
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22
int fetchNextId() noexcept(false)
Definition: ODTTCFConfig.cc:34
std::string getConfigTag()
Definition: IODConfig.h:32
int getReg30()
Definition: ODTTCFConfig.h:38
void ODTTCFConfig::setId ( int  id)
inline

Definition at line 26 of file ODTTCFConfig.h.

References hcalTTPDigis_cfi::id, and m_ID.

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

Definition at line 211 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

211  {
212 
213  // parses the result of the XML parser that is a map of
214  // string string with variable name variable value
215 
216  for( std::map<std::string, std::string >::const_iterator ci=
217  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
218 
219  if(ci->first== "TTCF_CONFIGURATION_ID") setConfigTag(ci->second);
220  if(ci->first== "Configuration") {
221  std::string fname=ci->second ;
222  string str3;
223  size_t pos, pose;
224 
225  pos = fname.find("="); // position of "live" in str
226  pose = fname.size(); // position of "]" in str
227  str3 = fname.substr (pos+1, pose-pos-2);
228 
229  cout << "fname="<<fname<< " and reduced is: "<<str3 << endl;
231 
232 
233  // here we must open the file and read the LTC Clob
234  std::cout << "Going to read file: " << str3 << endl;
235 
236  ifstream inpFile;
237  inpFile.open(str3.c_str());
238 
239  // tell me size of file
240  int bufsize = 0;
241  inpFile.seekg( 0,ios::end );
242  bufsize = inpFile.tellg();
243  std::cout <<" bufsize ="<<bufsize<< std::endl;
244  // set file pointer to start again
245  inpFile.seekg( 0,ios::beg );
246 
247  inpFile.close();
248  m_size=bufsize;
249 
250  } else if ( ci->first == "RXBC0_DELAY" ) {
251  setRxBC0Delay( atoi( ci->second.c_str() ) );
252  } else if ( ci->first == "REG_30" ) {
253  setReg30( atoi( ci->second.c_str() ) );
254  }
255  }
256 
257 }
unsigned int m_size
Definition: ODTTCFConfig.h:60
#define end
Definition: vmac.h:37
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:31
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.

35 { m_rxbc0_delay = x; }
void ODTTCFConfig::setSize ( unsigned int  id)
inline

Definition at line 23 of file ODTTCFConfig.h.

References hcalTTPDigis_cfi::id, and m_size.

23 { m_size = id; }
unsigned int m_size
Definition: ODTTCFConfig.h:60
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:59
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:61
void ODTTCFConfig::writeDB ( )
privatenoexcept

Definition at line 104 of file ODTTCFConfig.cc.

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

Referenced by getReg30().

106 {
107 
108  std::cout<<"updating the clob 2"<<std::endl;
109 
110  try {
111  m_writeStmt->setInt(1, m_ID);
112  ResultSet* rset = m_writeStmt->executeQuery();
113 
114  rset->next ();
115 
116  oracle::occi::Clob clob = rset->getClob (1);
117  cout << "Opening the clob in read write mode" << endl;
119  int clobLength=clob.length ();
120  cout << "Length of the clob is: " << clobLength << endl;
121 
122  m_writeStmt->executeUpdate();
123  m_writeStmt->closeResultSet (rset);
124 
125  } catch (SQLException &e) {
126  throw(std::runtime_error("ODTTCFConfig::writeDB(): "+e.getMessage()));
127  }
128  // Now get the ID
129  if (!this->fetchID()) {
130  throw(std::runtime_error("ODTTCFConfig::writeDB: Failed to write"));
131  }
132 
133 
134 }
Statement * m_writeStmt
Definition: IODConfig.h:36
void populateClob(Clob &clob, std::string fname, unsigned int bufsize) noexcept(false)
Definition: IODConfig.h:83
unsigned int m_size
Definition: ODTTCFConfig.h:60
int fetchID() noexcept(false)
std::string getTTCFConfigurationFile() const
Definition: ODTTCFConfig.h:30
oracle::occi::SQLException SQLException
Definition: IODConfig.h:22

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 58 of file ODTTCFConfig.h.

Referenced by getId(), and setId().

int ODTTCFConfig::m_reg_30
private

Definition at line 64 of file ODTTCFConfig.h.

Referenced by getReg30(), and setReg30().

int ODTTCFConfig::m_rxbc0_delay
private

Definition at line 63 of file ODTTCFConfig.h.

Referenced by getRxBC0Delay(), and setRxBC0Delay().

unsigned int ODTTCFConfig::m_size
private

Definition at line 60 of file ODTTCFConfig.h.

Referenced by getSize(), and setSize().

unsigned char* ODTTCFConfig::m_ttcf_clob
private

Definition at line 59 of file ODTTCFConfig.h.

Referenced by getTTCFClob(), and setTTCFClob().

std::string ODTTCFConfig::m_ttcf_file
private

Definition at line 61 of file ODTTCFConfig.h.

Referenced by getTTCFConfigurationFile(), and setTTCFConfigurationFile().