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 Object implements IDatabaseObject
BaseObject
-
-
Field Summary
Fields Modifier and Type Field Description protected List<Migration>
migrations
protected int
version
-
Constructor Summary
Constructors Constructor Description BaseObject(String schemaName, String objectName, DatabaseObjectType objectType, int version)
Public constructorBaseObject(String schemaName, String objectName, DatabaseObjectType objectType, int version, List<Migration> migrations)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDependencies(Collection<IDatabaseObject> obj)
Add the given collection of dependencies to our setvoid
addDependency(IDatabaseObject obj)
Add the given obj as a dependency of this (obj must be created before this, or dropped after this)void
addPrivilege(String groupName, Privilege p)
Add the privilege to the named privilege groupvoid
addTag(String tagName, String tagValue)
Add the tag name/value to the tag map for this objectvoid
addTags(Map<String,String> tags)
Add the given tags to our tag mapvoid
applyTx(IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)
Apply the DDL, but within its own transactionvoid
applyVersion(IDatabaseAdapter target, IVersionHistoryService vhs)
Apply the change, but only if it has a newer version than we already have recorded in the databaseITaskGroup
collect(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)boolean
equals(Object other)
void
fetchDependenciesTo(Collection<IDatabaseObject> out)
Fetch dependencies from this into the given out listString
getName()
Return the unique name for this objectString
getObjectName()
DatabaseObjectType
getObjectType()
The type enum of this objectString
getQualifiedName()
String
getSchemaName()
Map<String,String>
getTags()
Get the map of tags associated with this object.String
getTypeNameVersion()
Get the qualified name for this object: objectType:objectName:objectVersionint
getVersion()
Getter for the schema version number this object applies tovoid
grant(IDatabaseAdapter target, String groupName, String toUser)
Grant the given privileges to the userprotected void
grantGroupPrivileges(IDatabaseAdapter target, Set<Privilege> group, String toUser)
Internal method which can be override by different object types which may need to call a different grant method on the adapterint
hashCode()
protected void
safeSleep()
Sleep a random amount of time.String
toString()
void
visit(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
-
-
-
-
Constructor Detail
-
BaseObject
public BaseObject(String schemaName, String objectName, DatabaseObjectType objectType, int version)
Public constructor- Parameters:
schemaName
-objectName
-objectType
-version
-
-
BaseObject
public BaseObject(String schemaName, String objectName, DatabaseObjectType objectType, int version, List<Migration> migrations)
Public constructor- Parameters:
schemaName
-objectName
-objectType
-version
-
-
-
Method Detail
-
getVersion
public int getVersion()
Description copied from interface:IDatabaseObject
Getter for the schema version number this object applies to- Specified by:
getVersion
in interfaceIDatabaseObject
- Returns:
-
getObjectType
public DatabaseObjectType getObjectType()
Description copied from interface:IDatabaseObject
The type enum of this object- Specified by:
getObjectType
in interfaceIDatabaseObject
- Returns:
-
getSchemaName
public String getSchemaName()
-
getObjectName
public String getObjectName()
-
getQualifiedName
public String getQualifiedName()
-
getTypeNameVersion
public String getTypeNameVersion()
Description copied from interface:IDatabaseObject
Get the qualified name for this object: objectType:objectName:objectVersion- Specified by:
getTypeNameVersion
in interfaceIDatabaseObject
- Returns:
-
addTags
public void addTags(Map<String,String> tags)
Add the given tags to our tag map- Parameters:
tags
-
-
addTag
public void addTag(String tagName, String tagValue)
Description copied from interface:IDatabaseObject
Add the tag name/value to the tag map for this object- Specified by:
addTag
in interfaceIDatabaseObject
-
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(Collection<IDatabaseObject> obj)
Add the given collection of dependencies to our set- Specified by:
addDependencies
in interfaceIDatabaseObject
- Parameters:
obj
-
-
fetchDependenciesTo
public void fetchDependenciesTo(Collection<IDatabaseObject> out)
Description copied from interface:IDatabaseObject
Fetch dependencies from this into the given out list- Specified by:
fetchDependenciesTo
in interfaceIDatabaseObject
-
getName
public String getName()
Return the unique name for this object- Specified by:
getName
in interfaceIDatabaseObject
- Returns:
-
collect
public ITaskGroup collect(ITaskCollector tc, IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)
Description copied from interface:IDatabaseObject
Collect the tasks into a dependency tree so that they can be executed concurrently (but in the right order)- Specified by:
collect
in interfaceIDatabaseObject
-
applyTx
public void applyTx(IDatabaseAdapter target, ITransactionProvider tp, IVersionHistoryService vhs)
Description copied from interface:IDatabaseObject
Apply the DDL, but within its own transaction- Specified by:
applyTx
in 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:
applyVersion
in interfaceIDatabaseObject
- Parameters:
target
-vhs
- the service used to manage the version history table
-
safeSleep
protected void safeSleep()
Sleep a random amount of time.
-
getTags
public Map<String,String> getTags()
Description copied from interface:IDatabaseObject
Get the map of tags associated with this object. Used to find things in the PhysicalDataModel- Specified by:
getTags
in interfaceIDatabaseObject
- Returns:
-
grant
public void grant(IDatabaseAdapter target, String groupName, String toUser)
Description copied from interface:IDatabaseObject
Grant the given privileges to the user- Specified by:
grant
in interfaceIDatabaseObject
-
grantGroupPrivileges
protected void grantGroupPrivileges(IDatabaseAdapter target, Set<Privilege> group, 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(String groupName, Privilege p)
Add the privilege to the named privilege group- Parameters:
groupName
-p
-
-
visit
public void visit(Consumer<IDatabaseObject> c)
Description copied from interface:IDatabaseObject
Visit this object, calling the consumer for itself, or its children if any- Specified by:
visit
in interfaceIDatabaseObject
-
-