CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/CondCore/ORA/src/IDatabaseSchema.cc

Go to the documentation of this file.
00001 #include "IDatabaseSchema.h"
00002 #include "OraDatabaseSchema.h"
00003 #include "PoolDatabaseSchema.h"
00004 // externals
00005 #include "RelationalAccess/ISchema.h"
00006 #include "RelationalAccess/ITable.h"
00007 #include "RelationalAccess/ITablePrivilegeManager.h"
00008 
00009 std::string ora::poolSchemaVersion(){
00010   static std::string s_version("POOL");
00011   return s_version;
00012 }
00013 
00014 void ora::setTableAccessPermission( coral::ITable& table, 
00015                                     const std::string& principal, 
00016                                     bool forWrite ){
00017   table.privilegeManager().grantToUser( principal, coral::ITablePrivilegeManager::Select );
00018   if(forWrite){
00019     table.privilegeManager().grantToUser( principal, coral::ITablePrivilegeManager::Update );
00020     table.privilegeManager().grantToUser( principal, coral::ITablePrivilegeManager::Insert );
00021     table.privilegeManager().grantToUser( principal, coral::ITablePrivilegeManager::Delete );
00022   } 
00023 }
00024 
00025 ora::IDatabaseTable::IDatabaseTable( coral::ISchema& schema ):
00026   m_schema( schema ){
00027 }
00028 
00029 coral::ISchema& ora::IDatabaseTable::schema(){
00030   return m_schema;
00031 }
00032 
00033 void ora::IDatabaseTable::setAccessPermission( const std::string& principal, 
00034                                                bool forWrite ){
00035   coral::ITable& coralHandle = m_schema.tableHandle( name() );
00036   setTableAccessPermission( coralHandle, principal, forWrite );
00037 }
00038 
00039 std::string ora::IMainTable::versionParameterName(){
00040   static std::string s_name("SCHEMA_VERSION");
00041   return s_name;
00042 }
00043 
00044 std::string ora::IMainTable::userSchemaVersionParameterName(){
00045   static std::string s_name("USER_SCHEMA_VERSION");
00046   return s_name;
00047 }
00048 
00049 ora::IMainTable::IMainTable( coral::ISchema& schema ):
00050   IDatabaseTable( schema ){
00051 }
00052 
00053 ora::ISequenceTable::ISequenceTable( coral::ISchema& schema ):
00054   IDatabaseTable( schema ){
00055 }
00056 
00057 ora::MappingRawElement::MappingRawElement():
00058   scopeName(""),
00059   variableName(""),
00060   variableType(""),
00061   elementType(""),
00062   tableName(""),
00063   columns(){
00064 }
00065 
00066 ora::MappingRawElement::MappingRawElement(const MappingRawElement& rhs):
00067   scopeName( rhs.scopeName ),
00068   variableName( rhs.variableName ),
00069   variableType( rhs.variableType ),
00070   elementType( rhs.elementType ),
00071   tableName( rhs.tableName ),
00072   columns( rhs.columns ){
00073 }
00074 
00075 ora::MappingRawElement& ora::MappingRawElement::operator==(const MappingRawElement& rhs){
00076   scopeName = rhs.scopeName;
00077   variableName = rhs.variableName;
00078   variableType = rhs.variableType;
00079   elementType = rhs.elementType;
00080   tableName = rhs.tableName;
00081   columns = rhs.columns;
00082   return *this;
00083 }
00084 
00085 std::string ora::MappingRawElement::emptyScope(){
00086   static std::string s_scope("[]");
00087   return s_scope;
00088 }
00089 
00090 ora::MappingRawData::MappingRawData():  
00091   version( "" ),
00092   elements(){
00093 }
00094 
00095 ora::MappingRawData::MappingRawData( const std::string& vers ):  
00096   version( vers ),
00097   elements(){
00098 }
00099 
00100 ora::MappingRawElement& ora::MappingRawData::addElement( int elementId ){
00101   std::map< int, MappingRawElement>::iterator iElem = elements.find( elementId );
00102   if( iElem == elements.end() ){
00103     iElem = elements.insert( std::make_pair( elementId, MappingRawElement() ) ).first;
00104   }
00105   return iElem->second;
00106 }
00107 
00108 ora::ContainerHeaderData::ContainerHeaderData():
00109   id(-1),
00110   className(""),
00111   numberOfObjects(0){
00112 }
00113 
00114 ora::ContainerHeaderData::ContainerHeaderData( int contId,
00115                                                const std::string& classN,
00116                                                unsigned int numberObj ):
00117   id(contId),
00118   className(classN),
00119   numberOfObjects(numberObj){
00120 }
00121 
00122 ora::ContainerHeaderData::ContainerHeaderData( const ContainerHeaderData& rhs ):
00123   id(rhs.id),
00124   className(rhs.className),
00125   numberOfObjects(rhs.numberOfObjects){
00126 }
00127 
00128 ora::ContainerHeaderData& ora::ContainerHeaderData::operator=( const ContainerHeaderData& rhs ){
00129   id = rhs.id;
00130   className = rhs.className;
00131   numberOfObjects = rhs.numberOfObjects;
00132   return *this;
00133 }
00134 
00135 ora::IContainerHeaderTable::IContainerHeaderTable( coral::ISchema& schema ):
00136   IDatabaseTable( schema ){
00137 }
00138 
00139 ora::INamingServiceTable::INamingServiceTable( coral::ISchema& schema ):
00140   IDatabaseTable( schema ){
00141 }
00142 
00143 ora::IDatabaseSchema* ora::IDatabaseSchema::createSchemaHandle( coral::ISchema& schema ){
00144   IDatabaseSchema* dbSchema = 0;
00145   if( !OraDatabaseSchema::existsMainTable( schema ) ){
00146     if( PoolDatabaseSchema::existsMainTable( schema ) ) dbSchema = new PoolDatabaseSchema( schema );
00147   }
00148   if( ! dbSchema ) dbSchema = new OraDatabaseSchema( schema );
00149   return dbSchema;
00150 }
00151 
00152 ora::IDatabaseSchema::IDatabaseSchema( coral::ISchema& schema ):
00153   m_schema( schema ){
00154 }
00155 
00156 coral::ISchema& ora::IDatabaseSchema::storageSchema(){
00157   return m_schema;
00158 }
00159