CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/CondCore/ORA/src/OraDatabaseSchema.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_ORADATABASESCHEMA_H
00002 #define INCLUDE_ORA_ORADATABASESCHEMA_H
00003 
00004 #include "IDatabaseSchema.h"
00005 // externals
00006 #include "CoralBase/AttributeList.h"
00007 
00008 namespace ora {
00009 
00010   class OraMainTable: public IMainTable {
00011     public:
00012     static std::string version();
00013     static std::string tableName();
00014     static std::string parameterNameColumn();
00015     static std::string parameterValueColumn();
00016     public:
00017     explicit OraMainTable( coral::ISchema& dbSchema );
00018     virtual ~OraMainTable();
00019     void setParameter( const std::string& paramName, const std::string& paramValue );
00020     bool getParameters( std::map<std::string,std::string>& destination );
00021     std::string schemaVersion();
00022     public:
00023     std::string name();
00024     bool exists();
00025     void create();
00026     void drop();
00027   };
00028 
00029   
00030   class OraSequenceTable : public ISequenceTable{
00031     public:
00032     static std::string tableName();
00033     static std::string sequenceNameColumn();
00034     static std::string sequenceValueColumn();    
00035     public:
00036     explicit OraSequenceTable( coral::ISchema& dbSchema );
00037     OraSequenceTable( const std::string& tableName, coral::ISchema& dbSchema );
00038     virtual ~OraSequenceTable();
00039     bool add( const std::string& sequenceName );
00040     bool getLastId( const std::string& sequenceName, int& lastId );
00041     void sinchronize( const std::string& sequenceName, int lastValue );
00042     void erase( const std::string& sequenceName );
00043     public:
00044     std::string name();
00045     bool exists();
00046     void create();
00047     void drop();   
00048     private:
00049     std::string m_tableName;
00050   };
00051 
00052   class OraMappingVersionTable: public IDatabaseTable {
00053     public:
00054     static std::string tableName();
00055     static std::string mappingVersionColumn();
00056     public:
00057     explicit OraMappingVersionTable( coral::ISchema& dbSchema  );
00058     virtual ~OraMappingVersionTable();
00059     public:
00060     std::string name();
00061     bool exists();
00062     void create();
00063     void drop();
00064   };
00065   
00066   class OraMappingElementTable: public IDatabaseTable {
00067     public:
00068     static std::string tableName();
00069     static std::string mappingVersionColumn();
00070     static std::string elementIdColumn();
00071     static std::string elementTypeColumn();
00072     static std::string scopeNameColumn();
00073     static std::string variableNameColumn();
00074     static std::string variableParIndexColumn();
00075     static std::string variableTypeColumn();
00076     static std::string tableNameColumn();
00077     static std::string columnNameColumn();
00078     public:
00079     explicit OraMappingElementTable( coral::ISchema& dbSchema  );
00080     virtual ~OraMappingElementTable();
00081     public:
00082     std::string name();
00083     bool exists();
00084     void create();
00085     void drop();
00086   };
00087 
00088   class OraContainerHeaderTable: public IContainerHeaderTable {
00089     public:
00090     static std::string tableName();
00091     static std::string containerIdColumn();
00092     static std::string containerNameColumn();
00093     static std::string classNameColumn();
00094     static std::string numberOfObjectsColumn();
00095     public:
00096     explicit OraContainerHeaderTable( coral::ISchema& dbSchema );
00097     virtual ~OraContainerHeaderTable();
00098     bool getContainerData( std::map<std::string, ContainerHeaderData>& destination );
00099     void addContainer( int id, const std::string& containerName, const std::string& className );
00100     void removeContainer( int id );
00101     bool lockContainer( int id, ContainerHeaderData& destination );
00102     void incrementNumberOfObjects( int id  );
00103     void decrementNumberOfObjects( int id  );
00104     void updateNumberOfObjects( const std::map<int,unsigned int>& numberOfObjectsForContainerIds );
00105     public:
00106     std::string name();
00107     bool exists();
00108     void create();
00109     void drop();
00110     private:
00111     void updateContainer( int id, const std::string& setClause );
00112   };
00113 
00114   class OraClassVersionTable: public IDatabaseTable {
00115     public:
00116     static std::string tableName();
00117     static std::string classNameColumn();
00118     static std::string classVersionColumn();
00119     static std::string classIdColumn();
00120     static std::string dependencyIndexColumn();
00121     static std::string containerIdColumn();
00122     static std::string mappingVersionColumn();
00123     public:
00124     explicit OraClassVersionTable( coral::ISchema& dbSchema  );
00125     virtual ~OraClassVersionTable();
00126     public:
00127     std::string name();
00128     bool exists();
00129     void create();
00130     void drop();
00131   };
00132 
00133   class OraMappingSchema: public IMappingSchema {
00134     public:
00135     explicit OraMappingSchema( coral::ISchema& dbSchema  );
00136     virtual ~OraMappingSchema();
00137    public:
00138     bool getVersionList( std::set<std::string>& destination );
00139     bool getMapping( const std::string& version, MappingRawData& destination );
00140     void storeMapping( const MappingRawData& mapping );
00141     void removeMapping( const std::string& version );
00142     bool getContainerTableMap( std::map<std::string, int>& destination );
00143     bool getMappingVersionListForContainer( int containerId, std::set<std::string>& destination, bool onlyDependency=false );
00144     bool getDependentClassesInContainerMapping( int containerId, std::set<std::string>& destination );
00145     bool getClassVersionListForMappingVersion( const std::string& mappingVersion, std::set<std::string>& destination );
00146     bool getClassVersionListForContainer( int containerId, std::map<std::string,std::string>& versionMap );
00147     bool getMappingVersionListForTable( const std::string& tableName, std::set<std::string>& destination );
00148     bool selectMappingVersion( const std::string& classId, int containerId, std::string& destination );
00149     bool containerForMappingVersion( const std::string& mappingVersion, int& destination );
00150     void insertClassVersion( const std::string& className, const std::string& classVersion, const std::string& classId,
00151                              int dependencyIndex, int containerId, const std::string& mappingVersion );
00152     void setMappingVersion( const std::string& classId, int containerId, const std::string& mappingVersion );
00153     private:
00154     coral::ISchema& m_schema;
00155   };  
00156 
00157   class OraNamingServiceTable : public INamingServiceTable {
00158     public:
00159     static std::string& tableName();
00160     static std::string& objectNameColumn();
00161     static std::string& containerIdColumn();
00162     static std::string& itemIdColumn();
00163    public: 
00164     explicit OraNamingServiceTable( coral::ISchema& dbSchema );
00165     virtual ~OraNamingServiceTable();
00166     void setObjectName( const std::string& name, int contId, int itemId );
00167     bool eraseObjectName( const std::string& name );
00168     bool eraseAllNames();
00169     bool getObjectByName( const std::string& name, std::pair<int,int>& destination );
00170     bool getNamesForObject( int contId, int itemId, std::vector<std::string>& destination );
00171     bool getNamesForContainer( int contId, std::vector<std::string>& destination );
00172     bool getAllNames( std::vector<std::string>& destination );
00173 
00174    public:
00175     std::string name();
00176     bool exists();
00177     void create();
00178     void drop();    
00179   };
00180 
00181   class OraDatabaseSchema: public IDatabaseSchema {
00182     public:
00183     static bool existsMainTable( coral::ISchema& dbSchema );
00184     
00185     public:
00186     explicit OraDatabaseSchema( coral::ISchema& dbSchema );
00187     virtual ~OraDatabaseSchema();
00188     
00189     bool exists();
00190     void create( const std::string& userSchemaVersion );
00191     void drop();
00192     void setAccessPermission( const std::string& principal, bool forWrite );
00193 
00194     IMainTable& mainTable();
00195     ISequenceTable& sequenceTable();
00196     IDatabaseTable& mappingVersionTable();
00197     IDatabaseTable& mappingElementTable();
00198     IContainerHeaderTable& containerHeaderTable();
00199     IDatabaseTable& classVersionTable();
00200     IMappingSchema& mappingSchema();
00201     INamingServiceTable& namingServiceTable();
00202     bool testDropPermission();
00203 
00204     private:
00205     coral::ISchema& m_schema;
00206     OraMainTable m_mainTable;
00207     OraSequenceTable m_sequenceTable;
00208     OraMappingVersionTable m_mappingVersionTable;
00209     OraMappingElementTable m_mappingElementTable;
00210     OraContainerHeaderTable m_containerHeaderTable;
00211     OraClassVersionTable m_classVersionTable;
00212     OraMappingSchema m_mappingSchema;
00213     OraNamingServiceTable m_namingServiceTable;
00214   };  
00215   
00216 }
00217 
00218 #endif
00219   
00220