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
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)
 
std::string name ()
 
 OraMainTable (coral::ISchema &dbSchema)
 
std::string schemaVersion ()
 
void setParameter (const std::string &paramName, const std::string &paramValue)
 
virtual ~OraMainTable ()
 
- Public Member Functions inherited from ora::IMainTable
 IMainTable (coral::ISchema &schema)
 
virtual ~IMainTable ()
 
- Public Member Functions inherited from ora::IDatabaseTable
 IDatabaseTable (coral::ISchema &schema)
 
coral::ISchema & schema ()
 
virtual void setAccessPermission (const std::string &principal, bool forWrite)
 
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 userSchemaVersionParameterName ()
 
static std::string versionParameterName ()
 

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  IMainTable( dbSchema ){
38 }
IMainTable(coral::ISchema &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 84 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema, AlCaHLTBitMon_QueryRunRegistry::string, table, ora::throwException(), BeamSplash_cfg::version, and ora::IMainTable::versionParameterName().

84  {
85  if( schema().existsTable( tableName() )){
86  throwException( "ORA database main table already exists in this schema.",
87  "OraMainTable::create");
88  }
89 
90  coral::TableDescription descr( "OraDb" );
91  descr.setName( tableName() );
92  descr.insertColumn( parameterNameColumn(),
93  coral::AttributeSpecification::typeNameForType<std::string>() );
94  descr.insertColumn( parameterValueColumn(),
95  coral::AttributeSpecification::typeNameForType<std::string>() );
96  descr.setNotNullConstraint( parameterNameColumn() );
97  descr.setNotNullConstraint( parameterValueColumn() );
98  descr.setPrimaryKey( std::vector<std::string>( 1, parameterNameColumn() ) );
99 
100  coral::ITable& table = schema().createTable( descr );
101 
102  coral::AttributeList dataToInsert;
103  dataToInsert.extend<std::string>( parameterNameColumn());
104  dataToInsert.extend<std::string>( parameterValueColumn());
106  dataToInsert[ parameterValueColumn() ].data<std::string>() = version();
107  table.dataEditor().insertRow( dataToInsert );
108 }
static std::string versionParameterName()
static std::string tableName()
#define table(NAME)
Definition: DbCore.h:49
coral::ISchema & schema()
static std::string parameterNameColumn()
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
static std::string version()
static std::string parameterValueColumn()
void ora::OraMainTable::drop ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 110 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema.

110  {
111  schema().dropIfExistsTable( tableName() );
112 }
static std::string tableName()
coral::ISchema & schema()
bool ora::OraMainTable::exists ( )
virtual

Implements ora::IDatabaseTable.

Definition at line 80 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema.

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

80  {
81  return schema().existsTable( tableName() );
82 }
static std::string tableName()
coral::ISchema & schema()
bool ora::OraMainTable::getParameters ( std::map< std::string, std::string > &  destination)
virtual

Implements ora::IMainTable.

Definition at line 56 of file OraDatabaseSchema.cc.

References o2o::query, run_regression::ret, python.IdGenerator::schema, and AlCaHLTBitMon_QueryRunRegistry::string.

56  {
57  bool ret = false;
58  coral::ITable& mainTable = schema().tableHandle( tableName() );
59  std::auto_ptr<coral::IQuery> query(mainTable.newQuery());
60  coral::ICursor& cursor = query->execute();
61  while ( cursor.next() ) {
62  ret = true;
63  const coral::AttributeList& row = cursor.currentRow();
64  std::string paramName = row[ parameterNameColumn()].data< std::string >();
65  std::string paramValue = row[ parameterValueColumn()].data< std::string >();
66  dest.insert( std::make_pair( paramName, paramValue ) );
67  }
68  return ret;
69 }
static std::string tableName()
coral::ISchema & schema()
static std::string parameterNameColumn()
tuple query
Definition: o2o.py:269
static std::string parameterValueColumn()
std::string ora::OraMainTable::name ( )
virtual
std::string ora::OraMainTable::parameterNameColumn ( )
static

Definition at line 26 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

26  {
27  static const 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.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

Implements ora::IMainTable.

Definition at line 71 of file OraDatabaseSchema.cc.

References BeamSplash_cfg::version.

71  {
72  // could be replaced by a call to getParameters in case of needs to distinguish between ora db schema versions...
73  return version();
74 }
static std::string version()
void ora::OraMainTable::setParameter ( const std::string &  paramName,
const std::string &  paramValue 
)
virtual

Implements ora::IMainTable.

Definition at line 43 of file OraDatabaseSchema.cc.

References python.IdGenerator::schema, AlCaHLTBitMon_QueryRunRegistry::string, and table.

Referenced by editorTools.UserCodeTool::__call__(), HiCoreTools.RestrictInputToAOD::__call__(), coreTools.RunOnData::__call__(), trackTools.MakeAODTrackCandidates::__call__(), metTools.AddMETCollection::__call__(), editorTools.ChangeSource::__call__(), HiCoreTools.RemoveMCMatching::__call__(), cmsswVersionTools.PickRelValInputFiles::__call__(), jetTools.AddJetCollection::__call__(), coreTools.RemoveMCMatching::__call__(), trackTools.MakePATTrackCandidates::__call__(), trigTools.SwitchOnTrigger::__call__(), HiCoreTools.RemoveAllPATObjectsBut::__call__(), HiCoreTools.RemoveSpecificPATObjects::__call__(), trigTools.SwitchOnTriggerStandAlone::__call__(), trackTools.MakeTrackCandidates::__call__(), tauTools.AddTauCollection::__call__(), trigTools.SwitchOnTriggerMatching::__call__(), HiCoreTools.RemoveCleaning::__call__(), HiCoreTools.AddCleaning::__call__(), trigTools.SwitchOnTriggerMatchingStandAlone::__call__(), trigTools.SwitchOnTriggerMatchEmbedding::__call__(), jetTools.SwitchJetCollection::__call__(), jetTools.AddJetID::__call__(), jetTools.SetTagInfos::__call__(), and metUncertaintyTools.RunMEtUncertainties::__call__().

44  {
45  if( !paramName.empty() && !paramValue.empty() ){
46  coral::ITable& table = schema().tableHandle( tableName() );
47  coral::AttributeList dataToInsert;
48  dataToInsert.extend<std::string>( parameterNameColumn());
49  dataToInsert.extend<std::string>( parameterValueColumn());
50  dataToInsert[ parameterNameColumn() ].data<std::string>() = paramName;
51  dataToInsert[ parameterValueColumn() ].data<std::string>() = paramValue;
52  table.dataEditor().insertRow( dataToInsert );
53  }
54 }
static std::string tableName()
#define table(NAME)
Definition: DbCore.h:49
coral::ISchema & schema()
static std::string parameterNameColumn()
static std::string parameterValueColumn()
std::string ora::OraMainTable::tableName ( )
static

Definition at line 21 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

21  {
22  static const 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.

References AlCaHLTBitMon_QueryRunRegistry::string.

16  {
17  static const std::string s_version("1.1.0");
18  return s_version;
19 }