CMS 3D CMS Logo

MetaDataDataSchemaUtility.cc

Go to the documentation of this file.
00001 #include "CondCore/MetaDataService/interface/MetaDataSchemaUtility.h"
00002 #include "CondCore/MetaDataService/interface/MetaDataNames.h"
00003 #include "CondCore/MetaDataService/interface/MetaDataExceptions.h"
00004 #include "CondCore/DBCommon/interface/CoralTransaction.h"
00005 #include "RelationalAccess/SchemaException.h"
00006 #include "RelationalAccess/ISchema.h"
00007 #include "RelationalAccess/ITable.h"
00008 #include "RelationalAccess/TableDescription.h"
00009 #include "RelationalAccess/ITablePrivilegeManager.h"
00010 #include "RelationalAccess/ICursor.h"
00011 #include "RelationalAccess/IQuery.h"
00012 #include "RelationalAccess/ITableDataEditor.h"
00013 #include "CoralBase/AttributeList.h"
00014 #include "CoralBase/AttributeSpecification.h"
00015 #include "CoralBase/Attribute.h"
00016 cond::MetaDataSchemaUtility::MetaDataSchemaUtility(cond::CoralTransaction& coraldb):m_coraldb(coraldb){
00017 }
00018 cond::MetaDataSchemaUtility::~MetaDataSchemaUtility(){}
00019 
00020 void
00021 cond::MetaDataSchemaUtility::create(){
00022   try{
00023     coral::ISchema& schema=m_coraldb.nominalSchema();
00024     coral::TableDescription description;
00025     description.setName( cond::MetaDataNames::metadataTable() );
00026     description.insertColumn(  cond::MetaDataNames::tagColumn(), coral::AttributeSpecification::typeNameForId( typeid(std::string)) );
00027     description.insertColumn( cond::MetaDataNames::tokenColumn(), coral::AttributeSpecification::typeNameForId( typeid(std::string)) );
00028     description.insertColumn( cond::MetaDataNames::timetypeColumn(), coral::AttributeSpecification::typeNameForId( typeid(int)) );
00029     std::vector<std::string> cols;
00030     cols.push_back( cond::MetaDataNames::tagColumn() );
00031     description.setPrimaryKey(cols);
00032     description.setNotNullConstraint( cond::MetaDataNames::tokenColumn() );
00033     coral::ITable& table=schema.createTable(description);
00034     table.privilegeManager().grantToPublic( coral::ITablePrivilegeManager::Select);
00035   }catch( const coral::TableAlreadyExistingException& er ){
00036     //must catch and ignore this exception!!
00037     //std::cout<<"table alreay existing, not creating a new one"<<std::endl;
00038   }
00039 }
00040 void
00041 cond::MetaDataSchemaUtility::drop(){
00042   coral::ISchema& schema=m_coraldb.nominalSchema();
00043   try{
00044     schema.dropTable(cond::MetaDataNames::metadataTable());
00045   }catch(coral::TableNotExistingException& er){
00046     //must catch and ignore this exception!!
00047     //ok do nothing
00048   }
00049 }

Generated on Tue Jun 9 17:26:10 2009 for CMSSW by  doxygen 1.5.4