CMS 3D CMS Logo

Public Member Functions | Private Attributes

cond::IOVSchemaUtility Class Reference

#include <IOVSchemaUtility.h>

List of all members.

Public Member Functions

bool createIOVContainerIfNecessary ()
 create iov tables if not existing
void createPayloadContainer (const std::string &payloadName, const std::string &payloadTypeName)
 create a payload container
void dropAll ()
 drop all
bool dropIOVContainer ()
 drop iov tables if existing
void dropPayloadContainer (const std::string &payloadName)
 drop iov tables if existing
 IOVSchemaUtility (DbSession &session, std::ostream &log)
 IOVSchemaUtility (DbSession &session)
 ~IOVSchemaUtility ()

Private Attributes

std::ostream * m_log
cond::DbSessionm_session

Detailed Description

Definition at line 6 of file IOVSchemaUtility.h.


Constructor & Destructor Documentation

cond::IOVSchemaUtility::IOVSchemaUtility ( cond::DbSession session) [explicit]

Definition at line 6 of file IOVSchemaUtility.cc.

                                                            :
  m_session( session ),
  m_log(0){
}
cond::IOVSchemaUtility::IOVSchemaUtility ( cond::DbSession session,
std::ostream &  log 
)

Definition at line 11 of file IOVSchemaUtility.cc.

                                                                             :
  m_session( session ),
  m_log(&log){
}
cond::IOVSchemaUtility::~IOVSchemaUtility ( )

Definition at line 15 of file IOVSchemaUtility.cc.

{}

Member Function Documentation

bool cond::IOVSchemaUtility::createIOVContainerIfNecessary ( )

create iov tables if not existing

Definition at line 17 of file IOVSchemaUtility.cc.

References trackerHits::c, cond::DbSession::COND_SCHEMA_VERSION, cond::DbSession::CONDITIONS_GENERAL_READER, cond::DbSession::CONDITIONS_GENERAL_WRITER, ora::Database::connectionString(), cond::IOVNames::container(), ora::Database::containers(), ora::Database::create(), ora::Database::createContainer(), EcalCondDB::db, ora::Database::exists(), ora::Database::setAccessPermission(), and ora::Container::setAccessPermission().

Referenced by cond::service::PoolDBOutputService::initDB().

                                                        {
  ora::Database& db = m_session.storage();
  if( !db.exists() ){
    if(m_log) *m_log << "INFO: Creating condition database in "<<db.connectionString()<<std::endl;
    db.create(cond::DbSession::COND_SCHEMA_VERSION);
    db.setAccessPermission(cond::DbSession::CONDITIONS_GENERAL_READER, false );
    db.setAccessPermission( cond::DbSession::CONDITIONS_GENERAL_WRITER, true );
  } 
  std::set<std::string> conts = db.containers();
  if( conts.find( cond::IOVNames::container() )==conts.end() ){
    if(m_log) *m_log << "INFO: Creating container \"" << cond::IOVNames::container() << "\" in "<<db.connectionString()<<std::endl;
    ora::Container c = db.createContainer( cond::IOVNames::container(), cond::IOVNames::container() );
    c.setAccessPermission( cond::DbSession::CONDITIONS_GENERAL_READER, false );
    c.setAccessPermission( cond::DbSession::CONDITIONS_GENERAL_WRITER, true );
    return true;
  }
  if(m_log) *m_log << "INFO: container \"" << cond::IOVNames::container() << "\" already exists in the database "<<db.connectionString()<<std::endl;
  return false;
}
void cond::IOVSchemaUtility::createPayloadContainer ( const std::string &  payloadName,
const std::string &  payloadTypeName 
)

create a payload container

Definition at line 49 of file IOVSchemaUtility.cc.

References trackerHits::c, cond::DbSession::CONDITIONS_GENERAL_READER, cond::DbSession::CONDITIONS_GENERAL_WRITER, ora::Database::connectionString(), ora::Database::containers(), ora::Database::createContainer(), EcalCondDB::db, and ora::Container::setAccessPermission().

                                                                                       {
  ora::Database& db = m_session.storage();
  std::set<std::string> conts = db.containers();
  if( conts.find( payloadName ) != conts.end()) throw cond::Exception("Container \""+payloadName+"\" already exists.");
  if(m_log) *m_log << "INFO: Creating container \"" << payloadName << "\" in "<<db.connectionString()<<std::endl;
  ora::Container c = db.createContainer( payloadTypeName, payloadName );
  c.setAccessPermission( cond::DbSession::CONDITIONS_GENERAL_READER, false );
  c.setAccessPermission( cond::DbSession::CONDITIONS_GENERAL_WRITER, true );
}
void cond::IOVSchemaUtility::dropAll ( )

drop all

Definition at line 71 of file IOVSchemaUtility.cc.

References ora::Database::connectionString(), EcalCondDB::db, and ora::Database::drop().

                                  {
  ora::Database& db = m_session.storage();
  if(m_log) *m_log << "INFO: Dropping database in "<<db.connectionString()<<std::endl;
  db.drop();
}
bool cond::IOVSchemaUtility::dropIOVContainer ( )

drop iov tables if existing

Definition at line 37 of file IOVSchemaUtility.cc.

References ora::Database::connectionString(), cond::IOVNames::container(), ora::Database::containers(), EcalCondDB::db, and ora::Database::dropContainer().

                                           {
  ora::Database& db = m_session.storage();
  std::set<std::string> conts = db.containers();
  if( conts.find( cond::IOVNames::container() )==conts.end() ){
    if(m_log) *m_log << "WARNING: container \"" << cond::IOVNames::container() << "\" does not exist in the database "<<db.connectionString()<<std::endl;
    return false;
  }
  if(m_log) *m_log << "INFO: Dropping container \"" << cond::IOVNames::container() << "\" from "<<db.connectionString()<<std::endl;
  db.dropContainer( cond::IOVNames::container() );
  return true;
}
void cond::IOVSchemaUtility::dropPayloadContainer ( const std::string &  payloadName)

drop iov tables if existing

Definition at line 60 of file IOVSchemaUtility.cc.

References ora::Database::connectionString(), ora::Database::containers(), EcalCondDB::db, and ora::Database::dropContainer().

                                                                             {
  ora::Database& db = m_session.storage();
  std::set<std::string> conts = db.containers();
  if( conts.find( payloadName )!=conts.end() ){
    if(m_log) *m_log << "INFO: Dropping container \"" << payloadName << "\" from "<<db.connectionString()<<std::endl;
    db.dropContainer( payloadName );
    return;
  } 
  if(m_log) *m_log << "WARNING: container \"" << payloadName << "\" does not exist in the database "<<db.connectionString()<<std::endl;
}

Member Data Documentation

std::ostream* cond::IOVSchemaUtility::m_log [private]

Definition at line 27 of file IOVSchemaUtility.h.

Definition at line 26 of file IOVSchemaUtility.h.