CMS 3D CMS Logo

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

#include <IOVSchemaUtility.h>

Public Member Functions

bool createIOVContainer ()
 create iov tables More...
 
void createPayloadContainer (const std::string &payloadName, const std::string &payloadTypeName)
 create a payload container More...
 
void dropAll ()
 drop all More...
 
bool dropIOVContainer ()
 drop iov tables if existing More...
 
void dropPayloadContainer (const std::string &payloadName)
 drop iov tables if existing More...
 
bool existsIOVContainer ()
 
 IOVSchemaUtility (DbSession &session)
 
 IOVSchemaUtility (DbSession &session, std::ostream &log)
 
 ~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.

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

Definition at line 11 of file IOVSchemaUtility.cc.

11  :
12  m_session( session ),
13  m_log(&log){
14 }
cond::DbSession & m_session
cond::IOVSchemaUtility::~IOVSchemaUtility ( )

Definition at line 15 of file IOVSchemaUtility.cc.

15 {}

Member Function Documentation

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

27  {
29  if( !db.exists() ){
30  if(m_log) *m_log << "INFO: Creating condition database in "<<db.connectionString()<<std::endl;
32  }
33  std::set<std::string> conts = db.containers();
34  if( conts.find( cond::IOVNames::container() )==conts.end() ){
35  if(m_log) *m_log << "INFO: Creating container \"" << cond::IOVNames::container() << "\" in "<<db.connectionString()<<std::endl;
37  return true;
38  }
39  if(m_log) *m_log << "INFO: container \"" << cond::IOVNames::container() << "\" already exists in the database "<<db.connectionString()<<std::endl;
40  return false;
41 }
bool create(std::string userSchemaVersion=std::string(""))
Definition: Database.cc:135
cond::DbSession & m_session
const std::string & connectionString()
Definition: Database.cc:110
tuple db
Definition: EcalCondDB.py:151
static const char * COND_SCHEMA_VERSION
Definition: DbSession.h:33
bool exists()
Definition: Database.cc:130
std::set< std::string > containers()
Definition: Database.cc:191
static std::string container()
Definition: IOVNames.h:7
ora::Database & storage()
Definition: DbSession.cc:198
Container createContainer(const std::string &name)
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.

56  {
58  std::set<std::string> conts = db.containers();
59  if( conts.find( payloadName ) != conts.end()) throw cond::Exception("Container \""+payloadName+"\" already exists.");
60  if(m_log) *m_log << "INFO: Creating container \"" << payloadName << "\" in "<<db.connectionString()<<std::endl;
61  db.createContainer( payloadTypeName, payloadName );
62 }
cond::DbSession & m_session
const std::string & connectionString()
Definition: Database.cc:110
tuple db
Definition: EcalCondDB.py:151
std::set< std::string > containers()
Definition: Database.cc:191
ora::Database & storage()
Definition: DbSession.cc:198
Container createContainer(const std::string &name)
void cond::IOVSchemaUtility::dropAll ( )

drop all

Definition at line 75 of file IOVSchemaUtility.cc.

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

75  {
77  if(m_log) *m_log << "INFO: Dropping database in "<<db.connectionString()<<std::endl;
78  db.drop();
79 }
cond::DbSession & m_session
const std::string & connectionString()
Definition: Database.cc:110
tuple db
Definition: EcalCondDB.py:151
bool drop()
Definition: Database.cc:144
ora::Database & storage()
Definition: DbSession.cc:198
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().

43  {
45  std::set<std::string> conts = db.containers();
46  if( conts.find( cond::IOVNames::container() )==conts.end() ){
47  if(m_log) *m_log << "WARNING: container \"" << cond::IOVNames::container() << "\" does not exist in the database "<<db.connectionString()<<std::endl;
48  return false;
49  }
50  if(m_log) *m_log << "INFO: Dropping container \"" << cond::IOVNames::container() << "\" from "<<db.connectionString()<<std::endl;
52  return true;
53 }
cond::DbSession & m_session
const std::string & connectionString()
Definition: Database.cc:110
tuple db
Definition: EcalCondDB.py:151
std::set< std::string > containers()
Definition: Database.cc:191
bool dropContainer(const std::string &name)
Definition: Database.cc:253
static std::string container()
Definition: IOVNames.h:7
ora::Database & storage()
Definition: DbSession.cc:198
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().

64  {
66  std::set<std::string> conts = db.containers();
67  if( conts.find( payloadName )!=conts.end() ){
68  if(m_log) *m_log << "INFO: Dropping container \"" << payloadName << "\" from "<<db.connectionString()<<std::endl;
69  db.dropContainer( payloadName );
70  return;
71  }
72  if(m_log) *m_log << "WARNING: container \"" << payloadName << "\" does not exist in the database "<<db.connectionString()<<std::endl;
73 }
cond::DbSession & m_session
const std::string & connectionString()
Definition: Database.cc:110
tuple db
Definition: EcalCondDB.py:151
std::set< std::string > containers()
Definition: Database.cc:191
bool dropContainer(const std::string &name)
Definition: Database.cc:253
ora::Database & storage()
Definition: DbSession.cc:198
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 run_regression::ret.

Referenced by cond::IOVEditor::createIOVContainerIfNecessary().

17  {
18  bool ret = false;
20  if( db.exists() ){
21  std::set<std::string> conts = db.containers();
22  ret = ( conts.find( cond::IOVNames::container() )!=conts.end() );
23  }
24  return ret;
25 }
cond::DbSession & m_session
tuple db
Definition: EcalCondDB.py:151
bool exists()
Definition: Database.cc:130
std::set< std::string > containers()
Definition: Database.cc:191
static std::string container()
Definition: IOVNames.h:7
ora::Database & storage()
Definition: DbSession.cc:198

Member Data Documentation

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.