Class BaseObject
- java.lang.Object
-
- com.ibm.fhir.database.utils.model.BaseObject
-
- All Implemented Interfaces:
IDatabaseObject
- Direct Known Subclasses:
AlterSequenceStartWith,AlterTableAddColumn,AlterTableIdentityCache,CreateIndex,FunctionDef,NopObject,ObjectGroup,ProcedureDef,RowArrayType,RowType,Sequence,SessionVariableDef,Table,View
public abstract class BaseObject extends java.lang.Object implements IDatabaseObject
BaseObject
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<Migration>migrationsprotected intversion
-
Constructor Summary
Constructors Constructor Description BaseObject(java.lang.String schemaName, java.lang.String objectName, DatabaseObjectType objectType, int version)Public constructorBaseObject(java.lang.String schemaName, java.lang.String objectName, DatabaseObjectType objectType, int version, java.util.List<Migration> migrations)Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDependencies(java.util.Collection<IDatabaseObject> obj)Add the given collection of dependencies to our setvoidaddDependency(IDatabaseObject obj)Add the given obj as a dependency of this (obj must be created before this, or dropped after this)voidaddPrivilege(java.lang.String groupName, Privilege p)Add the privilege to the named privilege groupvoidaddTag(java.lang.String tagName, java.lang.String tagValue)Add the tag name/value to the tag map for this objectvoidaddTags(java.util.Map<java.lang.String,java.lang.String> tags)Add the given tags to our tag mapvoidapplyTx(IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)Apply the DDL, but within its own transactionvoidapplyVersion(IDatabaseAdapter target, IVersionHistoryService vhs)Apply the change, but only if it has a newer version than we already have recorded in the databaseITaskGroupcollect(ITaskCollector tc, IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)Collect the tasks into a dependency tree so that they can be executed concurrently (but in the right order)booleanequals(java.lang.Object other)voidfetchDependenciesTo(java.util.Collection<IDatabaseObject> out)Fetch dependencies from this into the given out listjava.lang.StringgetName()Return the unique name for this objectjava.lang.StringgetObjectName()DatabaseObjectTypegetObjectType()The type enum of this objectjava.lang.StringgetQualifiedName()java.lang.StringgetSchemaName()java.util.Map<java.lang.String,java.lang.String>getTags()Get the map of tags associated with this object.java.lang.StringgetTypeNameVersion()Get the qualified name for this object: objectType:objectName:objectVersionintgetVersion()Getter for the schema version number this object applies tovoidgrant(IDatabaseAdapter target, java.lang.String groupName, java.lang.String toUser)Grant the given privileges to the userprotected voidgrantGroupPrivileges(IDatabaseAdapter 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 adapterinthashCode()java.lang.StringtoString()voidvisit(java.util.function.Consumer<IDatabaseObject> c)Visit this object, calling the consumer for itself, or its children if any-
Methods inherited from interface com.ibm.fhir.database.utils.model.IDatabaseObject
apply, apply, drop, visit, visitReverse
-
-
-
-
Field Detail
-
version
protected final int version
-
migrations
protected final java.util.List<Migration> migrations
-
-
Constructor Detail
-
BaseObject
public BaseObject(java.lang.String schemaName, java.lang.String objectName, DatabaseObjectType objectType, int version)Public constructor- Parameters:
schemaName-objectName-objectType-version-
-
BaseObject
public BaseObject(java.lang.String schemaName, java.lang.String objectName, DatabaseObjectType objectType, int version, java.util.List<Migration> migrations)Public constructor- Parameters:
schemaName-objectName-objectType-version-
-
-
Method Detail
-
getVersion
public int getVersion()
Description copied from interface:IDatabaseObjectGetter for the schema version number this object applies to- Specified by:
getVersionin interfaceIDatabaseObject- Returns:
-
getObjectType
public DatabaseObjectType getObjectType()
Description copied from interface:IDatabaseObjectThe type enum of this object- Specified by:
getObjectTypein interfaceIDatabaseObject- Returns:
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getSchemaName
public java.lang.String getSchemaName()
-
getObjectName
public java.lang.String getObjectName()
-
getQualifiedName
public java.lang.String getQualifiedName()
-
getTypeNameVersion
public java.lang.String getTypeNameVersion()
Description copied from interface:IDatabaseObjectGet the qualified name for this object: objectType:objectName:objectVersion- Specified by:
getTypeNameVersionin interfaceIDatabaseObject- Returns:
-
addTags
public void addTags(java.util.Map<java.lang.String,java.lang.String> tags)
Add the given tags to our tag map- Parameters:
tags-
-
addTag
public void addTag(java.lang.String tagName, java.lang.String tagValue)Description copied from interface:IDatabaseObjectAdd the tag name/value to the tag map for this object- Specified by:
addTagin interfaceIDatabaseObject
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
addDependency
public void addDependency(IDatabaseObject obj)
Add the given obj as a dependency of this (obj must be created before this, or dropped after this)- Parameters:
obj-
-
addDependencies
public void addDependencies(java.util.Collection<IDatabaseObject> obj)
Add the given collection of dependencies to our set- Specified by:
addDependenciesin interfaceIDatabaseObject- Parameters:
obj-
-
fetchDependenciesTo
public void fetchDependenciesTo(java.util.Collection<IDatabaseObject> out)
Description copied from interface:IDatabaseObjectFetch dependencies from this into the given out list- Specified by:
fetchDependenciesToin interfaceIDatabaseObject
-
getName
public java.lang.String getName()
Return the unique name for this object- Specified by:
getNamein interfaceIDatabaseObject- Returns:
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
collect
public ITaskGroup collect(ITaskCollector tc, IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)
Description copied from interface:IDatabaseObjectCollect the tasks into a dependency tree so that they can be executed concurrently (but in the right order)- Specified by:
collectin interfaceIDatabaseObject
-
applyTx
public void applyTx(IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)
Description copied from interface:IDatabaseObjectApply the DDL, but within its own transaction- Specified by:
applyTxin interfaceIDatabaseObject- Parameters:
target- the target database we apply totp- of thread-specific transactionsvhs- the service interface for adding this object to the version history table
-
applyVersion
public void applyVersion(IDatabaseAdapter target, IVersionHistoryService vhs)
Apply the change, but only if it has a newer version than we already have recorded in the database- Specified by:
applyVersionin interfaceIDatabaseObject- Parameters:
target-vhs- the service used to manage the version history table
-
getTags
public java.util.Map<java.lang.String,java.lang.String> getTags()
Description copied from interface:IDatabaseObjectGet the map of tags associated with this object. Used to find things in the PhysicalDataModel- Specified by:
getTagsin interfaceIDatabaseObject- Returns:
-
grant
public void grant(IDatabaseAdapter target, java.lang.String groupName, java.lang.String toUser)
Description copied from interface:IDatabaseObjectGrant the given privileges to the user- Specified by:
grantin interfaceIDatabaseObject
-
grantGroupPrivileges
protected void grantGroupPrivileges(IDatabaseAdapter 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 adapter- Parameters:
target-group-toUser-
-
addPrivilege
public void addPrivilege(java.lang.String groupName, Privilege p)Add the privilege to the named privilege group- Parameters:
groupName-p-
-
visit
public void visit(java.util.function.Consumer<IDatabaseObject> c)
Description copied from interface:IDatabaseObjectVisit this object, calling the consumer for itself, or its children if any- Specified by:
visitin interfaceIDatabaseObject
-
-