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 classTable.BuilderBuilder 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 voidapply(java.lang.Integer priorVersion, ISchemaAdapter target, SchemaApplyContext context)Apply migration logic to bring the target database to the current level of this objectvoidapply(ISchemaAdapter target, SchemaApplyContext context)Apply the DDL for this object to the target databasevoidapplyDistributionRules(ISchemaAdapter target, int pass)Apply any distribution rules associated with the object (usually a table)static Table.Builderbuilder(java.lang.String schemaName, java.lang.String tableName)Create a builder forTable.voiddrop(ISchemaAdapter target)DROP this object from the target databasebooleanexists(ISchemaAdapter target)return true if the table already exists in the targetDistributionTypegetDistributionType()Getter for the table's distributionTypeIdentityDefgetIdentity()Getter for the identity definition, or null if there isn't onePrimaryKeyDefgetPrimaryKey()Getter for the primary key definition, or null if there isn't oneprotected voidgrantGroupPrivileges(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 adapterbooleanisCreate()Getter for the create flagvoidvisit(DataModelVisitor v)Visit thisIDatabaseObjectwith the givenDataModelVisitor.voidvisitReverse(DataModelVisitor v)Visit thisIDatabaseObjectwith 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:IDatabaseObjectApply 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:IDatabaseObjectApply 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:BaseObjectInternal method which can be override by different object types which may need to call a different grant method on the adapter- Overrides:
grantGroupPrivilegesin classBaseObject
-
drop
public void drop(ISchemaAdapter target)
Description copied from interface:IDatabaseObjectDROP 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:IDatabaseObjectVisit thisIDatabaseObjectwith the givenDataModelVisitor. Any sub-objects should be visited in creation order.
-
visitReverse
public void visitReverse(DataModelVisitor v)
Description copied from interface:IDatabaseObjectVisit thisIDatabaseObjectwith the givenDataModelVisitor. Any sub-objects should be visited in reverse order.
-
applyDistributionRules
public void applyDistributionRules(ISchemaAdapter target, int pass)
Description copied from interface:IDatabaseObjectApply any distribution rules associated with the object (usually a table)- Specified by:
applyDistributionRulesin interfaceIDatabaseObject- Overrides:
applyDistributionRulesin classBaseObject- Parameters:
target- the target database we apply the operation topass- multiple pass number
-
-