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

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

Constructor & Destructor Documentation

ODTTCciConfig::ODTTCciConfig ( )

Definition at line 15 of file ODTTCciConfig.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_config_tag="";
24  m_ID=0;
25  clear();
26  m_size=0;
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
#define NULL
Definition: scimark2.h:8
std::string m_config_tag
Definition: IODConfig.h:27
std::string m_configuration_script
Definition: ODTTCciConfig.h:62
std::string m_configuration_script_params
Definition: ODTTCciConfig.h:63
Statement * m_readStmt
Definition: IODConfig.h:37
ODTTCciConfig::~ODTTCciConfig ( )

Definition at line 39 of file ODTTCciConfig.cc.

40 {
41 }

Member Function Documentation

void ODTTCciConfig::clear ( void  )
private

Definition at line 29 of file ODTTCciConfig.cc.

References gather_cfg::cout.

29  {
30  std::cout <<"entering clear" << std::endl;
31  m_ttcci_file="";
34  m_trg_mode="";
35  m_trg_sleep=0;
36 
37 }
std::string m_configuration_script
Definition: ODTTCciConfig.h:62
std::string m_ttcci_file
Definition: ODTTCciConfig.h:61
std::string m_trg_mode
Definition: ODTTCciConfig.h:64
std::string m_configuration_script_params
Definition: ODTTCciConfig.h:63
tuple cout
Definition: gather_cfg.py:145
void ODTTCciConfig::fetchData ( ODTTCciConfig result)
throw (std::runtime_error
)
private

Definition at line 207 of file ODTTCciConfig.cc.

References gather_cfg::cout, alignCSCRings::e, i, and mps_fire::result.

209 {
210  this->checkConnection();
211  result->clear();
212  if(result->getId()==0 && (result->getConfigTag()=="") ){
213  throw(std::runtime_error("ODTTCciConfig::fetchData(): no Id defined for this ODTTCciConfig "));
214  }
215 
216  try {
217 
218  m_readStmt->setSQL("SELECT * "
219  "FROM ECAL_TTCci_CONFIGURATION "
220  " where ( ttcci_configuration_id = :1 or ttcci_tag=:2 )" );
221  m_readStmt->setInt(1, result->getId());
222  m_readStmt->setString(2, result->getConfigTag());
223  ResultSet* rset = m_readStmt->executeQuery();
224 
225  rset->next();
226  // 1 is the id and 2 is the config tag
227 
228  result->setId(rset->getInt(1));
229  result->setConfigTag(rset->getString(2));
230 
231 
232  result->setTTCciConfigurationFile(rset->getString(3));
233  result->setTrgMode(rset->getString(4));
234  result->setTrgSleep(rset->getInt(5));
235 
236  result->setConfigurationScript(rset->getString(7));
237  result->setConfigurationScriptParams(rset->getString(8));
238 
239  Clob clob = rset->getClob (6);
240  cout << "Opening the clob in Read only mode" << endl;
241  clob.open (OCCI_LOB_READONLY);
242  int clobLength=clob.length ();
243  cout << "Length of the clob is: " << clobLength << endl;
244  m_size=clobLength;
245  unsigned char* buffer = readClob (clob, m_size);
246  clob.close ();
247  cout<< "the clob buffer is:"<<endl;
248  for (int i = 0; i < clobLength; ++i)
249  cout << (char) buffer[i];
250  cout << endl;
251 
252 
253  result->setTTCciClob(buffer );
254 
255  } catch (SQLException &e) {
256  throw(std::runtime_error("ODTTCciConfig::fetchData(): "+e.getMessage()));
257  }
258 }
int i
Definition: DBlmapReader.cc:9
void setConfigurationScript(std::string x)
Definition: ODTTCciConfig.h:30
void setTTCciClob(unsigned char *x)
Definition: ODTTCciConfig.h:41
unsigned char * readClob(Clob &clob, int size)
Definition: IODConfig.h:160
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
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:36
int getId() const
Definition: ODTTCciConfig.h:25
oracle::occi::Clob Clob
Definition: IODConfig.h:25
void setConfigurationScriptParams(std::string x)
Definition: ODTTCciConfig.h:32
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
void setTrgSleep(int id)
Definition: ODTTCciConfig.h:38
void setConfigTag(std::string x)
Definition: IODConfig.h:31
Statement * m_readStmt
Definition: IODConfig.h:37
std::string getConfigTag()
Definition: IODConfig.h:32
tuple cout
Definition: gather_cfg.py:145
void checkConnection() const
Definition: IDBObject.h:41
int ODTTCciConfig::fetchID ( )
throw (std::runtime_error
)
private

Definition at line 262 of file ODTTCciConfig.cc.

References alignCSCRings::e.

263 {
264  if (m_ID!=0) {
265  return m_ID;
266  }
267 
268  this->checkConnection();
269 
270  try {
271  Statement* stmt = m_conn->createStatement();
272  stmt->setSQL("SELECT ttcci_configuration_id FROM ecal_ttcci_configuration "
273  "WHERE ttcci_tag=:ttcci_tag "
274  );
275 
276  stmt->setString(1, getConfigTag() );
277 
278  ResultSet* rset = stmt->executeQuery();
279 
280  if (rset->next()) {
281  m_ID = rset->getInt(1);
282  } else {
283  m_ID = 0;
284  }
285  m_conn->terminateStatement(stmt);
286  } catch (SQLException &e) {
287  throw(std::runtime_error("ODTTCciConfig::fetchID: "+e.getMessage()));
288  }
289  return m_ID;
290 }
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 ODTTCciConfig::fetchNextId ( )
throw (std::runtime_error
)
private

Definition at line 43 of file ODTTCciConfig.cc.

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

43  {
44 
45  int result=0;
46  try {
47  this->checkConnection();
48 
49  m_readStmt = m_conn->createStatement();
50  m_readStmt->setSQL("select ecal_ttcci_config_sq.NextVal from dual");
51  ResultSet* rset = m_readStmt->executeQuery();
52  while (rset->next ()){
53  result= rset->getInt(1);
54  }
55  m_conn->terminateStatement(m_readStmt);
56  return result;
57 
58  } catch (SQLException &e) {
59  throw(std::runtime_error("ODTTCciConfig::fetchNextId(): "+e.getMessage()));
60  }
61 
62 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
tuple result
Definition: mps_fire.py:83
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
Statement * m_readStmt
Definition: IODConfig.h:37
void checkConnection() const
Definition: IDBObject.h:41
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:62
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:63
int ODTTCciConfig::getId ( ) 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 44 of file ODTTCciConfig.h.

References m_size.

44 { return m_size; }
std::string ODTTCciConfig::getTable ( )
inlinevirtual

Implements IODConfig.

Definition at line 22 of file ODTTCciConfig.h.

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

Definition at line 37 of file ODTTCciConfig.h.

References m_trg_mode.

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

Definition at line 39 of file ODTTCciConfig.h.

References m_trg_sleep.

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

Definition at line 42 of file ODTTCciConfig.h.

References m_ttcci_clob.

42 { return m_ttcci_clob; }
unsigned char * m_ttcci_clob
Definition: ODTTCciConfig.h:60
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:61
void ODTTCciConfig::prepareWrite ( )
throw (std::runtime_error
)
privatevirtual

Implements IODConfig.

Definition at line 67 of file ODTTCciConfig.cc.

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

69 {
70  this->checkConnection();
71 
72  int next_id=fetchNextId();
73 
74  try {
75  m_writeStmt = m_conn->createStatement();
76  m_writeStmt->setSQL("INSERT INTO ECAL_TTCci_CONFIGURATION (ttcci_configuration_id, ttcci_tag, "
77  " TTCCI_configuration_file, TRG_MODE, TRG_SLEEP, Configuration, configuration_script, configuration_script_params ) "
78  "VALUES (:1, :2, :3, :4, :5, :6, :7, :8 )");
79  m_writeStmt->setInt(1, next_id);
80  m_writeStmt->setString(2, getConfigTag());
81  m_writeStmt->setString(3, getTTCciConfigurationFile());
82  m_writeStmt->setString(4, getTrgMode());
83  m_writeStmt->setInt(5, getTrgSleep());
84  m_writeStmt->setString(7, getConfigurationScript());
86 
87  // and now the clob
88  oracle::occi::Clob clob(m_conn);
89  clob.setEmpty();
90  m_writeStmt->setClob(6,clob);
91  m_writeStmt->executeUpdate ();
92  m_ID=next_id;
93 
94  m_conn->terminateStatement(m_writeStmt);
95  std::cout<<"TTCci Clob inserted into CONFIGURATION with id="<<next_id<<std::endl;
96 
97  // now we read and update it
98  m_writeStmt = m_conn->createStatement();
99  m_writeStmt->setSQL ("SELECT Configuration FROM ECAL_TTCci_CONFIGURATION WHERE"
100  " ttcci_configuration_id=:1 FOR UPDATE");
101 
102  std::cout<<"updating the clob 0"<<std::endl;
103 
104 
105  } catch (SQLException &e) {
106  throw(std::runtime_error("ODTTCciConfig::prepareWrite(): "+e.getMessage()));
107  }
108 
109  std::cout<<"updating the clob 1 "<<std::endl;
110 
111 }
oracle::occi::Connection * m_conn
Definition: IDBObject.h:39
Statement * m_writeStmt
Definition: IODConfig.h:36
std::string getConfigurationScript() const
Definition: ODTTCciConfig.h:31
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string getTTCciConfigurationFile() const
Definition: ODTTCciConfig.h:28
int getTrgSleep() const
Definition: ODTTCciConfig.h:39
std::string getConfigurationScriptParams() const
Definition: ODTTCciConfig.h:33
std::string getConfigTag()
Definition: IODConfig.h:32
tuple cout
Definition: gather_cfg.py:145
void checkConnection() const
Definition: IDBObject.h:41
std::string getTrgMode() const
Definition: ODTTCciConfig.h:37
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:62
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:63
void ODTTCciConfig::setId ( int  id)
inline

Definition at line 24 of file ODTTCciConfig.h.

References m_ID.

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

Definition at line 113 of file ODTTCciConfig.cc.

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

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

Definition at line 43 of file ODTTCciConfig.h.

References m_size.

43 { m_size = id; }
void ODTTCciConfig::setTrgMode ( std::string  x)
inline

Definition at line 36 of file ODTTCciConfig.h.

References m_trg_mode, and x.

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

Definition at line 38 of file ODTTCciConfig.h.

References m_trg_sleep.

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

Definition at line 41 of file ODTTCciConfig.h.

References m_ttcci_clob, and x.

41 { m_ttcci_clob = x; }
unsigned char * m_ttcci_clob
Definition: ODTTCciConfig.h:60
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:61
void ODTTCciConfig::writeDB ( )
throw (std::runtime_error
)
private

Definition at line 163 of file ODTTCciConfig.cc.

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

165 {
166 
167 
168  std::cout<<"updating the clob 2"<<std::endl;
169 
170 
171  try {
172 
173 
174  m_writeStmt->setInt(1, m_ID);
175  ResultSet* rset = m_writeStmt->executeQuery();
176 
177  while (rset->next ())
178  {
179  oracle::occi::Clob clob = rset->getClob (1);
180  cout << "Opening the clob in read write mode" << endl;
181  cout << "Populating the clob" << endl;
183  int clobLength=clob.length ();
184  cout << "Length of the clob is: " << clobLength << endl;
185  // clob.close ();
186  }
187 
188  m_writeStmt->executeUpdate();
189 
190  m_writeStmt->closeResultSet (rset);
191 
192  } catch (SQLException &e) {
193  throw(std::runtime_error("ODTTCciConfig::writeDB(): "+e.getMessage()));
194  }
195  // Now get the ID
196  if (!this->fetchID()) {
197  throw(std::runtime_error("ODTTCciConfig::writeDB: Failed to write"));
198  }
199 
200 }
void populateClob(Clob &clob, std::string fname, unsigned int bufsize)
Definition: IODConfig.h:88
Statement * m_writeStmt
Definition: IODConfig.h:36
oracle::occi::SQLException SQLException
Definition: HcalDbOmds.cc:27
std::string getTTCciConfigurationFile() const
Definition: ODTTCciConfig.h:28
oracle::occi::ResultSet ResultSet
Definition: HcalDbOmds.cc:26
tuple cout
Definition: gather_cfg.py:145

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 62 of file ODTTCciConfig.h.

Referenced by getConfigurationScript(), and setConfigurationScript().

std::string ODTTCciConfig::m_configuration_script_params
private

Definition at line 63 of file ODTTCciConfig.h.

Referenced by getConfigurationScriptParams(), and setConfigurationScriptParams().

int ODTTCciConfig::m_ID
private

Definition at line 59 of file ODTTCciConfig.h.

Referenced by getId(), and setId().

int ODTTCciConfig::m_size
private

Definition at line 66 of file ODTTCciConfig.h.

Referenced by getSize(), and setSize().

std::string ODTTCciConfig::m_trg_mode
private

Definition at line 64 of file ODTTCciConfig.h.

Referenced by getTrgMode(), and setTrgMode().

int ODTTCciConfig::m_trg_sleep
private

Definition at line 65 of file ODTTCciConfig.h.

Referenced by getTrgSleep(), and setTrgSleep().

unsigned char* ODTTCciConfig::m_ttcci_clob
private

Definition at line 60 of file ODTTCciConfig.h.

Referenced by getTTCciClob(), and setTTCciClob().

std::string ODTTCciConfig::m_ttcci_file
private

Definition at line 61 of file ODTTCciConfig.h.

Referenced by getTTCciConfigurationFile(), and setTTCciConfigurationFile().