Class Table.Builder
- java.lang.Object
-
- com.ibm.fhir.database.utils.model.VersionedSchemaObject
-
- com.ibm.fhir.database.utils.model.Table.Builder
-
- Enclosing class:
- Table
public static class Table.Builder extends VersionedSchemaObject
Builder for table
-
-
Field Summary
-
Fields inherited from class com.ibm.fhir.database.utils.model.VersionedSchemaObject
migrations, version
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Table.Builder
addBigIntColumn(String columnName, boolean nullable)
Table.Builder
addBigIntColumn(String columnName, boolean nullable, String defaultValue)
Table.Builder
addBlobColumn(String columnName, long size, int inlineSize, boolean nullable)
Table.Builder
addCharColumn(String columnName, int size, boolean nullable)
Add char (fixed-width) columnTable.Builder
addCharColumn(String columnName, int size, boolean nullable, String defaultValue)
Add char (fixed-width) column with a default value specifiedTable.Builder
addClobColumn(String columnName, boolean nullable, String defaultVal)
Table.Builder
addDoubleColumn(String columnName, boolean nullable)
Table.Builder
addForeignKeyConstraint(String constraintName, boolean enforced, String targetSchema, String targetTable, String... columns)
Add a foreign key constraint pointing to the target table.Table.Builder
addForeignKeyConstraint(String constraintName, String targetSchema, String targetTable, String... columns)
Add a foreign key constraint pointing to the target table (with enforcement).Table.Builder
addForeignKeyConstraintAltTarget(String constraintName, String targetSchema, String targetTable, String targetColumnName, String... columns)
Adds a foreign key constraint relationship on itself.Table.Builder
addForeignKeyConstraintSelf(String constraintName, String targetSchema, String targetTable, String targetColumnName, String... columns)
Adds a foreign key constraint relationship on itself.Table.Builder
addIndex(String indexName, OrderedColumnDef... columns)
Table.Builder
addIndex(String indexName, String... columns)
Add an index to the table using the list of column namesTable.Builder
addIntColumn(String columnName, boolean nullable)
Table.Builder
addMigration(Migration... migration)
Add migration steps to perform to upgrade from previous versions of this objectTable.Builder
addPrimaryKey(String constraintName, String... columns)
Add a primary key constraint to the tableTable.Builder
addPrivilege(String groupName, Privilege p)
Table.Builder
addPrivileges(Collection<GroupPrivilege> gps)
Add the collection of group privileges to this tableTable.Builder
addSmallIntColumn(String columnName, Integer defaultValue, boolean nullable)
Table.Builder
addTag(String tagName, String tagValue)
Table.Builder
addTimestampColumn(String columnName, boolean nullable)
Table.Builder
addTimestampColumn(String columnName, boolean nullable, String defaultValue)
Table.Builder
addTimestampColumn(String columnName, int numberOfFractionalSecondDigits, boolean nullable)
Table.Builder
addUniqueConstraint(String constraintName, String... columnName)
Add a unique constraint to the table/columnTable.Builder
addUniqueIndex(String indexName, String... columns)
Add a unique index to the table using the list of column namesTable.Builder
addUniqueIndex(String indexName, Collection<String> indexColumns, Collection<String> includeColumns)
Add a unique index with include columnsTable.Builder
addVarbinaryColumn(String columnName, int size, boolean nullable)
Add a VARBINARY(nn) columnTable.Builder
addVarcharColumn(String columnName, int size, boolean nullable)
Table
build(IDataModel dataModel)
Build the immutable table object based on the current configurationprotected List<ColumnBase>
buildColumns()
Create the columns for the table based on the definitions that have been addedprotected void
checkColumns(String[] columns)
Check each of the columns in the given array are valid column namesprotected void
checkColumns(Collection<String> columns)
Check each of the columns in the given array are valid column namesTable.Builder
enableAccessControl(SessionVariableDef var)
Switch on access control for this tableTable.Builder
setIdentityColumn(String columnName, Generated generated)
Set one of the columns to be the identity column for the tableTable.Builder
setTablespace(Tablespace ts)
Setter for the tablespaceTable.Builder
setTenantColumnName(String name)
Setter to configure this table for multitenancy.Table.Builder
setVersion(int v)
Set the version-
Methods inherited from class com.ibm.fhir.database.utils.model.VersionedSchemaObject
getObjectName, getQualifiedName, getSchemaName, getVersion, setVersionValue
-
-
-
-
Method Detail
-
setVersion
public Table.Builder setVersion(int v)
Set the version- Parameters:
v
-- Returns:
-
setTablespace
public Table.Builder setTablespace(Tablespace ts)
Setter for the tablespace- Parameters:
ts
-- Returns:
-
addIntColumn
public Table.Builder addIntColumn(String columnName, boolean nullable)
-
addSmallIntColumn
public Table.Builder addSmallIntColumn(String columnName, Integer defaultValue, boolean nullable)
-
addBigIntColumn
public Table.Builder addBigIntColumn(String columnName, boolean nullable)
-
addBigIntColumn
public Table.Builder addBigIntColumn(String columnName, boolean nullable, String defaultValue)
-
addDoubleColumn
public Table.Builder addDoubleColumn(String columnName, boolean nullable)
-
addTimestampColumn
public Table.Builder addTimestampColumn(String columnName, boolean nullable)
-
addTimestampColumn
public Table.Builder addTimestampColumn(String columnName, boolean nullable, String defaultValue)
-
addTimestampColumn
public Table.Builder addTimestampColumn(String columnName, int numberOfFractionalSecondDigits, boolean nullable)
-
addVarcharColumn
public Table.Builder addVarcharColumn(String columnName, int size, boolean nullable)
-
addVarbinaryColumn
public Table.Builder addVarbinaryColumn(String columnName, int size, boolean nullable)
Add a VARBINARY(nn) column- Parameters:
columnName
-size
-nullable
-- Returns:
-
addCharColumn
public Table.Builder addCharColumn(String columnName, int size, boolean nullable)
Add char (fixed-width) column- Parameters:
columnName
-size
-nullable
-- Returns:
-
addCharColumn
public Table.Builder addCharColumn(String columnName, int size, boolean nullable, String defaultValue)
Add char (fixed-width) column with a default value specified- Parameters:
columnName
-size
-nullable
-defaultValue
-- Returns:
-
addBlobColumn
public Table.Builder addBlobColumn(String columnName, long size, int inlineSize, boolean nullable)
-
addClobColumn
public Table.Builder addClobColumn(String columnName, boolean nullable, String defaultVal)
- Parameters:
columnName
-nullable
-defaultVal
- this value is auto-quoted; do not pass the single-quote (') within the string value- Returns:
-
setIdentityColumn
public Table.Builder setIdentityColumn(String columnName, Generated generated)
Set one of the columns to be the identity column for the table- Parameters:
constraintName
-columns
-- Returns:
-
addPrimaryKey
public Table.Builder addPrimaryKey(String constraintName, String... columns)
Add a primary key constraint to the table- Parameters:
constraintName
-columns
-- Returns:
-
addIndex
public Table.Builder addIndex(String indexName, String... columns)
Add an index to the table using the list of column names- Parameters:
indexName
-columns
-- Returns:
-
addIndex
public Table.Builder addIndex(String indexName, OrderedColumnDef... columns)
-
addUniqueIndex
public Table.Builder addUniqueIndex(String indexName, String... columns)
Add a unique index to the table using the list of column names- Parameters:
indexName
-columns
-- Returns:
-
addUniqueIndex
public Table.Builder addUniqueIndex(String indexName, Collection<String> indexColumns, Collection<String> includeColumns)
Add a unique index with include columns- Parameters:
indexName
-indexColumns
-includeColumns
-- Returns:
-
addUniqueConstraint
public Table.Builder addUniqueConstraint(String constraintName, String... columnName)
Add a unique constraint to the table/column- Parameters:
constraintName
-columnName
- - at least one column- Returns:
-
addForeignKeyConstraint
public Table.Builder addForeignKeyConstraint(String constraintName, String targetSchema, String targetTable, String... columns)
Add a foreign key constraint pointing to the target table (with enforcement). The list of columns is expected to match the primary key definition on the target.- Parameters:
constraintName
-targetSchema
-targetTable
-columns
-- Returns:
-
addForeignKeyConstraint
public Table.Builder addForeignKeyConstraint(String constraintName, boolean enforced, String targetSchema, String targetTable, String... columns)
Add a foreign key constraint pointing to the target table. The list of columns is expected to match the primary key definition on the target- Parameters:
constraintName
-enforced
-targetSchema
-targetTable
-columns
-- Returns:
-
addForeignKeyConstraintSelf
public Table.Builder addForeignKeyConstraintSelf(String constraintName, String targetSchema, String targetTable, String targetColumnName, String... columns)
Adds a foreign key constraint relationship on itself. This is intentionally created as a separate method, so there are no mistakes.- Parameters:
constraintName
-targetSchema
-targetTable
-targetColumnName
-columns
-- Returns:
-
addForeignKeyConstraintAltTarget
public Table.Builder addForeignKeyConstraintAltTarget(String constraintName, String targetSchema, String targetTable, String targetColumnName, String... columns)
Adds a foreign key constraint relationship on itself. This is intentionally created as a separate method, so there are no mistakes.- Parameters:
constraintName
-targetSchema
-targetTable
-targetColumnName
-columns
-- Returns:
-
checkColumns
protected void checkColumns(String[] columns)
Check each of the columns in the given array are valid column names- Parameters:
columns
-
-
checkColumns
protected void checkColumns(Collection<String> columns)
Check each of the columns in the given array are valid column names- Parameters:
columns
-
-
build
public Table build(IDataModel dataModel)
Build the immutable table object based on the current configuration- Parameters:
dataModel
-- Returns:
-
buildColumns
protected List<ColumnBase> buildColumns()
Create the columns for the table based on the definitions that have been added- Returns:
-
enableAccessControl
public Table.Builder enableAccessControl(SessionVariableDef var)
Switch on access control for this table
-
addTag
public Table.Builder addTag(String tagName, String tagValue)
- Parameters:
tagName
-tagValue
-- Returns:
-
addPrivilege
public Table.Builder addPrivilege(String groupName, Privilege p)
-
addPrivileges
public Table.Builder addPrivileges(Collection<GroupPrivilege> gps)
Add the collection of group privileges to this table- Parameters:
gps
-- Returns:
-
setTenantColumnName
public Table.Builder setTenantColumnName(String name)
Setter to configure this table for multitenancy. Multitenancy support depends on the target ...which in this case means DB2 supports it (using partitioning) but Derby does not...so for Derby, we don't create the extra column or FK relationships back to the TENANTS table.- Returns:
-
addMigration
public Table.Builder addMigration(Migration... migration)
Description copied from class:VersionedSchemaObject
Add migration steps to perform to upgrade from previous versions of this object- Overrides:
addMigration
in classVersionedSchemaObject
- Returns:
-
-