CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IOVSchemaUtility.cc
Go to the documentation of this file.
5 
7  m_session( session ),
8  m_log(0){
9 }
10 
12  m_session( session ),
13  m_log(&log){
14 }
16 
18  bool ret = false;
19  ora::Database& db = m_session.storage();
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 }
26 
28  ora::Database& db = m_session.storage();
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 }
42 
44  ora::Database& db = m_session.storage();
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 }
54 
56  const std::string& payloadTypeName ){
57  ora::Database& db = m_session.storage();
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 }
63 
65  ora::Database& db = m_session.storage();
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 }
74 
76  ora::Database& db = m_session.storage();
77  if(m_log) *m_log << "INFO: Dropping database in "<<db.connectionString()<<std::endl;
78  db.drop();
79 }
80 
bool create(std::string userSchemaVersion=std::string(""))
Definition: Database.cc:138
const std::string & connectionString()
Definition: Database.cc:113
tuple db
Definition: EcalCondDB.py:151
void dropPayloadContainer(const std::string &payloadName)
drop iov tables if existing
static const char * COND_SCHEMA_VERSION
Definition: DbSession.h:33
bool exists()
Definition: Database.cc:133
std::set< std::string > containers()
Definition: Database.cc:194
bool dropIOVContainer()
drop iov tables if existing
bool dropContainer(const std::string &name)
Definition: Database.cc:256
IOVSchemaUtility(DbSession &session)
static std::string container()
Definition: IOVNames.h:7
bool drop()
Definition: Database.cc:147
void createPayloadContainer(const std::string &payloadName, const std::string &payloadTypeName)
create a payload container
bool createIOVContainer()
create iov tables
Container createContainer(const std::string &name)
tuple log
Definition: cmsBatch.py:347