From 1fd0358a4c72552581d3969a25f51cee993437f6 Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Thu, 31 Aug 2023 12:24:53 +0530 Subject: [PATCH 1/3] fix: add way to add propagation if set to false again --- .../store/graph/v2/EntityGraphMapper.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 560835cb16..3486ddcd42 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -3185,13 +3185,18 @@ public void updateClassifications(EntityMutationContext context, String guid, Li AtlasGraphUtilsV2.setEncodedProperty(classificationVertex, CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY, updatedRemovePropagations); // If value set true from false and source entity is deleted, remove propagated classification from propagated entities - if (updatedRemovePropagations && !currentRemovePropagations) { - boolean isEntityDeleted = entityVertex.getProperty(STATE_PROPERTY_KEY, String.class).equals(DELETED.toString()); - if(isEntityDeleted && taskManagement != null && DEFERRED_ACTION_ENABLED) { - createAndQueueTask(CLASSIFICATION_PROPAGATION_DELETE, entityVertex, classificationVertex.getIdForDisplay()); - } + boolean isEntityDeleted = entityVertex.getProperty(STATE_PROPERTY_KEY, String.class).equals(DELETED.toString()); + boolean isUpdatedRemovePropagationsDifferentFromCurrent = updatedRemovePropagations != currentRemovePropagations; + + if (isEntityDeleted && taskManagement != null && DEFERRED_ACTION_ENABLED && isUpdatedRemovePropagationsDifferentFromCurrent) { + createAndQueueTask( + updatedRemovePropagations ? CLASSIFICATION_PROPAGATION_DELETE : CLASSIFICATION_PROPAGATION_ADD, + entityVertex, + classificationVertex.getIdForDisplay() + ); } + isClassificationUpdated = true; } From 2f5c449c6127404b2eea56554c3004ce943da28d Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Thu, 31 Aug 2023 16:26:14 +0530 Subject: [PATCH 2/3] fix: update and refactore task creation logic --- .../store/graph/v2/EntityGraphMapper.java | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 3486ddcd42..0a69434094 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -3177,27 +3177,18 @@ public void updateClassifications(EntityMutationContext context, String guid, Li isClassificationUpdated = true; } + boolean removePropagation = false; // check for removePropagationsOnEntityDelete update Boolean currentRemovePropagations = currentClassification.getRemovePropagationsOnEntityDelete(); Boolean updatedRemovePropagations = classification.getRemovePropagationsOnEntityDelete(); - - if (updatedRemovePropagations != null && (updatedRemovePropagations != currentRemovePropagations)) { + if (updatedRemovePropagations != null && !updatedRemovePropagations.equals(currentRemovePropagations)) { AtlasGraphUtilsV2.setEncodedProperty(classificationVertex, CLASSIFICATION_VERTEX_REMOVE_PROPAGATIONS_KEY, updatedRemovePropagations); + isClassificationUpdated = true; - // If value set true from false and source entity is deleted, remove propagated classification from propagated entities - boolean isEntityDeleted = entityVertex.getProperty(STATE_PROPERTY_KEY, String.class).equals(DELETED.toString()); - boolean isUpdatedRemovePropagationsDifferentFromCurrent = updatedRemovePropagations != currentRemovePropagations; - - if (isEntityDeleted && taskManagement != null && DEFERRED_ACTION_ENABLED && isUpdatedRemovePropagationsDifferentFromCurrent) { - createAndQueueTask( - updatedRemovePropagations ? CLASSIFICATION_PROPAGATION_DELETE : CLASSIFICATION_PROPAGATION_ADD, - entityVertex, - classificationVertex.getIdForDisplay() - ); + boolean isEntityDeleted = DELETED.toString().equals(entityVertex.getProperty(STATE_PROPERTY_KEY, String.class)); + if (isEntityDeleted && !updatedRemovePropagations) { + removePropagation = true; } - - - isClassificationUpdated = true; } if (isClassificationUpdated) { @@ -3213,10 +3204,6 @@ public void updateClassifications(EntityMutationContext context, String guid, Li mapClassification(EntityOperation.UPDATE, context, classification, entityType, entityVertex, classificationVertex); updateModificationMetadata(entityVertex); - // handle update of 'propagate' flag - Boolean currentTagPropagation = currentClassification.isPropagate(); - Boolean updatedTagPropagation = classification.isPropagate(); - /* ----------------------------- | Current Tag | Updated Tag | | Propagation | Propagation | @@ -3230,15 +3217,22 @@ public void updateClassifications(EntityMutationContext context, String guid, Li | true | false | => Remove Tag Propagation (send REMOVE classification notifications) |-------------|-------------| */ + Boolean currentTagPropagation = currentClassification.isPropagate(); + Boolean updatedTagPropagation = classification.isPropagate(); Boolean currentRestrictPropagationThroughLineage = currentClassification.getRestrictPropagationThroughLineage(); Boolean updatedRestrictPropagationThroughLineage = classification.getRestrictPropagationThroughLineage(); - if (taskManagement != null && DEFERRED_ACTION_ENABLED) { - String propagationType = updatedTagPropagation ? CLASSIFICATION_PROPAGATION_ADD : CLASSIFICATION_PROPAGATION_DELETE; - if (!Objects.equals(currentTagPropagation, updatedTagPropagation) || !Objects.equals(currentRestrictPropagationThroughLineage, updatedRestrictPropagationThroughLineage)) { - createAndQueueTask(propagationType, entityVertex, classificationVertex.getIdForDisplay(), currentRestrictPropagationThroughLineage); + if ((!Objects.equals(updatedRemovePropagations, currentRemovePropagations) || + !Objects.equals(currentTagPropagation, updatedTagPropagation) || + !Objects.equals(currentRestrictPropagationThroughLineage, updatedRestrictPropagationThroughLineage)) && + taskManagement != null && DEFERRED_ACTION_ENABLED) { + + String propagationType = CLASSIFICATION_PROPAGATION_ADD; + if (removePropagation || !updatedTagPropagation) + { + propagationType = CLASSIFICATION_PROPAGATION_DELETE; } - updatedTagPropagation = null; + createAndQueueTask(propagationType, entityVertex, classificationVertex.getIdForDisplay(), currentRestrictPropagationThroughLineage); } // compute propagatedEntityVertices once and use it for subsequent iterations and notifications From 880d0b4011cc04eb1fc2201c797cd30fda5df4a2 Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Thu, 31 Aug 2023 17:04:27 +0530 Subject: [PATCH 3/3] fix: fixing the not case --- .../atlas/repository/store/graph/v2/EntityGraphMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 0a69434094..b446f4c299 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -3186,7 +3186,7 @@ public void updateClassifications(EntityMutationContext context, String guid, Li isClassificationUpdated = true; boolean isEntityDeleted = DELETED.toString().equals(entityVertex.getProperty(STATE_PROPERTY_KEY, String.class)); - if (isEntityDeleted && !updatedRemovePropagations) { + if (isEntityDeleted && updatedRemovePropagations) { removePropagation = true; } }