CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MetaDataDataSchemaUtility.cc
Go to the documentation of this file.
3 #include "RelationalAccess/SchemaException.h"
4 #include "RelationalAccess/ISchema.h"
5 #include "RelationalAccess/ITable.h"
6 #include "RelationalAccess/TableDescription.h"
7 #include "RelationalAccess/ITablePrivilegeManager.h"
8 #include "RelationalAccess/ICursor.h"
9 #include "RelationalAccess/IQuery.h"
10 #include "RelationalAccess/ITableDataEditor.h"
11 #include "CoralBase/AttributeList.h"
12 #include "CoralBase/AttributeSpecification.h"
13 #include "CoralBase/Attribute.h"
15 }
17 
18 void
20  try{
21  coral::ISchema& schema=m_coraldb.nominalSchema();
22  coral::TableDescription description;
23  description.setName( cond::MetaDataNames::metadataTable() );
24  description.insertColumn( cond::MetaDataNames::tagColumn(), coral::AttributeSpecification::typeNameForId( typeid(std::string)) );
25  description.insertColumn( cond::MetaDataNames::tokenColumn(), coral::AttributeSpecification::typeNameForId( typeid(std::string)) );
26  description.insertColumn( cond::MetaDataNames::timetypeColumn(), coral::AttributeSpecification::typeNameForId( typeid(int)) );
27  std::vector<std::string> cols;
28  cols.push_back( cond::MetaDataNames::tagColumn() );
29  description.setPrimaryKey(cols);
30  description.setNotNullConstraint( cond::MetaDataNames::tokenColumn() );
31  coral::ITable& table=schema.createTable(description);
32  table.privilegeManager().grantToPublic( coral::ITablePrivilegeManager::Select);
33  }catch( const coral::TableAlreadyExistingException& er ){
34  //must catch and ignore this exception!!
35  //std::cout<<"table alreay existing, not creating a new one"<<std::endl;
36  }
37 }
38 void
40  coral::ISchema& schema=m_coraldb.nominalSchema();
41  try{
42  schema.dropTable(cond::MetaDataNames::metadataTable());
43  }catch(coral::TableNotExistingException& er){
44  //must catch and ignore this exception!!
45  //ok do nothing
46  }
47 }
list table
Definition: asciidump.py:386
static const std::string & tagColumn()
Definition: MetaDataNames.cc:6
MetaDataSchemaUtility(cond::DbSession &coraldb)
static const std::string & metadataTable()
Definition: MetaDataNames.cc:2
tuple description
Definition: idDealer.py:66
void create()
create metadata tables if not existing
void drop()
drop metadata tables is existing
static const std::string & timetypeColumn()
static const std::string & tokenColumn()