Package org.openmetadata.service.jdbi3
Class EntityRepository.EntityUpdater
java.lang.Object
org.openmetadata.service.jdbi3.EntityRepository.EntityUpdater
- Direct Known Subclasses:
AppRepository.AppUpdater,BotRepository.BotUpdater,ChartRepository.ChartUpdater,ClassificationRepository.ClassificationUpdater,ContainerRepository.ContainerUpdater,DashboardDataModelRepository.DataModelUpdater,DashboardRepository.DashboardUpdater,DatabaseRepository.DatabaseUpdater,DatabaseSchemaRepository.DatabaseSchemaUpdater,DataProductRepository.DataProductUpdater,DocumentRepository.DocumentUpdater,DomainRepository.DomainUpdater,EventSubscriptionRepository.EventSubscriptionUpdater,GlossaryRepository.GlossaryUpdater,GlossaryTermRepository.GlossaryTermUpdater,IngestionPipelineRepository.IngestionPipelineUpdater,KpiRepository.KpiUpdater,MlModelRepository.MlModelUpdater,PersonaRepository.PersonaUpdater,PipelineRepository.PipelineUpdater,PolicyRepository.PolicyUpdater,QueryRepository.QueryUpdater,RoleRepository.RoleUpdater,SearchIndexRepository.SearchIndexUpdater,ServiceEntityRepository.ServiceUpdater,StoredProcedureRepository.StoredProcedureUpdater,TableRepository.TableUpdater,TagRepository.TagUpdater,TeamRepository.TeamUpdater,TestCaseRepository.TestUpdater,TestConnectionDefinitionRepository.TestConnectionDefinitionUpdater,TestDefinitionRepository.TestDefinitionUpdater,TestSuiteRepository.TestSuiteUpdater,TopicRepository.TopicUpdater,TypeRepository.TypeUpdater,UserRepository.UserUpdater,WorkflowRepository.WorkflowUpdater
- Enclosing class:
- EntityRepository<T extends EntityInterface>
Class that performs PUT and PATCH update operation. It takes an updated entity and original entity.
Performs comparison between then and updates the stored entity and also updates all the relationships. This class
also tracks the changes between original and updated to version the entity and produce change events.
Common entity attributes such as description, displayName, owner, tags are handled by this class. Override
EntityUpdater supports consolidation of changes done by a user within session timeout. It is done as follows:
Common entity attributes such as description, displayName, owner, tags are handled by this class. Override
entitySpecificUpdate() to add additional entity specific fields to be updated. EntityUpdater supports consolidation of changes done by a user within session timeout. It is done as follows:
- First, entity is reverted from current version (original) to previous version without recording any changes. Hence changeDescription is null in this phase.
- Second, entity is updated from current version (original) to updated to carry forward changes from original to updated again without recording changes. Hence changeDescription is null in this phase.
- Finally, entity is updated from previous version to updated to consolidate the changes in a session. Hence changeDescription is **NOT** null in this phase.
- Entity goes from v0 -> v1 -> v1 again where consolidation of changes in original and updated happens resulting in new version of the entity that remains the same. In this case stored previous version remains v0 and new version v1 is stored that has consolidated updates.
- Entity goes from v0 -> v1 -> v0 where v1 -> v0 undoes the changes from v0 -> v1. Example a user added a description to create v1. Then removed the description in the next update. In this case stored previous version goes to v-1 and new version v0 replaces v1 for the entity.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ChangeDescriptionprotected booleanprotected final EntityRepository.Operationprotected Tprotected Tprotected Tprotected final User -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidfinal booleanfinal <K> booleanrecordChange(String field, K orig, K updated) final <K> booleanrecordChange(String field, K orig, K updated, boolean jsonValue) final <K> booleanrecordChange(String field, K orig, K updated, boolean jsonValue, BiPredicate<K, K> typeMatch) final <K> booleanrecordChange(String field, K orig, K updated, boolean jsonValue, BiPredicate<K, K> typeMatch, boolean updateVersion) final <K> booleanrecordListChange(String field, List<K> origList, List<K> updatedList, List<K> addedItems, List<K> deletedItems, BiPredicate<K, K> typeMatch) static voidsetSessionTimeout(long timeout) final voidfinal voidupdate()Compare original and updated entities and perform updates.final booleanfinal voidupdateFromRelationship(String field, String fromEntityType, EntityReference originFromRef, EntityReference updatedFromRef, Relationship relationshipType, String toEntityType, UUID toId) final voidupdateFromRelationships(String field, String fromEntityType, List<EntityReference> originFromRefs, List<EntityReference> updatedFromRefs, Relationship relationshipType, String toEntityType, UUID toId) Remove `fromEntityType:origFromRefs` -- `relationType` ---> `toEntityType:toId` Add `fromEntityType:updatedFromRefs` -- `relationType` ---> `toEntityType:toId` and record it as change for entity field `field`.protected voidfinal voidupdateToRelationship(String field, String fromEntityType, UUID fromId, Relationship relationshipType, String toEntityType, EntityReference origToRef, EntityReference updatedToRef, boolean bidirectional) final voidupdateToRelationships(String field, String fromEntityType, UUID fromId, Relationship relationshipType, String toEntityType, List<EntityReference> origToRefs, List<EntityReference> updatedToRefs, boolean bidirectional) Remove `fromEntityType:fromId` -- `relationType` ---> `toEntityType:origToRefs` Add `fromEntityType:fromId` -- `relationType` ---> `toEntityType:updatedToRefs` and record it as change for entity field `field`.final booleanupdateVersion(Double oldVersion)
-
Field Details
-
previous
-
original
-
updated
-
operation
-
changeDescription
-
majorVersionChange
protected boolean majorVersionChange -
updatingUser
-
-
Constructor Details
-
EntityUpdater
-
-
Method Details
-
update
public final void update()Compare original and updated entities and perform updates. Update the entity version and track changes. -
entitySpecificUpdate
protected void entitySpecificUpdate() -
updateTags
-
updateVersion
-
fieldsChanged
public final boolean fieldsChanged() -
recordChange
-
recordChange
-
recordChange
public final <K> boolean recordChange(String field, K orig, K updated, boolean jsonValue, BiPredicate<K, K> typeMatch) -
recordChange
public final <K> boolean recordChange(String field, K orig, K updated, boolean jsonValue, BiPredicate<K, K> typeMatch, boolean updateVersion) -
recordListChange
-
updateToRelationships
public final void updateToRelationships(String field, String fromEntityType, UUID fromId, Relationship relationshipType, String toEntityType, List<EntityReference> origToRefs, List<EntityReference> updatedToRefs, boolean bidirectional) Remove `fromEntityType:fromId` -- `relationType` ---> `toEntityType:origToRefs` Add `fromEntityType:fromId` -- `relationType` ---> `toEntityType:updatedToRefs` and record it as change for entity field `field`.When `bidirectional` is set to true, relationship from both side are replaced
-
updateToRelationship
public final void updateToRelationship(String field, String fromEntityType, UUID fromId, Relationship relationshipType, String toEntityType, EntityReference origToRef, EntityReference updatedToRef, boolean bidirectional) -
updateFromRelationships
public final void updateFromRelationships(String field, String fromEntityType, List<EntityReference> originFromRefs, List<EntityReference> updatedFromRefs, Relationship relationshipType, String toEntityType, UUID toId) Remove `fromEntityType:origFromRefs` -- `relationType` ---> `toEntityType:toId` Add `fromEntityType:updatedFromRefs` -- `relationType` ---> `toEntityType:toId` and record it as change for entity field `field`. -
updateFromRelationship
public final void updateFromRelationship(String field, String fromEntityType, EntityReference originFromRef, EntityReference updatedFromRef, Relationship relationshipType, String toEntityType, UUID toId) -
storeUpdate
public final void storeUpdate() -
updatedByBot
public final boolean updatedByBot() -
setSessionTimeout
public static void setSessionTimeout(long timeout)
-