CMS 3D CMS Logo

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

#include <ODDCCConfig.h>

Inheritance diagram for ODDCCConfig:
IODConfig IDBObject

Public Member Functions

unsigned char * getDCCClob () const
 
unsigned int getDCCClobSize () const
 
std::string getDCCConfigurationUrl () const
 
std::string getDCCWeightsMode () const
 
int getId () const
 
int getNTestPatternsToLoad () const
 
unsigned int getSize () const
 
int getSMHalf () const
 
std::string getTable ()
 
std::string getTestPatternFileUrl () const
 
 ODDCCConfig ()
 
void setDCCClob (unsigned char *x)
 
void setDCCConfigurationUrl (std::string x)
 
void setDCCWeightsMode (std::string x)
 
void setId (int id)
 
void setNTestPatternsToLoad (int id)
 
void setParameters (std::map< std::string, std::string > my_keys_map)
 
void setSize (unsigned int id)
 
void setSMHalf (int id)
 
void setTestPatternFileUrl (std::string x)
 
 ~ODDCCConfig ()
 
- 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 (ODDCCConfig *result) throw (std::runtime_error)
 
int fetchID () throw (std::runtime_error)
 
int fetchNextId () throw (std::runtime_error)
 
void prepareWrite () throw (std::runtime_error)
 
void writeDB () throw (std::runtime_error)
 

Private Attributes

unsigned char * m_dcc_clob
 
std::string m_dcc_url
 
int m_ID
 
int m_ntest
 
unsigned int m_size
 
int m_sm_half
 
std::string m_test_url
 
std::string m_wei
 

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 () throw (std::runtime_error)
 
void createReadStatement () throw (std::runtime_error)
 
void populateClob (Clob &clob, std::string fname, unsigned int bufsize) throw (std::runtime_error)
 
unsigned char * readClob (Clob &clob, int size) throw (std::runtime_error)
 
void setPrefetchRowCount (int ncount) throw (std::runtime_error)
 
void terminateReadStatement () throw (std::runtime_error)
 
void terminateWriteStatement () throw (std::runtime_error)
 
- Protected Member Functions inherited from IDBObject
void checkConnection () const throw (std::runtime_error)
 
- 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 ODDCCConfig.h.

Constructor & Destructor Documentation

ODDCCConfig::ODDCCConfig ( )

Definition at line 15 of file ODDCCConfig.cc.

References NULL.

16 {
17  m_env = NULL;
18  m_conn = NULL;
19  m_writeStmt = NULL;
20  m_readStmt = NULL;
21  m_size=0;
22  m_config_tag="";
23  m_ID=0;
24  m_wei="";
25  clear();
26 
27 }
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
unsigned int m_size
Definition: ODDCCConfig.h:66
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
std::string m_wei
Definition: ODDCCConfig.h:67
Statement * m_readStmt
Definition: IODConfig.h:37
void clear()
Definition: ODDCCConfig.cc:194
ODDCCConfig::~ODDCCConfig ( )

Definition at line 31 of file ODDCCConfig.cc.

32 {
33 }

Member Function Documentation

void ODDCCConfig::clear ( void  )
private

Definition at line 194 of file ODDCCConfig.cc.

Referenced by python.Vispa.Views.BoxDecayView.BoxDecayView::closeEvent(), python.Vispa.Views.LineDecayView.LineDecayView::setDataObjects(), and python.Vispa.Views.BoxDecayView.BoxDecayView::updateContent().

194  {
195 
196  m_dcc_url="";
197  m_test_url="";
198  m_ntest=0;
199  m_sm_half=0;
200  m_wei="";
201 
202 }
std::string m_test_url
Definition: ODDCCConfig.h:63
std::string m_dcc_url
Definition: ODDCCConfig.h:62
std::string m_wei
Definition: ODDCCConfig.h:67
void ODDCCConfig::fetchData ( ODDCCConfig result)
throw (std::runtime_error
)
private

Definition at line 207 of file ODDCCConfig.cc.

References ExpressReco_HICollisions_FallBack::e, and query::result.

209 {
210  this->checkConnection();
211  // result->clear();
212  int idid=0;
213  if(result->getId()==0 && (result->getConfigTag()=="") ){
214  // throw(std::runtime_error("ODDCCConfig::fetchData(): no Id defined for this ODDCCConfig "));
215  idid=result->fetchID();
216  }
217 
218  try {
219 
220  m_readStmt->setSQL("SELECT * "
221  "FROM ECAL_DCC_CONFIGURATION "
222  " where dcc_configuration_id = :1 or dcc_tag=:2 " );
223  m_readStmt->setInt(1, result->getId());
224  m_readStmt->setString(2, result->getConfigTag());
225  ResultSet* rset = m_readStmt->executeQuery();
226 
227  rset->next();
228 
229  // 1 is the id and 2 is the config tag
230 
231  result->setId(rset->getInt(1));
232  result->setConfigTag(rset->getString(2));
233  result->setDCCConfigurationUrl(rset->getString(3));
234  result->setTestPatternFileUrl(rset->getString(4));
235  result->setNTestPatternsToLoad(rset->getInt(5));
236  result->setSMHalf(rset->getInt(6));
237 
238  Clob clob = rset->getClob (7);
239  m_size = clob.length();
240  Stream *instream = clob.getStream (1,0);
241  unsigned char *buffer = new unsigned char[m_size];
242  memset (buffer, 0, m_size);
243  instream->readBuffer ((char*)buffer, m_size);
244  /*
245  cout << "Opening the clob in Read only mode" << endl;
246  clob.open (OCCI_LOB_READONLY);
247  int clobLength=clob.length ();
248  cout << "Length of the clob is: " << clobLength << endl;
249  m_size=clobLength;
250  unsigned char* buffer = readClob (clob, m_size);
251  clob.close ();
252  cout<< "the clob buffer is:"<<endl;
253  for (int i = 0; i < clobLength; ++i)
254  cout << (char) buffer[i];
255  cout << endl;
256 
257 
258  */
259  result->setDCCClob(buffer );
260  result->setDCCWeightsMode(rset->getString(8));
261 
262 
263  } catch (SQLException &e) {
264  throw(std::runtime_error("ODDCCConfig::fetchData(): "+e.getMessage()));
265  }
266 }
oracle::occi::Stream Stream
Definition: IODConfig.h:24
unsigned int m_size
Definition: ODDCCConfig.h:66
void setNTestPatternsToLoad(int id)
Definition: ODDCCConfig.h:35
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getId() const
Definition: ODDCCConfig.h:25
void setDCCWeightsMode(std::string x)
Definition: ODDCCConfig.h:44
oracle::occi::Clob Clob
Definition: IODConfig.h:25
void setTestPatternFileUrl(std::string x)
Definition: ODDCCConfig.h:32
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
void setSMHalf(int id)
Definition: ODDCCConfig.h:38
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setDCCConfigurationUrl(std::string x)
Definition: ODDCCConfig.h:29
void setId(int id)
Definition: ODDCCConfig.h:24
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
void setDCCClob(unsigned char *x)
Definition: ODDCCConfig.h:41
void checkConnection() const
Definition: IDBObject.h:41
int ODDCCConfig::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 270 of file ODDCCConfig.cc.

References ExpressReco_HICollisions_FallBack::e.

271 {
272  if (m_ID!=0) {
273  return m_ID;
274  }
275 
276  this->checkConnection();
277 
278  try {
279  Statement* stmt = m_conn->createStatement();
280  stmt->setSQL("SELECT DCC_configuration_id FROM ecal_dcc_configuration "
281  "WHERE dcc_tag=:dcc_tag "
282  );
283 
284  stmt->setString(1, getConfigTag() );
285 
286 
287  ResultSet* rset = stmt->executeQuery();
288 
289  if (rset->next()) {
290  m_ID = rset->getInt(1);
291  } else {
292  m_ID = 0;
293  }
294  m_conn->terminateStatement(stmt);
295  } catch (SQLException &e) {
296  throw(std::runtime_error("ODDCCConfig::fetchID: "+e.getMessage()));
297  }
298 
299 
300  return m_ID;
301 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
std::string getConfigTag()
Definition: IODConfig.h:32
void checkConnection() const
Definition: IDBObject.h:41
int ODDCCConfig::fetchNextId ( )
throw (std::runtime_error
)
private

Definition at line 35 of file ODDCCConfig.cc.

References ExpressReco_HICollisions_FallBack::e, and query::result.

35  {
36 
37  int result=0;
38  try {
39  this->checkConnection();
40 
41  m_readStmt = m_conn->createStatement();
42  m_readStmt->setSQL("select ecal_dcc_config_sq.NextVal from dual");
43  ResultSet* rset = m_readStmt->executeQuery();
44  while (rset->next ()){
45  result= rset->getInt(1);
46  }
47  m_conn->terminateStatement(m_readStmt);
48  return result;
49 
50  } catch (SQLException &e) {
51  throw(std::runtime_error("ODDCCConfig::fetchNextId(): "+e.getMessage()));
52  }
53 
54 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
unsigned char* ODDCCConfig::getDCCClob ( ) const
inline

Definition at line 42 of file ODDCCConfig.h.

References m_dcc_clob.

42 { return m_dcc_clob; }
unsigned char * m_dcc_clob
Definition: ODDCCConfig.h:61
unsigned int ODDCCConfig::getDCCClobSize ( ) const
inline

Definition at line 43 of file ODDCCConfig.h.

References m_size.

43 { return m_size; }
unsigned int m_size
Definition: ODDCCConfig.h:66
std::string ODDCCConfig::getDCCConfigurationUrl ( ) const
inline

Definition at line 30 of file ODDCCConfig.h.

References m_dcc_url.

30 { return m_dcc_url; }
std::string m_dcc_url
Definition: ODDCCConfig.h:62
std::string ODDCCConfig::getDCCWeightsMode ( ) const
inline

Definition at line 45 of file ODDCCConfig.h.

References m_wei.

45 { return m_wei; }
std::string m_wei
Definition: ODDCCConfig.h:67
int ODDCCConfig::getId ( ) const
inline

Definition at line 25 of file ODDCCConfig.h.

References m_ID.

25 { return m_ID; }
int ODDCCConfig::getNTestPatternsToLoad ( ) const
inline

Definition at line 36 of file ODDCCConfig.h.

References m_ntest.

36 { return m_ntest; }
unsigned int ODDCCConfig::getSize ( ) const
inline

Definition at line 27 of file ODDCCConfig.h.

References m_size.

27 { return m_size; }
unsigned int m_size
Definition: ODDCCConfig.h:66
int ODDCCConfig::getSMHalf ( ) const
inline

Definition at line 39 of file ODDCCConfig.h.

References m_sm_half.

39 { return m_sm_half; }
std::string ODDCCConfig::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 22 of file ODDCCConfig.h.

22 { return "ECAL_DCC_CONFIGURATION"; }
std::string ODDCCConfig::getTestPatternFileUrl ( ) const
inline

Definition at line 33 of file ODDCCConfig.h.

References m_test_url.

33 { return m_test_url; }
std::string m_test_url
Definition: ODDCCConfig.h:63
void ODDCCConfig::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 59 of file ODDCCConfig.cc.

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

61 {
62  this->checkConnection();
63 
64  int next_id=fetchNextId();
65 
66  try {
67  m_writeStmt = m_conn->createStatement();
68  m_writeStmt->setSQL("INSERT INTO ECAL_DCC_CONFIGURATION (dcc_configuration_id, dcc_tag, "
69  " DCC_CONFIGURATION_URL, TESTPATTERN_FILE_URL, "
70  " N_TESTPATTERNS_TO_LOAD , SM_HALF, weightsmode, "
71  " dcc_configuration) "
72  "VALUES (:1, :2, :3, :4, :5, :6 , :7 ,:8 )");
73  m_writeStmt->setInt(1, next_id);
74  m_writeStmt->setString(2, getConfigTag());
75  m_writeStmt->setString(3, getDCCConfigurationUrl());
76  m_writeStmt->setString(4, getTestPatternFileUrl());
77  m_writeStmt->setInt(5, getNTestPatternsToLoad());
78  m_writeStmt->setInt(6, getSMHalf());
79  m_writeStmt->setString(7, getDCCWeightsMode());
80 
81  // and now the clob
82  oracle::occi::Clob clob(m_conn);
83  clob.setEmpty();
84  m_writeStmt->setClob(8,clob);
85  m_writeStmt->executeUpdate ();
86  m_ID=next_id;
87 
88  m_conn->terminateStatement(m_writeStmt);
89  std::cout<<"DCC Clob inserted into CONFIGURATION with id="<<next_id<<std::endl;
90 
91  // now we read and update it
92  m_writeStmt = m_conn->createStatement();
93  m_writeStmt->setSQL ("SELECT dcc_configuration FROM ECAL_DCC_CONFIGURATION WHERE"
94  " dcc_configuration_id=:1 FOR UPDATE");
95 
96  std::cout<<"updating the clob 0"<<std::endl;
97 
98 
99 
100  } catch (SQLException &e) {
101  throw(std::runtime_error("ODDCCConfig::prepareWrite(): "+e.getMessage()));
102  }
103 
104  std::cout<<"updating the clob 1 "<<std::endl;
105 
106 
107 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
int fetchNextId()
Definition: ODDCCConfig.cc:35
std::string getTestPatternFileUrl() const
Definition: ODDCCConfig.h:33
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
int getNTestPatternsToLoad() const
Definition: ODDCCConfig.h:36
std::string getDCCConfigurationUrl() const
Definition: ODDCCConfig.h:30
std::string getDCCWeightsMode() const
Definition: ODDCCConfig.h:45
int getSMHalf() const
Definition: ODDCCConfig.h:39
std::string getConfigTag()
Definition: IODConfig.h:32
tuple cout
Definition: gather_cfg.py:41
void checkConnection() const
Definition: IDBObject.h:41
void ODDCCConfig::setDCCClob ( unsigned char *  x)
inline
void ODDCCConfig::setDCCConfigurationUrl ( std::string  x)
inline
void ODDCCConfig::setDCCWeightsMode ( std::string  x)
inline
void ODDCCConfig::setId ( int  id)
inline
void ODDCCConfig::setNTestPatternsToLoad ( int  id)
inline
void ODDCCConfig::setParameters ( std::map< std::string, std::string >  my_keys_map)

Definition at line 110 of file ODDCCConfig.cc.

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

110  {
111 
112  // parses the result of the XML parser that is a map of
113  // string string with variable name variable value
114 
115  for( std::map<std::string, std::string >::iterator ci=
116  my_keys_map.begin(); ci!=my_keys_map.end(); ci++ ) {
117 
118  if(ci->first== "DCC_CONFIGURATION_ID") setConfigTag(ci->second);
119  if(ci->first== "TESTPATTERN_FILE_URL") setTestPatternFileUrl(ci->second );
120  if(ci->first== "N_TESTPATTERNS_TO_LOAD") setNTestPatternsToLoad(atoi(ci->second.c_str() ));
121  if(ci->first== "SM_HALF") setSMHalf(atoi(ci->second.c_str() ));
122  if(ci->first== "WEIGHTSMODE") setDCCWeightsMode(ci->second.c_str() );
123  if(ci->first== "DCC_CONFIGURATION_URL") {
124  std::string fname=ci->second ;
125  setDCCConfigurationUrl(fname );
126 
127  // here we must open the file and read the DCC Clob
128  std::cout << "Going to read DCC file: " << fname << endl;
129 
130  ifstream inpFile;
131  inpFile.open(fname.c_str());
132 
133  // tell me size of file
134  int bufsize = 0;
135  inpFile.seekg( 0,ios::end );
136  bufsize = inpFile.tellg();
137  std::cout <<" bufsize ="<<bufsize<< std::endl;
138  // set file pointer to start again
139  inpFile.seekg( 0,ios::beg );
140 
141  m_size=bufsize;
142 
143  inpFile.close();
144 
145  }
146  }
147 
148 }
unsigned int m_size
Definition: ODDCCConfig.h:66
void setNTestPatternsToLoad(int id)
Definition: ODDCCConfig.h:35
void setDCCWeightsMode(std::string x)
Definition: ODDCCConfig.h:44
#define end
Definition: vmac.h:38
void setTestPatternFileUrl(std::string x)
Definition: ODDCCConfig.h:32
string fname
main script
void setSMHalf(int id)
Definition: ODDCCConfig.h:38
void setConfigTag(std::string x)
Definition: IODConfig.h:31
void setDCCConfigurationUrl(std::string x)
Definition: ODDCCConfig.h:29
tuple cout
Definition: gather_cfg.py:41
void ODDCCConfig::setSize ( unsigned int  id)
inline
void ODDCCConfig::setSMHalf ( int  id)
inline
void ODDCCConfig::setTestPatternFileUrl ( std::string  x)
inline
void ODDCCConfig::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 153 of file ODDCCConfig.cc.

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

155 {
156 
157 
158  std::cout<<"updating the clob "<<std::endl;
159 
160 
161  try {
162 
163 
164  m_writeStmt->setInt(1, m_ID);
165  ResultSet* rset = m_writeStmt->executeQuery();
166 
167  rset->next ();
168  oracle::occi::Clob clob = rset->getClob (1);
169 
170  cout << "Opening the clob in read write mode" << endl;
171 
172  std::cout << "Populating the clob" << endl;
173 
175  int clobLength=clob.length ();
176  cout << "Length of the clob is: " << clobLength << endl;
177 
178  m_writeStmt->executeUpdate();
179 
180  m_writeStmt->closeResultSet (rset);
181 
182  } catch (SQLException &e) {
183  throw(std::runtime_error("ODDCCConfig::writeDB(): "+e.getMessage()));
184  }
185  // Now get the ID
186  if (!this->fetchID()) {
187  throw(std::runtime_error("ODDCCConfig::writeDB: Failed to write"));
188  }
189 
190 
191 }
void populateClob(Clob &clob, std::string fname, unsigned int bufsize)
Definition: IODConfig.h:88
Statement * m_writeStmt
Definition: IODConfig.h:36
unsigned int m_size
Definition: ODDCCConfig.h:66
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:22
std::string getDCCConfigurationUrl() const
Definition: ODDCCConfig.h:30
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:21
tuple cout
Definition: gather_cfg.py:41

Friends And Related Function Documentation

friend class EcalCondDBInterface
friend

Definition at line 17 of file ODDCCConfig.h.

Member Data Documentation

unsigned char* ODDCCConfig::m_dcc_clob
private

Definition at line 61 of file ODDCCConfig.h.

Referenced by getDCCClob(), and setDCCClob().

std::string ODDCCConfig::m_dcc_url
private

Definition at line 62 of file ODDCCConfig.h.

Referenced by getDCCConfigurationUrl(), and setDCCConfigurationUrl().

int ODDCCConfig::m_ID
private

Definition at line 60 of file ODDCCConfig.h.

Referenced by getId(), and setId().

int ODDCCConfig::m_ntest
private

Definition at line 64 of file ODDCCConfig.h.

Referenced by getNTestPatternsToLoad(), and setNTestPatternsToLoad().

unsigned int ODDCCConfig::m_size
private

Definition at line 66 of file ODDCCConfig.h.

Referenced by getDCCClobSize(), getSize(), and setSize().

int ODDCCConfig::m_sm_half
private

Definition at line 65 of file ODDCCConfig.h.

Referenced by getSMHalf(), and setSMHalf().

std::string ODDCCConfig::m_test_url
private

Definition at line 63 of file ODDCCConfig.h.

Referenced by getTestPatternFileUrl(), and setTestPatternFileUrl().

std::string ODDCCConfig::m_wei
private

Definition at line 67 of file ODDCCConfig.h.

Referenced by getDCCWeightsMode(), and setDCCWeightsMode().