Class Table
- java.lang.Object
-
- org.linuxforhealth.fhir.database.utils.model.BaseObject
-
- org.linuxforhealth.fhir.database.utils.model.Table
-
- All Implemented Interfaces:
IDatabaseObject
public class Table extends BaseObject
An immutable definition of a table
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Table.Builder
Builder for table
-
Field Summary
-
Fields inherited from class org.linuxforhealth.fhir.database.utils.model.BaseObject
migrations, version
-
-
Constructor Summary
Constructors Constructor Description Table(java.lang.String schemaName, java.lang.String name, int version, java.util.Collection<ColumnBase> columns, PrimaryKeyDef pk, IdentityDef identity, java.util.Collection<IndexDef> indexes, java.util.Collection<ForeignKeyConstraint> fkConstraints, Tablespace tablespace, java.util.List<IDatabaseObject> dependencies, java.util.Map<java.lang.String,java.lang.String> tags, java.util.Collection<GroupPrivilege> privileges, java.util.List<Migration> migrations, java.util.List<With> withs, java.util.List<CheckConstraint> checkConstraints, DistributionType distributionType, java.lang.String distributionColumnName, boolean create)
Public constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(java.lang.Integer priorVersion, ISchemaAdapter target, SchemaApplyContext context)
Apply migration logic to bring the target database to the current level of this objectvoid
apply(ISchemaAdapter target, SchemaApplyContext context)
Apply the DDL for this object to the target databasevoid
applyDistributionRules(ISchemaAdapter target, int pass)
Apply any distribution rules associated with the object (usually a table)static Table.Builder
builder(java.lang.String schemaName, java.lang.String tableName)
Create a builder forTable
.void
drop(ISchemaAdapter target)
DROP this object from the target databaseboolean
exists(ISchemaAdapter target)
return true if the table already exists in the targetDistributionType
getDistributionType()
Getter for the table's distributionTypeIdentityDef
getIdentity()
Getter for the identity definition, or null if there isn't onePrimaryKeyDef
getPrimaryKey()
Getter for the primary key definition, or null if there isn't oneprotected void
grantGroupPrivileges(ISchemaAdapter target, java.util.Set<Privilege> group, java.lang.String toUser)
Internal method which can be override by different object types which may need to call a different grant method on the adapterboolean
isCreate()
Getter for the create flagvoid
visit(DataModelVisitor v)
Visit thisIDatabaseObject
with the givenDataModelVisitor
.void
visitReverse(DataModelVisitor v)
Visit thisIDatabaseObject
with the givenDataModelVisitor
.-
Methods inherited from class org.linuxforhealth.fhir.database.utils.model.BaseObject
addDependencies, addDependency, addPrivilege, addTag, addTags, applyTx, applyVersion, collect, equals, fetchDependenciesTo, getName, getObjectName, getObjectType, getQualifiedName, getSchemaName, getTags, getTypeNameVersion, getVersion, grant, hashCode, toString, visit
-
-
-
-
Constructor Detail
-
Table
public Table(java.lang.String schemaName, java.lang.String name, int version, java.util.Collection<ColumnBase> columns, PrimaryKeyDef pk, IdentityDef identity, java.util.Collection<IndexDef> indexes, java.util.Collection<ForeignKeyConstraint> fkConstraints, Tablespace tablespace, java.util.List<IDatabaseObject> dependencies, java.util.Map<java.lang.String,java.lang.String> tags, java.util.Collection<GroupPrivilege> privileges, java.util.List<Migration> migrations, java.util.List<With> withs, java.util.List<CheckConstraint> checkConstraints, DistributionType distributionType, java.lang.String distributionColumnName, boolean create)
Public constructor- Parameters:
schemaName
-name
-version
-columns
-pk
-identity
-indexes
-fkConstraints
-accessControlVar
-tablespace
-dependencies
-tags
-privileges
-migrations
-withs
-checkConstraints
-distributionType
-distributionColumnName
-create
-
-
-
Method Detail
-
getPrimaryKey
public PrimaryKeyDef getPrimaryKey()
Getter for the primary key definition, or null if there isn't one- Returns:
-
getIdentity
public IdentityDef getIdentity()
Getter for the identity definition, or null if there isn't one- Returns:
-
isCreate
public boolean isCreate()
Getter for the create flag- Returns:
- whether the table should be created or not
-
getDistributionType
public DistributionType getDistributionType()
Getter for the table's distributionType- Returns:
-
apply
public void apply(ISchemaAdapter target, SchemaApplyContext context)
Description copied from interface:IDatabaseObject
Apply the DDL for this object to the target database- Parameters:
target
- the database targetcontext
- context to control the schema apply process
-
apply
public void apply(java.lang.Integer priorVersion, ISchemaAdapter target, SchemaApplyContext context)
Description copied from interface:IDatabaseObject
Apply migration logic to bring the target database to the current level of this objecttarget
- the database targetcontext
- to control the schema apply process
-
grantGroupPrivileges
protected void grantGroupPrivileges(ISchemaAdapter target, java.util.Set<Privilege> group, java.lang.String toUser)
Description copied from class:BaseObject
Internal method which can be override by different object types which may need to call a different grant method on the adapter- Overrides:
grantGroupPrivileges
in classBaseObject
-
drop
public void drop(ISchemaAdapter target)
Description copied from interface:IDatabaseObject
DROP this object from the target database
-
builder
public static Table.Builder builder(java.lang.String schemaName, java.lang.String tableName)
Create a builder forTable
.- Parameters:
schemaName
-tableName
-- Returns:
-
exists
public boolean exists(ISchemaAdapter target)
return true if the table already exists in the target- Parameters:
target
-- Returns:
-
visit
public void visit(DataModelVisitor v)
Description copied from interface:IDatabaseObject
Visit thisIDatabaseObject
with the givenDataModelVisitor
. Any sub-objects should be visited in creation order.
-
visitReverse
public void visitReverse(DataModelVisitor v)
Description copied from interface:IDatabaseObject
Visit thisIDatabaseObject
with the givenDataModelVisitor
. Any sub-objects should be visited in reverse order.
-
applyDistributionRules
public void applyDistributionRules(ISchemaAdapter target, int pass)
Description copied from interface:IDatabaseObject
Apply any distribution rules associated with the object (usually a table)- Specified by:
applyDistributionRules
in interfaceIDatabaseObject
- Overrides:
applyDistributionRules
in classBaseObject
- Parameters:
target
- the target database we apply the operation topass
- multiple pass number
-
-