Class DerbyAdapter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void activateRowAccessControl​(java.lang.String schemaName, java.lang.String tableName)
      ALTER TABLE ACTIVATE ROW ACCESS CONTROL
      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 alterTableColumnIdentityCache​(java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, int cache)
      Change the CACHE value of the named identity generated always column
      java.lang.String blobClause​(long size, int inlineSize)
      Generate a clause for BLOB (with an inline size if supported)
      boolean checkCompatibility​(java.lang.String adminSchema)
      checks connectivity to the database and that it is compatible
      void createArrType​(java.lang.String schemaName, java.lang.String typeName, java.lang.String valueType, int arraySize)
      Create ARRAY type used for passing values to stored procedures e.g.: CREATE OR REPLACE TYPE .t_str_values_arr AS .t_str_values ARRAY[256]
      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.lang.String tenantColumnName, java.util.List<java.lang.String> columns, boolean enforced)  
      void createIntVariable​(java.lang.String schemaName, java.lang.String variableName)
      CREATE VARIABLE ptng.session_tenant INT DEFAULT NULL;
      void createOrReplacePermission​(java.lang.String schemaName, java.lang.String permissionName, java.lang.String tableName, java.lang.String predicate)
      CREATE OR REPLACE PERMISSION ROW_ACCESS ON ptng.patients FOR ROWS WHERE patients.mt_id = ptng.session_tenant ENFORCED FOR ALL ACCESS ENABLE;
      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 viewName, java.lang.String selectClause)
      Create or replace the view
      void createRowType​(java.lang.String schemaName, java.lang.String typeName, java.util.List<ColumnBase> columns)
      Create ROW type used for passing values to stored procedures e.g.:
      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.lang.String tenantColumnName, java.util.List<ColumnBase> columns, PrimaryKeyDef primaryKey, IdentityDef identity, java.lang.String tablespaceName, java.util.List<With> withs, java.util.List<CheckConstraint> checkConstraints)
      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 createTenantPartitions​(java.util.Collection<Table> tables, java.lang.String schemaName, int newTenantId, int extentSizeKB)
      Create the partitions on each of these tables
      void createUniqueIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.lang.String tenantColumnName, java.util.List<OrderedColumnDef> indexColumns, java.util.List<java.lang.String> includeColumns)  
      void deactivateRowAccessControl​(java.lang.String schemaName, java.lang.String tableName)
      Deactivate row access control on a table ALTER TABLE DEACTIVATE ROW ACCESS CONTROL
      void detachPartition​(java.lang.String schemaName, java.lang.String tableName, java.lang.String partitionName, java.lang.String newTableName)
      Detach the partition
      void disableForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Disable the FK with the given constraint name
      boolean doesTableExist​(java.lang.String schemaName, java.lang.String tableName)
      Check if the table currently exists
      void dropDetachedPartitions​(java.util.Collection<Table> tables, java.lang.String schemaName, int tenantId)
      Drop the tables which were created by the detach partition operation (as part of tenant deprovisioning).
      void dropPermission​(java.lang.String schemaName, java.lang.String permissionName)
      Drop permission object from the schema
      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 tableName)
      Drop table from the schema
      void dropTablespace​(java.lang.String tablespaceName)
      Drop an existing tablespace, including all of its contents
      void dropTenantTablespace​(int tenantId)
      Drop the tablespace associated with the given tenantId
      void dropType​(java.lang.String schemaName, java.lang.String typeName)
      Drop the type object from the schema
      void enableForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Enable the FK with the given constraint name
      java.util.List<SchemaInfoObject> listSchemaObjects​(java.lang.String schemaName)
      List the objects present in the given schema
      protected java.util.List<OrderedColumnDef> prefixTenantColumn​(java.lang.String tenantColumnName, java.util.List<OrderedColumnDef> columns)
      Prefix the tenantColumnName to the list of columns, or do nothing if tenantColumnName is null
      void removeTenantPartitions​(java.util.Collection<Table> tables, java.lang.String schemaName, int tenantId)
      Detach the partition associated with the tenantId from each of the given tables
      void runStatement​(IDatabaseStatement stmt)
      Run the statement using the connectionProvider to obtain a new connection.
      void setIntegrityOff​(java.lang.String schemaName, java.lang.String tableName)  
      void setIntegrityUnchecked​(java.lang.String schemaName, java.lang.String tableName)  
      void setIntVariable​(java.lang.String schemaName, java.lang.String variableName, int value)
      Build the DML statement for setting a session variable
      java.lang.String timestampClause​(java.lang.Integer precision)
      Generate a clause for TIMESTAMP
      java.lang.String varbinaryClause​(int size)
      Generate a clause for binary data type
      java.lang.String varcharClause​(int size)
      Generate a clause for VARCHAR
      void warnOnce​(com.ibm.fhir.database.utils.derby.DerbyAdapter.MessageKey messageKey, java.lang.String msg)
      Once write each warning message once
      • Methods inherited from class java.lang.Object

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

      • DerbyAdapter

        public DerbyAdapter​(IDatabaseTarget tgt)
        Public constructor
        Parameters:
        tgt - the target database we want to manage
      • DerbyAdapter

        public DerbyAdapter()
    • Method Detail

      • warnOnce

        public void warnOnce​(com.ibm.fhir.database.utils.derby.DerbyAdapter.MessageKey messageKey,
                             java.lang.String msg)
        Once write each warning message once
        Parameters:
        msg -
      • createTable

        public void createTable​(java.lang.String schemaName,
                                java.lang.String name,
                                java.lang.String tenantColumnName,
                                java.util.List<ColumnBase> columns,
                                PrimaryKeyDef primaryKey,
                                IdentityDef identity,
                                java.lang.String tablespaceName,
                                java.util.List<With> withs,
                                java.util.List<CheckConstraint> checkConstraints)
        Description copied from interface: IDatabaseAdapter
        Build the create table DDL
        tenantColumnName - optional column name to enable multi-tenancy
      • createIntVariable

        public void createIntVariable​(java.lang.String schemaName,
                                      java.lang.String variableName)
        Description copied from interface: IDatabaseAdapter
         CREATE VARIABLE ptng.session_tenant INT DEFAULT NULL;
         
      • createOrReplacePermission

        public void createOrReplacePermission​(java.lang.String schemaName,
                                              java.lang.String permissionName,
                                              java.lang.String tableName,
                                              java.lang.String predicate)
        Description copied from interface: IDatabaseAdapter
         CREATE OR REPLACE PERMISSION ROW_ACCESS ON ptng.patients FOR ROWS WHERE patients.mt_id =
         ptng.session_tenant ENFORCED FOR ALL ACCESS ENABLE;
         
      • activateRowAccessControl

        public void activateRowAccessControl​(java.lang.String schemaName,
                                             java.lang.String tableName)
        Description copied from interface: IDatabaseAdapter
         ALTER TABLE  ACTIVATE ROW ACCESS CONTROL
         
      • setIntVariable

        public void setIntVariable​(java.lang.String schemaName,
                                   java.lang.String variableName,
                                   int value)
        Description copied from interface: IDatabaseAdapter
        Build the DML statement for setting a session variable
      • deactivateRowAccessControl

        public void deactivateRowAccessControl​(java.lang.String schemaName,
                                               java.lang.String tableName)
        Description copied from interface: IDatabaseAdapter
        Deactivate row access control on a table ALTER TABLE DEACTIVATE ROW ACCESS CONTROL
      • createTenantPartitions

        public void createTenantPartitions​(java.util.Collection<Table> tables,
                                           java.lang.String schemaName,
                                           int newTenantId,
                                           int extentSizeKB)
        Description copied from interface: IDatabaseAdapter
        Create the partitions on each of these tables
      • createRowType

        public void createRowType​(java.lang.String schemaName,
                                  java.lang.String typeName,
                                  java.util.List<ColumnBase> columns)
        Description copied from interface: IDatabaseAdapter
        Create ROW type used for passing values to stored procedures e.g.:
         CREATE OR REPLACE TYPE .t_str_values AS ROW (parameter_name_id INTEGER,
         str_value VARCHAR(511 OCTETS), str_value_lcase VARCHAR(511 OCTETS))
         
      • createArrType

        public void createArrType​(java.lang.String schemaName,
                                  java.lang.String typeName,
                                  java.lang.String valueType,
                                  int arraySize)
        Description copied from interface: IDatabaseAdapter
        Create ARRAY type used for passing values to stored procedures e.g.: CREATE OR REPLACE TYPE .t_str_values_arr AS .t_str_values ARRAY[256]
      • dropType

        public void dropType​(java.lang.String schemaName,
                             java.lang.String typeName)
        Description copied from interface: IDatabaseAdapter
        Drop the type object from the schema
      • createTablespace

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

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

        public void dropTablespace​(java.lang.String tablespaceName)
        Description copied from interface: IDatabaseAdapter
        Drop an existing tablespace, including all of its contents
      • detachPartition

        public void detachPartition​(java.lang.String schemaName,
                                    java.lang.String tableName,
                                    java.lang.String partitionName,
                                    java.lang.String newTableName)
        Description copied from interface: IDatabaseAdapter
        Detach the partition
      • removeTenantPartitions

        public void removeTenantPartitions​(java.util.Collection<Table> tables,
                                           java.lang.String schemaName,
                                           int tenantId)
        Description copied from interface: IDatabaseAdapter
        Detach the partition associated with the tenantId from each of the given tables
      • doesTableExist

        public boolean doesTableExist​(java.lang.String schemaName,
                                      java.lang.String tableName)
        Description copied from interface: IDatabaseAdapter
        Check if the table currently exists
        Returns:
      • createSequence

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

        public java.lang.String varbinaryClause​(int size)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for binary data type
        Returns:
      • blobClause

        public java.lang.String blobClause​(long size,
                                           int inlineSize)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for BLOB (with an inline size if supported)
        Returns:
      • varcharClause

        public java.lang.String varcharClause​(int size)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for VARCHAR
        Returns:
      • timestampClause

        public java.lang.String timestampClause​(java.lang.Integer precision)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for TIMESTAMP
        Returns:
      • 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.lang.String tenantColumnName,
                                               java.util.List<java.lang.String> columns,
                                               boolean enforced)
        Specified by:
        createForeignKeyConstraint in interface IDatabaseAdapter
        Overrides:
        createForeignKeyConstraint in class CommonDatabaseAdapter
      • checkCompatibility

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

        public void createSchema​(java.lang.String schemaName)
        Description copied from interface: IDatabaseAdapter
        Create a database schema
      • dropDetachedPartitions

        public void dropDetachedPartitions​(java.util.Collection<Table> tables,
                                           java.lang.String schemaName,
                                           int tenantId)
        Description copied from interface: IDatabaseAdapter
        Drop the tables which were created by the detach partition operation (as part of tenant deprovisioning).
      • dropTenantTablespace

        public void dropTenantTablespace​(int tenantId)
        Description copied from interface: IDatabaseAdapter
        Drop the tablespace associated with the given tenantId
      • disableForeignKey

        public void disableForeignKey​(java.lang.String schemaName,
                                      java.lang.String tableName,
                                      java.lang.String constraintName)
        Description copied from interface: IDatabaseAdapter
        Disable the FK with the given constraint name
      • enableForeignKey

        public void enableForeignKey​(java.lang.String schemaName,
                                     java.lang.String tableName,
                                     java.lang.String constraintName)
        Description copied from interface: IDatabaseAdapter
        Enable the FK with the given constraint name
      • setIntegrityOff

        public void setIntegrityOff​(java.lang.String schemaName,
                                    java.lang.String tableName)
      • setIntegrityUnchecked

        public void setIntegrityUnchecked​(java.lang.String schemaName,
                                          java.lang.String tableName)
      • listSchemaObjects

        public java.util.List<SchemaInfoObject> listSchemaObjects​(java.lang.String schemaName)
        Description copied from interface: IDatabaseAdapter
        List the objects present in the given schema
        Returns: