CMS 3D CMS Logo

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

#include <OraDatabaseSchema.h>

Inheritance diagram for ora::OraMainTable:
ora::IMainTable ora::IDatabaseTable

Public Member Functions

void create ()
 
void drop ()
 
bool exists ()
 
bool getParameters (std::map< std::string, std::string > &destination)
 
 OraMainTable (coral::ISchema &dbSchema)
 
std::string schemaVersion ()
 
virtual ~OraMainTable ()
 
- Public Member Functions inherited from ora::IMainTable
virtual ~IMainTable ()
 
- Public Member Functions inherited from ora::IDatabaseTable
virtual ~IDatabaseTable ()
 

Static Public Member Functions

static std::string parameterNameColumn ()
 
static std::string parameterValueColumn ()
 
static std::string tableName ()
 
static std::string version ()
 
- Static Public Member Functions inherited from ora::IMainTable
static std::string versionParameterName ()
 

Private Attributes

coral::ISchema & m_schema
 

Detailed Description

Definition at line 10 of file OraDatabaseSchema.h.

Constructor & Destructor Documentation

ora::OraMainTable::OraMainTable ( coral::ISchema &  dbSchema)
explicit

Definition at line 36 of file OraDatabaseSchema.cc.

36  :
37  m_schema( dbSchema ){
38 }
coral::ISchema & m_schema
ora::OraMainTable::~OraMainTable ( )
virtual

Definition at line 40 of file OraDatabaseSchema.cc.

40  {
41 }

Member Function Documentation

void ora::OraMainTable::create ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 67 of file OraDatabaseSchema.cc.

References asciidump::table, ora::throwException(), AlCaRecoCosmics_cfg::version, and ora::IMainTable::versionParameterName().

67  {
68  if( m_schema.existsTable( tableName() )){
69  throwException( "ORA database main table already exists in this schema.",
70  "OraMainTable::create");
71  }
72 
73  coral::TableDescription descr( "OraDb" );
74  descr.setName( tableName() );
75  descr.insertColumn( parameterNameColumn(),
76  coral::AttributeSpecification::typeNameForType<std::string>() );
77  descr.insertColumn( parameterValueColumn(),
78  coral::AttributeSpecification::typeNameForType<std::string>() );
79  descr.setNotNullConstraint( parameterNameColumn() );
80  descr.setNotNullConstraint( parameterValueColumn() );
81  descr.setPrimaryKey( std::vector<std::string>( 1, parameterNameColumn() ) );
82 
83  coral::ITable& table = m_schema.createTable( descr );
84  table.privilegeManager().grantToPublic( coral::ITablePrivilegeManager::Select );
85 
86  coral::AttributeList dataToInsert;
87  dataToInsert.extend<std::string>( parameterNameColumn());
88  dataToInsert.extend<std::string>( parameterValueColumn());
89  dataToInsert[ parameterNameColumn() ].data<std::string>() = IMainTable::versionParameterName();
90  dataToInsert[ parameterValueColumn() ].data<std::string>() = version();
91  table.dataEditor().insertRow( dataToInsert );
92 }
static std::string versionParameterName()
list table
Definition: asciidump.py:386
coral::ISchema & m_schema
static std::string tableName()
static std::string parameterNameColumn()
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
static std::string version()
static std::string parameterValueColumn()
void ora::OraMainTable::drop ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 94 of file OraDatabaseSchema.cc.

94  {
95  m_schema.dropIfExistsTable( tableName() );
96 }
coral::ISchema & m_schema
static std::string tableName()
bool ora::OraMainTable::exists ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 63 of file OraDatabaseSchema.cc.

Referenced by ora::OraDatabaseSchema::existsMainTable().

63  {
64  return m_schema.existsTable( tableName() );
65 }
coral::ISchema & m_schema
static std::string tableName()
bool ora::OraMainTable::getParameters ( std::map< std::string, std::string > &  destination)
virtual

Implements ora::IMainTable.

Definition at line 43 of file OraDatabaseSchema.cc.

References o2o::query, and runTheMatrix::ret.

43  {
44  bool ret = false;
45  coral::ITable& mainTable = m_schema.tableHandle( tableName() );
46  std::auto_ptr<coral::IQuery> query(mainTable.newQuery());
47  coral::ICursor& cursor = query->execute();
48  while ( cursor.next() ) {
49  ret = true;
50  const coral::AttributeList& row = cursor.currentRow();
51  std::string paramName = row[ parameterNameColumn()].data< std::string >();
52  std::string paramValue = row[ parameterValueColumn()].data< std::string >();
53  dest.insert( std::make_pair( paramName, paramValue ) );
54  }
55  return ret;
56 }
coral::ISchema & m_schema
static std::string tableName()
static std::string parameterNameColumn()
tuple query
Definition: o2o.py:269
static std::string parameterValueColumn()
std::string ora::OraMainTable::parameterNameColumn ( )
static

Definition at line 26 of file OraDatabaseSchema.cc.

26  {
27  static std::string s_column("PARAMETER_NAME");
28  return s_column;
29 }
std::string ora::OraMainTable::parameterValueColumn ( )
static

Definition at line 31 of file OraDatabaseSchema.cc.

31  {
32  static std::string s_column("PARAMETER_VALUE");
33  return s_column;
34 }
std::string ora::OraMainTable::schemaVersion ( )
virtual

Implements ora::IMainTable.

Definition at line 58 of file OraDatabaseSchema.cc.

References AlCaRecoCosmics_cfg::version.

58  {
59  // could be replaced by a call to getParameters in case of needs to distinguish between ora db schema versions...
60  return version();
61 }
static std::string version()
std::string ora::OraMainTable::tableName ( )
static

Definition at line 21 of file OraDatabaseSchema.cc.

21  {
22  static std::string s_name("ORA_DB");
23  return s_name;
24 }
std::string ora::OraMainTable::version ( )
static

Definition at line 16 of file OraDatabaseSchema.cc.

16  {
17  static std::string s_version("V1.0");
18  return s_version;
19 }

Member Data Documentation

coral::ISchema& ora::OraMainTable::m_schema
private

Definition at line 26 of file OraDatabaseSchema.h.