Class PlainSchemaAdapter

  • All Implemented Interfaces:
    ISchemaAdapter
    Direct Known Subclasses:
    DistributedSchemaAdapter, FhirSchemaAdapter

    public class PlainSchemaAdapter
    extends java.lang.Object
    implements ISchemaAdapter
    Adapter to build the plain version of the FHIR schema. Uses the IDatabaseAdapter to hide the specifics of a particular database flavor (like PostgreSQL, Derby etc).
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void alterSequenceRestartWith​(java.lang.String schemaName, java.lang.String sequenceName, long restartWith, int cache, int incrementBy)
      Sets/resets the sequence to start with the given value.
      void alterTableAddColumn​(java.lang.String schemaName, java.lang.String tableName, ColumnBase column)
      Add a new column to an existing table
      void alterTableColumnIdentityCache​(java.lang.String schemaName, java.lang.String objectName, java.lang.String columnName, int cache)
      Change the CACHE value of the named identity generated always column
      void applyDistributionRules​(java.lang.String schemaName, java.lang.String tableName, DistributionType distributionType, java.lang.String distributionColumnName)
      Apply any distribution rules configured for the named table
      boolean checkCompatibility​(java.lang.String adminSchema)
      checks connectivity to the database and that it is compatible
      void createForeignKeyConstraint​(java.lang.String constraintName, java.lang.String schemaName, java.lang.String name, java.lang.String targetSchema, java.lang.String targetTable, java.lang.String targetColumnName, java.util.List<java.lang.String> columns, boolean enforced, DistributionType distributionType, boolean targetIsReference)  
      void createIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, DistributionType distributionType)
      Create an index on the named schema.table object
      void createOrReplaceFunction​(java.lang.String schemaName, java.lang.String objectName, java.util.function.Supplier<java.lang.String> supplier)
      creates or replaces the SQL function
      void createOrReplaceProcedure​(java.lang.String schemaName, java.lang.String procedureName, java.util.function.Supplier<java.lang.String> supplier)
      Create the stored procedure using the DDL text provided by the supplier
      void createOrReplaceView​(java.lang.String schemaName, java.lang.String objectName, java.lang.String selectClause)
      Create or replace the view
      void createSchema​(java.lang.String schemaName)
      Create a database schema
      void createSequence​(java.lang.String schemaName, java.lang.String sequenceName, long startWith, int cache, int incrementBy)  
      void createTable​(java.lang.String schemaName, java.lang.String name, java.util.List<ColumnBase> columns, PrimaryKeyDef primaryKey, IdentityDef identity, java.lang.String tablespaceName, java.util.List<With> withs, java.util.List<CheckConstraint> checkConstraints, DistributionType distributionType, java.lang.String distributionColumnName)
      Build the create table DDL
      void createTablespace​(java.lang.String tablespaceName)
      Create a new tablespace with the given name
      void createTablespace​(java.lang.String tablespaceName, int extentSizeKB)
      Create a new tablespace using the given extent size
      void createUniqueConstraint​(java.lang.String constraintName, java.util.List<java.lang.String> columns, java.lang.String schemaName, java.lang.String name)
      create a unique constraint on a table.
      void createUniqueIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, java.util.List<java.lang.String> includeColumns, DistributionType distributionType, java.lang.String distributionColumnName)
      Create a unique index
      void createUniqueIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, DistributionType distributionType, java.lang.String distributionColumnName)
      Create a unique index
      void createView​(java.lang.String schemaName, java.lang.String objectName, java.lang.String selectClause)
      Create the view as defined by the selectClause
      void disableForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Disable the FK with the given constraint name
      void distributeFunction​(java.lang.String schemaName, java.lang.String functionName, int distributeByParamNumber)
      For Citus, functions can be distributed by one of their parameters (typically the first)
      boolean doesForeignKeyConstraintExist​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Check to see if the named foreign key constraint already exists
      boolean doesTableExist​(java.lang.String schemaName, java.lang.String objectName)
      Check if the table currently exists
      void dropForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Drop the FK on the table with the given constraint name
      void dropFunction​(java.lang.String schemaName, java.lang.String functionName)
      drops a given function
      void dropIndex​(java.lang.String schemaName, java.lang.String indexName)
      Drop the named index
      void dropProcedure​(java.lang.String schemaName, java.lang.String procedureName)
      Drop the given procedure
      void dropSequence​(java.lang.String schemaName, java.lang.String sequenceName)  
      void dropTable​(java.lang.String schemaName, java.lang.String name)
      Drop table from the schema
      void dropTablespace​(java.lang.String tablespaceName)
      Drop an existing tablespace, including all of its contents
      void dropView​(java.lang.String schemaName, java.lang.String objectName)
      Drop the view from the database
      void enableForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Enable the FK with the given constraint name
      void grantAllSequenceUsage​(java.lang.String schemaName, java.lang.String grantToUser)
      Grant access to all sequences in the named schema
      void grantFunctionPrivileges​(java.lang.String schemaName, java.lang.String functionName, java.util.Collection<Privilege> privileges, java.lang.String toUser)
      grants permissions on a given function
      void grantObjectPrivileges​(java.lang.String schemaName, java.lang.String tableName, java.util.Collection<Privilege> privileges, java.lang.String toUser)
      Grant the list of privileges on the named object to the user.
      void grantProcedurePrivileges​(java.lang.String schemaName, java.lang.String procedureName, java.util.Collection<Privilege> privileges, java.lang.String toUser)
      Grant the collection of privileges on the named procedure to the user
      void grantSchemaUsage​(java.lang.String schemaName, java.lang.String grantToUser)
      Grants USAGE on the given schemaName to the given user
      void grantSequencePrivileges​(java.lang.String schemaName, java.lang.String objectName, java.util.Collection<Privilege> group, java.lang.String toUser)
      Grant the collection of privileges on the named variable to the user
      void grantVariablePrivileges​(java.lang.String schemaName, java.lang.String variableName, java.util.Collection<Privilege> privileges, java.lang.String toUser)
      Grant the collection of privileges on the named variable to the user
      java.util.List<SchemaInfoObject> listSchemaObjects​(java.lang.String schemaName)
      List the objects present in the given schema
      void runStatement​(IDatabaseStatement statement)
      Run the given statement against the database represented by this adapter
      void setIntegrityOff​(java.lang.String schemaName, java.lang.String tableName)  
      void setIntegrityUnchecked​(java.lang.String schemaName, java.lang.String tableName)  
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PlainSchemaAdapter

        public PlainSchemaAdapter​(IDatabaseAdapter databaseAdapter)
        Public constructor
        Parameters:
        databaseAdapter -
    • Method Detail

      • createTablespace

        public void createTablespace​(java.lang.String tablespaceName)
        Description copied from interface: ISchemaAdapter
        Create a new tablespace with the given name
        Specified by:
        createTablespace in interface ISchemaAdapter
      • createTablespace

        public void createTablespace​(java.lang.String tablespaceName,
                                     int extentSizeKB)
        Description copied from interface: ISchemaAdapter
        Create a new tablespace using the given extent size
        Specified by:
        createTablespace in interface ISchemaAdapter
      • dropTablespace

        public void dropTablespace​(java.lang.String tablespaceName)
        Description copied from interface: ISchemaAdapter
        Drop an existing tablespace, including all of its contents
        Specified by:
        dropTablespace in interface ISchemaAdapter
      • applyDistributionRules

        public void applyDistributionRules​(java.lang.String schemaName,
                                           java.lang.String tableName,
                                           DistributionType distributionType,
                                           java.lang.String distributionColumnName)
        Description copied from interface: ISchemaAdapter
        Apply any distribution rules configured for the named table
        Specified by:
        applyDistributionRules in interface ISchemaAdapter
      • alterTableAddColumn

        public void alterTableAddColumn​(java.lang.String schemaName,
                                        java.lang.String tableName,
                                        ColumnBase column)
        Description copied from interface: ISchemaAdapter
        Add a new column to an existing table
        Specified by:
        alterTableAddColumn in interface ISchemaAdapter
      • createOrReplaceProcedure

        public void createOrReplaceProcedure​(java.lang.String schemaName,
                                             java.lang.String procedureName,
                                             java.util.function.Supplier<java.lang.String> supplier)
        Description copied from interface: ISchemaAdapter
        Create the stored procedure using the DDL text provided by the supplier
        Specified by:
        createOrReplaceProcedure in interface ISchemaAdapter
      • dropProcedure

        public void dropProcedure​(java.lang.String schemaName,
                                  java.lang.String procedureName)
        Description copied from interface: ISchemaAdapter
        Drop the given procedure
        Specified by:
        dropProcedure in interface ISchemaAdapter
      • createUniqueIndex

        public void createUniqueIndex​(java.lang.String schemaName,
                                      java.lang.String tableName,
                                      java.lang.String indexName,
                                      java.util.List<OrderedColumnDef> indexColumns,
                                      java.util.List<java.lang.String> includeColumns,
                                      DistributionType distributionType,
                                      java.lang.String distributionColumnName)
        Description copied from interface: ISchemaAdapter
        Create a unique index
        Specified by:
        createUniqueIndex in interface ISchemaAdapter
      • createUniqueIndex

        public void createUniqueIndex​(java.lang.String schemaName,
                                      java.lang.String tableName,
                                      java.lang.String indexName,
                                      java.util.List<OrderedColumnDef> indexColumns,
                                      DistributionType distributionType,
                                      java.lang.String distributionColumnName)
        Description copied from interface: ISchemaAdapter
        Create a unique index
        Specified by:
        createUniqueIndex in interface ISchemaAdapter
      • createIndex

        public void createIndex​(java.lang.String schemaName,
                                java.lang.String tableName,
                                java.lang.String indexName,
                                java.util.List<OrderedColumnDef> indexColumns,
                                DistributionType distributionType)
        Description copied from interface: ISchemaAdapter
        Create an index on the named schema.table object
        Specified by:
        createIndex in interface ISchemaAdapter
      • dropTable

        public void dropTable​(java.lang.String schemaName,
                              java.lang.String name)
        Description copied from interface: ISchemaAdapter
        Drop table from the schema
        Specified by:
        dropTable in interface ISchemaAdapter
      • createForeignKeyConstraint

        public void createForeignKeyConstraint​(java.lang.String constraintName,
                                               java.lang.String schemaName,
                                               java.lang.String name,
                                               java.lang.String targetSchema,
                                               java.lang.String targetTable,
                                               java.lang.String targetColumnName,
                                               java.util.List<java.lang.String> columns,
                                               boolean enforced,
                                               DistributionType distributionType,
                                               boolean targetIsReference)
        Specified by:
        createForeignKeyConstraint in interface ISchemaAdapter
        distributionType - distribution type of the source table
      • createSequence

        public void createSequence​(java.lang.String schemaName,
                                   java.lang.String sequenceName,
                                   long startWith,
                                   int cache,
                                   int incrementBy)
        Specified by:
        createSequence in interface ISchemaAdapter
        startWith - the START WITH value for the sequence
        cache - the sequence CACHE value
      • dropSequence

        public void dropSequence​(java.lang.String schemaName,
                                 java.lang.String sequenceName)
        Specified by:
        dropSequence in interface ISchemaAdapter
      • alterSequenceRestartWith

        public void alterSequenceRestartWith​(java.lang.String schemaName,
                                             java.lang.String sequenceName,
                                             long restartWith,
                                             int cache,
                                             int incrementBy)
        Description copied from interface: ISchemaAdapter
        Sets/resets the sequence to start with the given value.
        Specified by:
        alterSequenceRestartWith in interface ISchemaAdapter
      • grantObjectPrivileges

        public void grantObjectPrivileges​(java.lang.String schemaName,
                                          java.lang.String tableName,
                                          java.util.Collection<Privilege> privileges,
                                          java.lang.String toUser)
        Description copied from interface: ISchemaAdapter
        Grant the list of privileges on the named object to the user. This is a general purpose method which can be used to specify privileges for any object type which doesn't need the object type to be specified in the grant DDL.
        Specified by:
        grantObjectPrivileges in interface ISchemaAdapter
      • grantProcedurePrivileges

        public void grantProcedurePrivileges​(java.lang.String schemaName,
                                             java.lang.String procedureName,
                                             java.util.Collection<Privilege> privileges,
                                             java.lang.String toUser)
        Description copied from interface: ISchemaAdapter
        Grant the collection of privileges on the named procedure to the user
        Specified by:
        grantProcedurePrivileges in interface ISchemaAdapter
      • grantVariablePrivileges

        public void grantVariablePrivileges​(java.lang.String schemaName,
                                            java.lang.String variableName,
                                            java.util.Collection<Privilege> privileges,
                                            java.lang.String toUser)
        Description copied from interface: ISchemaAdapter
        Grant the collection of privileges on the named variable to the user
        Specified by:
        grantVariablePrivileges in interface ISchemaAdapter
      • grantSequencePrivileges

        public void grantSequencePrivileges​(java.lang.String schemaName,
                                            java.lang.String objectName,
                                            java.util.Collection<Privilege> group,
                                            java.lang.String toUser)
        Description copied from interface: ISchemaAdapter
        Grant the collection of privileges on the named variable to the user
        Specified by:
        grantSequencePrivileges in interface ISchemaAdapter
      • grantSchemaUsage

        public void grantSchemaUsage​(java.lang.String schemaName,
                                     java.lang.String grantToUser)
        Description copied from interface: ISchemaAdapter
        Grants USAGE on the given schemaName to the given user
        Specified by:
        grantSchemaUsage in interface ISchemaAdapter
      • grantAllSequenceUsage

        public void grantAllSequenceUsage​(java.lang.String schemaName,
                                          java.lang.String grantToUser)
        Description copied from interface: ISchemaAdapter
        Grant access to all sequences in the named schema
        Specified by:
        grantAllSequenceUsage in interface ISchemaAdapter
      • doesTableExist

        public boolean doesTableExist​(java.lang.String schemaName,
                                      java.lang.String objectName)
        Description copied from interface: ISchemaAdapter
        Check if the table currently exists
        Specified by:
        doesTableExist in interface ISchemaAdapter
        Returns:
      • createSchema

        public void createSchema​(java.lang.String schemaName)
        Description copied from interface: ISchemaAdapter
        Create a database schema
        Specified by:
        createSchema in interface ISchemaAdapter
      • createUniqueConstraint

        public void createUniqueConstraint​(java.lang.String constraintName,
                                           java.util.List<java.lang.String> columns,
                                           java.lang.String schemaName,
                                           java.lang.String name)
        Description copied from interface: ISchemaAdapter
        create a unique constraint on a table.
        Specified by:
        createUniqueConstraint in interface ISchemaAdapter
      • checkCompatibility

        public boolean checkCompatibility​(java.lang.String adminSchema)
        Description copied from interface: ISchemaAdapter
        checks connectivity to the database and that it is compatible
        Specified by:
        checkCompatibility in interface ISchemaAdapter
        Returns:
      • createOrReplaceFunction

        public void createOrReplaceFunction​(java.lang.String schemaName,
                                            java.lang.String objectName,
                                            java.util.function.Supplier<java.lang.String> supplier)
        Description copied from interface: ISchemaAdapter
        creates or replaces the SQL function
        Specified by:
        createOrReplaceFunction in interface ISchemaAdapter
      • distributeFunction

        public void distributeFunction​(java.lang.String schemaName,
                                       java.lang.String functionName,
                                       int distributeByParamNumber)
        Description copied from interface: ISchemaAdapter
        For Citus, functions can be distributed by one of their parameters (typically the first)
        Specified by:
        distributeFunction in interface ISchemaAdapter
      • dropFunction

        public void dropFunction​(java.lang.String schemaName,
                                 java.lang.String functionName)
        Description copied from interface: ISchemaAdapter
        drops a given function
        Specified by:
        dropFunction in interface ISchemaAdapter
      • grantFunctionPrivileges

        public void grantFunctionPrivileges​(java.lang.String schemaName,
                                            java.lang.String functionName,
                                            java.util.Collection<Privilege> privileges,
                                            java.lang.String toUser)
        Description copied from interface: ISchemaAdapter
        grants permissions on a given function
        Specified by:
        grantFunctionPrivileges in interface ISchemaAdapter
      • disableForeignKey

        public void disableForeignKey​(java.lang.String schemaName,
                                      java.lang.String tableName,
                                      java.lang.String constraintName)
        Description copied from interface: ISchemaAdapter
        Disable the FK with the given constraint name
        Specified by:
        disableForeignKey in interface ISchemaAdapter
      • dropForeignKey

        public void dropForeignKey​(java.lang.String schemaName,
                                   java.lang.String tableName,
                                   java.lang.String constraintName)
        Description copied from interface: ISchemaAdapter
        Drop the FK on the table with the given constraint name
        Specified by:
        dropForeignKey in interface ISchemaAdapter
      • enableForeignKey

        public void enableForeignKey​(java.lang.String schemaName,
                                     java.lang.String tableName,
                                     java.lang.String constraintName)
        Description copied from interface: ISchemaAdapter
        Enable the FK with the given constraint name
        Specified by:
        enableForeignKey in interface ISchemaAdapter
      • doesForeignKeyConstraintExist

        public boolean doesForeignKeyConstraintExist​(java.lang.String schemaName,
                                                     java.lang.String tableName,
                                                     java.lang.String constraintName)
        Description copied from interface: ISchemaAdapter
        Check to see if the named foreign key constraint already exists
        Specified by:
        doesForeignKeyConstraintExist in interface ISchemaAdapter
        Returns:
      • setIntegrityOff

        public void setIntegrityOff​(java.lang.String schemaName,
                                    java.lang.String tableName)
        Specified by:
        setIntegrityOff in interface ISchemaAdapter
      • setIntegrityUnchecked

        public void setIntegrityUnchecked​(java.lang.String schemaName,
                                          java.lang.String tableName)
        Specified by:
        setIntegrityUnchecked in interface ISchemaAdapter
      • alterTableColumnIdentityCache

        public void alterTableColumnIdentityCache​(java.lang.String schemaName,
                                                  java.lang.String objectName,
                                                  java.lang.String columnName,
                                                  int cache)
        Description copied from interface: ISchemaAdapter
        Change the CACHE value of the named identity generated always column
        Specified by:
        alterTableColumnIdentityCache in interface ISchemaAdapter
      • dropIndex

        public void dropIndex​(java.lang.String schemaName,
                              java.lang.String indexName)
        Description copied from interface: ISchemaAdapter
        Drop the named index
        Specified by:
        dropIndex in interface ISchemaAdapter
      • createView

        public void createView​(java.lang.String schemaName,
                               java.lang.String objectName,
                               java.lang.String selectClause)
        Description copied from interface: ISchemaAdapter
        Create the view as defined by the selectClause
        Specified by:
        createView in interface ISchemaAdapter
      • dropView

        public void dropView​(java.lang.String schemaName,
                             java.lang.String objectName)
        Description copied from interface: ISchemaAdapter
        Drop the view from the database
        Specified by:
        dropView in interface ISchemaAdapter
      • createOrReplaceView

        public void createOrReplaceView​(java.lang.String schemaName,
                                        java.lang.String objectName,
                                        java.lang.String selectClause)
        Description copied from interface: ISchemaAdapter
        Create or replace the view
        Specified by:
        createOrReplaceView in interface ISchemaAdapter