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>

public class EntityRepository.EntityUpdater extends Object
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 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:
  1. First, entity is reverted from current version (original) to previous version without recording any changes. Hence changeDescription is null in this phase.
  2. 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.
  3. Finally, entity is updated from previous version to updated to consolidate the changes in a session. Hence changeDescription is **NOT** null in this phase.
Here are the cases for consolidation:
  1. 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.
  2. 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 Details

  • Constructor Details

  • 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

      protected void updateTags(String fqn, String fieldName, List<TagLabel> origTags, List<TagLabel> updatedTags)
    • updateVersion

      public final boolean updateVersion(Double oldVersion)
    • fieldsChanged

      public final boolean fieldsChanged()
    • recordChange

      public final <K> boolean recordChange(String field, K orig, K updated)
    • recordChange

      public final <K> boolean recordChange(String field, K orig, K updated, boolean jsonValue)
    • 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

      public final <K> boolean recordListChange(String field, List<K> origList, List<K> updatedList, List<K> addedItems, List<K> deletedItems, BiPredicate<K,K> typeMatch)
    • 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)