diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java index 993f7534d5..5003e8ba9f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java @@ -1014,7 +1014,7 @@ private Map preloadProperties(AtlasVertex entityVertex, AtlasEnt Iterator> traversal = ((AtlasJanusVertex)entityVertex).getWrappedElement().properties(); // retrieve all the valid relationships for this entityType - Map relationshipsLookup = fetchEdgeNames(entityType); + Map> relationshipsLookup = fetchEdgeNames(entityType); // Fetch edges in both directions retrieveEdgeLabels(entityVertex, AtlasEdgeDirection.BOTH, attributes, relationshipsLookup, propertiesMap); @@ -1052,18 +1052,19 @@ private Map preloadProperties(AtlasVertex entityVertex, AtlasEnt return propertiesMap; } - private Map fetchEdgeNames(AtlasEntityType entityType){ + private Map> fetchEdgeNames(AtlasEntityType entityType){ Map> relationships = entityType.getRelationshipAttributes(); - Map edgeNames = new HashMap<>(); + Map> edgeNames = new HashMap<>(); relationships.forEach((k,v) -> { v.forEach((k1,v1) -> { - edgeNames.put(k1, k); + edgeNames.putIfAbsent(k1, new HashSet<>()); + edgeNames.get(k1).add(k); }); }); return edgeNames; } - private void retrieveEdgeLabels(AtlasVertex entityVertex, AtlasEdgeDirection edgeDirection, Set attributes, Map relationshipsLookup,Map propertiesMap) throws AtlasBaseException { + private void retrieveEdgeLabels(AtlasVertex entityVertex, AtlasEdgeDirection edgeDirection, Set attributes, Map> relationshipsLookup,Map propertiesMap) throws AtlasBaseException { Iterator edges = GraphHelper.getOnlyActiveEdges(entityVertex, edgeDirection); List edgeLabelsDebug = new ArrayList<>(); @@ -1078,13 +1079,15 @@ private void retrieveEdgeLabels(AtlasVertex entityVertex, AtlasEdgeDirection edg Set edgeLabels = new HashSet<>(); edgeLabelsDebug.stream().filter(Objects::nonNull).forEach(edgeLabel -> attributes.forEach(attribute->{ - if (edgeLabel.contains(attribute)){ + + if (edgeLabel.contains(attribute)){ edgeLabels.add(attribute); return; } String edgeTypeName = edgesTypeName.get(edgeLabel); - if (MapUtils.isNotEmpty(relationshipsLookup) && relationshipsLookup.containsKey(edgeTypeName) && attribute.equals(relationshipsLookup.get(edgeTypeName))) { + + if (MapUtils.isNotEmpty(relationshipsLookup) && relationshipsLookup.containsKey(edgeTypeName) && relationshipsLookup.get(edgeTypeName).contains(attribute)) { edgeLabels.add(attribute); } }));