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 (const 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 hitfit::clear(), and 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.

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 alignCSCRings::e, and query::result.

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

References alignCSCRings::e.

270 {
271  if (m_ID!=0) {
272  return m_ID;
273  }
274 
275  this->checkConnection();
276 
277  try {
278  Statement* stmt = m_conn->createStatement();
279  stmt->setSQL("SELECT DCC_configuration_id FROM ecal_dcc_configuration "
280  "WHERE dcc_tag=:dcc_tag "
281  );
282 
283  stmt->setString(1, getConfigTag() );
284 
285 
286  ResultSet* rset = stmt->executeQuery();
287 
288  if (rset->next()) {
289  m_ID = rset->getInt(1);
290  } else {
291  m_ID = 0;
292  }
293  m_conn->terminateStatement(stmt);
294  } catch (SQLException &e) {
295  throw(std::runtime_error("ODDCCConfig::fetchID: "+e.getMessage()));
296  }
297 
298 
299  return m_ID;
300 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
oracle::occi::Statement Statement
Definition: IODConfig.h:23
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
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 alignCSCRings::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:27
tuple result
Definition: query.py:137
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
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.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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.

Referenced by popcon::EcalSRPHandler::getNewObjects().

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 alignCSCRings::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:27
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:121
void checkConnection() const
Definition: IDBObject.h:41
void ODDCCConfig::setDCCClob ( unsigned char *  x)
inline

Definition at line 41 of file ODDCCConfig.h.

References m_dcc_clob, and x.

41 { m_dcc_clob = x; }
unsigned char * m_dcc_clob
Definition: ODDCCConfig.h:61
void ODDCCConfig::setDCCConfigurationUrl ( std::string  x)
inline

Definition at line 29 of file ODDCCConfig.h.

References m_dcc_url, and x.

29 { m_dcc_url = x; }
std::string m_dcc_url
Definition: ODDCCConfig.h:62
void ODDCCConfig::setDCCWeightsMode ( std::string  x)
inline

Definition at line 44 of file ODDCCConfig.h.

References m_wei, and x.

44 { m_wei = x; }
std::string m_wei
Definition: ODDCCConfig.h:67
void ODDCCConfig::setId ( int  id)
inline

Definition at line 24 of file ODDCCConfig.h.

References m_ID.

Referenced by popcon::EcalSRPHandler::getNewObjects().

24 { m_ID = id; }
void ODDCCConfig::setNTestPatternsToLoad ( int  id)
inline

Definition at line 35 of file ODDCCConfig.h.

References m_ntest.

35 { m_ntest = id; }
void ODDCCConfig::setParameters ( const std::map< std::string, std::string > &  my_keys_map)

Definition at line 110 of file ODDCCConfig.cc.

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

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 >::const_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:37
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:121
void ODDCCConfig::setSize ( unsigned int  id)
inline

Definition at line 26 of file ODDCCConfig.h.

References m_size.

26 { m_size = id; }
unsigned int m_size
Definition: ODDCCConfig.h:66
void ODDCCConfig::setSMHalf ( int  id)
inline

Definition at line 38 of file ODDCCConfig.h.

References m_sm_half.

38 { m_sm_half = id; }
void ODDCCConfig::setTestPatternFileUrl ( std::string  x)
inline

Definition at line 32 of file ODDCCConfig.h.

References m_test_url, and x.

32 { m_test_url = x; }
std::string m_test_url
Definition: ODDCCConfig.h:63
void ODDCCConfig::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 153 of file ODDCCConfig.cc.

References gather_cfg::cout, and alignCSCRings::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:27
std::string getDCCConfigurationUrl() const
Definition: ODDCCConfig.h:30
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple cout
Definition: gather_cfg.py:121

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().