#include <IOVSchemaUtility.h>
Public Member Functions | |
bool | createIOVContainer () |
create iov tables | |
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 | |
bool | existsIOVContainer () |
IOVSchemaUtility (DbSession &session, std::ostream &log) | |
IOVSchemaUtility (DbSession &session) | |
~IOVSchemaUtility () | |
Private Attributes | |
std::ostream * | m_log |
cond::DbSession & | m_session |
Definition at line 6 of file IOVSchemaUtility.h.
cond::IOVSchemaUtility::IOVSchemaUtility | ( | cond::DbSession & | session | ) | [explicit] |
Definition at line 6 of file IOVSchemaUtility.cc.
cond::IOVSchemaUtility::IOVSchemaUtility | ( | cond::DbSession & | session, |
std::ostream & | log | ||
) |
Definition at line 11 of file IOVSchemaUtility.cc.
cond::IOVSchemaUtility::~IOVSchemaUtility | ( | ) |
Definition at line 15 of file IOVSchemaUtility.cc.
{}
bool cond::IOVSchemaUtility::createIOVContainer | ( | ) |
create iov tables
Definition at line 27 of file IOVSchemaUtility.cc.
References cond::DbSession::COND_SCHEMA_VERSION, ora::Database::connectionString(), cond::IOVNames::container(), ora::Database::containers(), ora::Database::create(), ora::Database::createContainer(), EcalCondDB::db, and ora::Database::exists().
Referenced by cond::IOVEditor::createIOVContainerIfNecessary(), and 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); } 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; db.createContainer( cond::IOVNames::container(), cond::IOVNames::container() ); 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 55 of file IOVSchemaUtility.cc.
References ora::Database::connectionString(), ora::Database::containers(), ora::Database::createContainer(), and EcalCondDB::db.
{ 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; db.createContainer( payloadTypeName, payloadName ); }
void cond::IOVSchemaUtility::dropAll | ( | ) |
drop all
Definition at line 75 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 43 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 64 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; }
bool cond::IOVSchemaUtility::existsIOVContainer | ( | ) |
Definition at line 17 of file IOVSchemaUtility.cc.
References cond::IOVNames::container(), ora::Database::containers(), EcalCondDB::db, ora::Database::exists(), and runTheMatrix::ret.
Referenced by cond::IOVEditor::createIOVContainerIfNecessary().
{ bool ret = false; ora::Database& db = m_session.storage(); if( db.exists() ){ std::set<std::string> conts = db.containers(); ret = ( conts.find( cond::IOVNames::container() )!=conts.end() ); } return ret; }
std::ostream* cond::IOVSchemaUtility::m_log [private] |
Definition at line 30 of file IOVSchemaUtility.h.
cond::DbSession& cond::IOVSchemaUtility::m_session [private] |
Definition at line 29 of file IOVSchemaUtility.h.