CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions

ora::OraMainTable Class Reference

#include <OraDatabaseSchema.h>

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

List of all members.

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

Static Public Member Functions

static std::string parameterNameColumn ()
static std::string parameterValueColumn ()
static std::string tableName ()
static std::string version ()

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.

                                                     :
  IMainTable( dbSchema ){
}
ora::OraMainTable::~OraMainTable ( ) [virtual]

Definition at line 40 of file OraDatabaseSchema.cc.

                              {
}

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, asciidump::table, ora::throwException(), BeamSplash_cfg::version, and ora::IMainTable::versionParameterName().

                            {
  if( schema().existsTable( tableName() )){
    throwException( "ORA database main table already exists in this schema.",
                    "OraMainTable::create");
  }
  
  coral::TableDescription descr( "OraDb" );
  descr.setName( tableName() );
  descr.insertColumn( parameterNameColumn(),
                      coral::AttributeSpecification::typeNameForType<std::string>() );
  descr.insertColumn( parameterValueColumn(),
                      coral::AttributeSpecification::typeNameForType<std::string>() );
  descr.setNotNullConstraint( parameterNameColumn() );
  descr.setNotNullConstraint( parameterValueColumn() );
  descr.setPrimaryKey( std::vector<std::string>( 1, parameterNameColumn() ) );

  coral::ITable& table = schema().createTable( descr );

  coral::AttributeList dataToInsert;
  dataToInsert.extend<std::string>( parameterNameColumn());
  dataToInsert.extend<std::string>( parameterValueColumn());
  dataToInsert[ parameterNameColumn() ].data<std::string>() = IMainTable::versionParameterName();
  dataToInsert[ parameterValueColumn() ].data<std::string>() = version();
  table.dataEditor().insertRow( dataToInsert );
}
void ora::OraMainTable::drop ( ) [virtual]

Implements ora::IDatabaseTable.

Definition at line 110 of file OraDatabaseSchema.cc.

References python::IdGenerator::schema.

                          {
  schema().dropIfExistsTable( tableName() );
}
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().

                            {
  return schema().existsTable( tableName() );
}
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.

                                                                      {
  bool ret = false;
  coral::ITable& mainTable = schema().tableHandle( tableName() );
  std::auto_ptr<coral::IQuery> query(mainTable.newQuery());
  coral::ICursor& cursor = query->execute();
  while ( cursor.next() ) {
    ret = true;
    const coral::AttributeList& row = cursor.currentRow();
    std::string paramName = row[ parameterNameColumn()].data< std::string >();
    std::string paramValue = row[ parameterValueColumn()].data< std::string >();
    dest.insert( std::make_pair( paramName, paramValue ) );
  }
  return ret;
}
std::string ora::OraMainTable::name ( ) [virtual]

Implements ora::IDatabaseTable.

Definition at line 76 of file OraDatabaseSchema.cc.

                               {
  return tableName();
}
std::string ora::OraMainTable::parameterNameColumn ( ) [static]

Definition at line 26 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

                                              {
  static std::string s_column("PARAMETER_NAME");
  return s_column;
}
std::string ora::OraMainTable::parameterValueColumn ( ) [static]

Definition at line 31 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

                                               {
  static std::string s_column("PARAMETER_VALUE");
  return s_column;
}
std::string ora::OraMainTable::schemaVersion ( ) [virtual]

Implements ora::IMainTable.

Definition at line 71 of file OraDatabaseSchema.cc.

References BeamSplash_cfg::version.

                                        {
  // could be replaced by a call to getParameters in case of needs to distinguish between ora db schema versions...
  return 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 asciidump::table.

                                                                   {
  if( !paramName.empty() && !paramValue.empty() ){
    coral::ITable& table = schema().tableHandle( tableName() );
    coral::AttributeList dataToInsert;
    dataToInsert.extend<std::string>( parameterNameColumn());
    dataToInsert.extend<std::string>( parameterValueColumn());
    dataToInsert[ parameterNameColumn() ].data<std::string>() = paramName;
    dataToInsert[ parameterValueColumn() ].data<std::string>() = paramValue;
    table.dataEditor().insertRow( dataToInsert );
  }
}
std::string ora::OraMainTable::tableName ( ) [static]

Definition at line 21 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

                                    {
  static std::string s_name("ORA_DB");
  return s_name;
}
std::string ora::OraMainTable::version ( ) [static]

Definition at line 16 of file OraDatabaseSchema.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

                                  {
  static std::string s_version("1.1.0");
  return s_version;
}