From fe1722edfa959d745bf1f2eca86786fd5157fec0 Mon Sep 17 00:00:00 2001 From: Suman Das <59254445+sumandas0@users.noreply.github.com> Date: Fri, 24 Jan 2025 12:53:37 +0530 Subject: [PATCH] fix: just fetch ACTIVE edges from the entity during deletion --- .../atlas/repository/graph/GraphHelper.java | 17 +++++++++++++++++ .../store/graph/v1/DeleteHandlerV1.java | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java index 335e2accc8..fce52721ce 100755 --- a/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java +++ b/repository/src/main/java/org/apache/atlas/repository/graph/GraphHelper.java @@ -1673,12 +1673,29 @@ public static List getCollectionElementsUsingRelationship(AtlasVertex return getCollectionElementsUsingRelationship(vertex, attribute, edgeLabel); } + public static List getActiveCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute) throws AtlasBaseException { + String edgeLabel = attribute.getRelationshipEdgeLabel(); + return getActiveCollectionElementsUsingRelationship(vertex, attribute, edgeLabel); + } + public static List getCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute, boolean isStructType) { String edgeLabel = isStructType ? AtlasGraphUtilsV2.getEdgeLabel(attribute.getName()) : attribute.getRelationshipEdgeLabel(); return getCollectionElementsUsingRelationship(vertex, attribute, edgeLabel); } + public static List getActiveCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute, String edgeLabel) throws AtlasBaseException { + List ret; + AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection(); + Iterator edgesForLabel = getActiveEdges(vertex, edgeLabel, AtlasEdgeDirection.valueOf(edgeDirection.name())); + + ret = IteratorUtils.toList(edgesForLabel); + + sortCollectionElements(attribute, ret); + + return ret; + } + public static List getCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute, String edgeLabel) { List ret; diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java index c32aa1f190..34c4f2900d 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/DeleteHandlerV1.java @@ -828,7 +828,7 @@ protected void deleteTypeVertex(AtlasVertex instanceVertex, boolean force) throw AtlasType elemType = arrType.getElementType(); if (isReference(elemType.getTypeCategory())) { - List edges = getCollectionElementsUsingRelationship(instanceVertex, attributeInfo); + List edges = getActiveCollectionElementsUsingRelationship(instanceVertex, attributeInfo); if (CollectionUtils.isNotEmpty(edges)) { for (AtlasEdge edge : edges) {