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