Class DerbyAdapter
- java.lang.Object
-
- org.linuxforhealth.fhir.database.utils.common.CommonDatabaseAdapter
-
- org.linuxforhealth.fhir.database.utils.derby.DerbyAdapter
-
- All Implemented Interfaces:
IDatabaseAdapter
,IDatabaseTypeAdapter
public class DerbyAdapter extends CommonDatabaseAdapter
A Derby database target
-
-
Field Summary
-
Fields inherited from class org.linuxforhealth.fhir.database.utils.common.CommonDatabaseAdapter
connectionProvider, target
-
-
Constructor Summary
Constructors Constructor Description DerbyAdapter()
DerbyAdapter(IConnectionProvider cp)
DerbyAdapter(IDatabaseTarget tgt)
Public constructor
-
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
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 columnjava.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 compatiblevoid
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.util.List<java.lang.String> columns, boolean enforced)
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 suppliervoid
createOrReplaceView(java.lang.String schemaName, java.lang.String viewName, java.lang.String selectClause)
Create or replace the viewvoid
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 schemavoid
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, DistributionContext distributionContext)
Build the create table DDLvoid
createTablespace(java.lang.String tablespaceName)
Create a new tablespace with the given namevoid
createTablespace(java.lang.String tablespaceName, int extentSizeKB)
Create a new tablespace using the given extent sizevoid
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, DistributionContext distributionContext)
Create a unique indexvoid
disableForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
Disable the FK with the given constraint nameboolean
doesForeignKeyConstraintExist(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
Does the named foreign key constraint existboolean
doesTableExist(java.lang.String schemaName, java.lang.String tableName)
Check if the table currently existsvoid
dropPermission(java.lang.String schemaName, java.lang.String permissionName)
Drop permission object from the schemavoid
dropProcedure(java.lang.String schemaName, java.lang.String procedureName)
Drop the given procedurevoid
dropSequence(java.lang.String schemaName, java.lang.String sequenceName)
void
dropTable(java.lang.String schemaName, java.lang.String tableName)
Drop table from the schemavoid
dropTablespace(java.lang.String tablespaceName)
Drop an existing tablespace, including all of its contentsvoid
dropType(java.lang.String schemaName, java.lang.String typeName)
Drop the type object from the schemavoid
enableForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
Enable the FK with the given constraint namejava.util.List<SchemaInfoObject>
listSchemaObjects(java.lang.String schemaName)
List the objects present in the given schemaprotected 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 nullvoid
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)
java.lang.String
timestampClause(java.lang.Integer precision)
Generate a clause for TIMESTAMPjava.lang.String
varbinaryClause(int size)
Generate a clause for binary data typejava.lang.String
varcharClause(int size)
Generate a clause for VARCHARvoid
warnOnce(org.linuxforhealth.fhir.database.utils.derby.DerbyAdapter.MessageKey messageKey, java.lang.String msg)
Once write each warning message once-
Methods inherited from class org.linuxforhealth.fhir.database.utils.common.CommonDatabaseAdapter
alterTableAddColumn, applyDistributionRules, buildColumns, buildCreateTableStatement, createIndex, createOrReplaceFunction, createUniqueConstraint, createUniqueIndex, createView, distributeFunction, dropForeignKey, dropFunction, dropIndex, dropVariable, dropView, getQualifiedName, getTranslator, grantAllSequenceUsage, grantFunctionPrivileges, grantObjectPrivileges, grantProcedurePrivileges, grantSchemaUsage, grantSequencePrivileges, grantVariablePrivileges, runStatement, runStatement
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.linuxforhealth.fhir.database.utils.api.IDatabaseAdapter
useSessionVariable
-
Methods inherited from interface org.linuxforhealth.fhir.database.utils.api.IDatabaseTypeAdapter
clobClause, doubleClause, smallintClause
-
-
-
-
Constructor Detail
-
DerbyAdapter
public DerbyAdapter(IDatabaseTarget tgt)
Public constructor- Parameters:
tgt
- the target database we want to manage
-
DerbyAdapter
public DerbyAdapter(IConnectionProvider cp)
-
DerbyAdapter
public DerbyAdapter()
-
-
Method Detail
-
warnOnce
public void warnOnce(org.linuxforhealth.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.util.List<ColumnBase> columns, PrimaryKeyDef primaryKey, IdentityDef identity, java.lang.String tablespaceName, java.util.List<With> withs, java.util.List<CheckConstraint> checkConstraints, DistributionContext distributionContext)
Description copied from interface:IDatabaseAdapter
Build the create table DDL
-
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, DistributionContext distributionContext)
Description copied from interface:IDatabaseAdapter
Create a unique index- Specified by:
createUniqueIndex
in interfaceIDatabaseAdapter
- Overrides:
createUniqueIndex
in classCommonDatabaseAdapter
-
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
-
createOrReplaceProcedure
public void createOrReplaceProcedure(java.lang.String schemaName, java.lang.String procedureName, java.util.function.Supplier<java.lang.String> supplier)
Description copied from interface:IDatabaseAdapter
Create the stored procedure using the DDL text provided by the supplier- Specified by:
createOrReplaceProcedure
in interfaceIDatabaseAdapter
- Overrides:
createOrReplaceProcedure
in classCommonDatabaseAdapter
-
dropProcedure
public void dropProcedure(java.lang.String schemaName, java.lang.String procedureName)
Description copied from interface:IDatabaseAdapter
Drop the given procedure- Specified by:
dropProcedure
in interfaceIDatabaseAdapter
- Overrides:
dropProcedure
in classCommonDatabaseAdapter
-
dropPermission
public void dropPermission(java.lang.String schemaName, java.lang.String permissionName)
Description copied from interface:IDatabaseAdapter
Drop permission object from the schema- Specified by:
dropPermission
in interfaceIDatabaseAdapter
- Overrides:
dropPermission
in classCommonDatabaseAdapter
-
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
-
dropTable
public void dropTable(java.lang.String schemaName, java.lang.String tableName)
Description copied from interface:IDatabaseAdapter
Drop table from the schema- Specified by:
dropTable
in interfaceIDatabaseAdapter
- Overrides:
dropTable
in classCommonDatabaseAdapter
-
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 interfaceIDatabaseAdapter
- Overrides:
createSequence
in classCommonDatabaseAdapter
startWith
- the START WITH value for the sequencecache
- the sequence CACHE value
-
dropSequence
public void dropSequence(java.lang.String schemaName, java.lang.String sequenceName)
- Specified by:
dropSequence
in interfaceIDatabaseAdapter
- Overrides:
dropSequence
in classCommonDatabaseAdapter
-
alterSequenceRestartWith
public void alterSequenceRestartWith(java.lang.String schemaName, java.lang.String sequenceName, long restartWith, int cache, int incrementBy)
Description copied from interface:IDatabaseAdapter
Sets/resets the sequence to start with the given value.- Specified by:
alterSequenceRestartWith
in interfaceIDatabaseAdapter
- Overrides:
alterSequenceRestartWith
in classCommonDatabaseAdapter
-
alterTableColumnIdentityCache
public void alterTableColumnIdentityCache(java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, int cache)
Description copied from interface:IDatabaseAdapter
Change the CACHE value of the named identity generated always column- Specified by:
alterTableColumnIdentityCache
in interfaceIDatabaseAdapter
- Overrides:
alterTableColumnIdentityCache
in classCommonDatabaseAdapter
-
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.util.List<java.lang.String> columns, boolean enforced)
- Specified by:
createForeignKeyConstraint
in interfaceIDatabaseAdapter
- Overrides:
createForeignKeyConstraint
in classCommonDatabaseAdapter
-
doesForeignKeyConstraintExist
public boolean doesForeignKeyConstraintExist(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
Description copied from interface:IDatabaseAdapter
Does the named foreign key constraint exist- Returns:
-
prefixTenantColumn
protected java.util.List<OrderedColumnDef> prefixTenantColumn(java.lang.String tenantColumnName, java.util.List<OrderedColumnDef> columns)
Description copied from class:CommonDatabaseAdapter
Prefix the tenantColumnName to the list of columns, or do nothing if tenantColumnName is null- Overrides:
prefixTenantColumn
in classCommonDatabaseAdapter
- Returns:
-
runStatement
public void runStatement(IDatabaseStatement stmt)
Description copied from class:CommonDatabaseAdapter
Run the statement using the connectionProvider to obtain a new connection. Also, there should be a transaction open on the current thread at this time- Specified by:
runStatement
in interfaceIDatabaseAdapter
- Overrides:
runStatement
in classCommonDatabaseAdapter
-
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
-
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)
-
createOrReplaceView
public void createOrReplaceView(java.lang.String schemaName, java.lang.String viewName, java.lang.String selectClause)
Description copied from interface:IDatabaseAdapter
Create or replace the view- Specified by:
createOrReplaceView
in interfaceIDatabaseAdapter
- Overrides:
createOrReplaceView
in classCommonDatabaseAdapter
-
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:
-
-