private List<Object> mapVertexToArray(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, AtlasAttribute attribute, final boolean isMinExtInfo) throws AtlasBaseException { AtlasArrayType arrayType = (AtlasArrayType) attribute.getAttributeType(); AtlasType arrayElementType = arrayType.getElementType(); List<Object> arrayElements = getArrayElementsProperty(arrayElementType, entityVertex, attribute); if (CollectionUtils.isEmpty(arrayElements)) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Mapping array attribute {} for vertex {}", arrayElementType.getTypeName(), entityVertex); } List arrValues = new ArrayList(arrayElements.size()); String edgeLabel = attribute.getRelationshipEdgeLabel(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection(); for (Object element : arrayElements) { // When internal types are deleted, sometimes the collection type attribute will contain a null value // Graph layer does erroneous mapping of the null element, hence avoiding the processing of the null element if (element == null) { LOG.debug("Skipping null arrayElement"); continue; } Object arrValue = mapVertexToCollectionEntry(entityVertex, arrayElementType, element, edgeLabel, entityExtInfo, isOwnedAttribute, edgeDirection, isMinExtInfo); if (arrValue != null) { arrValues.add(arrValue); } } return arrValues; }
private List<Object> mapVertexToArray(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, AtlasAttribute attribute, final boolean isMinExtInfo) throws AtlasBaseException { AtlasArrayType arrayType = (AtlasArrayType) attribute.getAttributeType(); AtlasType arrayElementType = arrayType.getElementType(); List<Object> arrayElements = getArrayElementsProperty(arrayElementType, entityVertex, attribute); if (CollectionUtils.isEmpty(arrayElements)) { return null; } if (LOG.isDebugEnabled()) { LOG.debug("Mapping array attribute {} for vertex {}", arrayElementType.getTypeName(), entityVertex); } List arrValues = new ArrayList(arrayElements.size()); String edgeLabel = attribute.getRelationshipEdgeLabel(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection(); for (Object element : arrayElements) { // When internal types are deleted, sometimes the collection type attribute will contain a null value // Graph layer does erroneous mapping of the null element, hence avoiding the processing of the null element if (element == null) { LOG.debug("Skipping null arrayElement"); continue; } Object arrValue = mapVertexToCollectionEntry(entityVertex, arrayElementType, element, edgeLabel, entityExtInfo, isOwnedAttribute, edgeDirection, isMinExtInfo); if (arrValue != null) { arrValues.add(arrValue); } } return arrValues; }
private List<AtlasEdge> removeUnusedArrayEntries(AtlasAttribute attribute, List<AtlasEdge> currentEntries, List<AtlasEdge> newEntries, AtlasVertex entityVertex) throws AtlasBaseException { if (CollectionUtils.isNotEmpty(currentEntries)) { AtlasType entryType = ((AtlasArrayType) attribute.getAttributeType()).getElementType(); if (isReference(entryType)) { Collection<AtlasEdge> edgesToRemove = CollectionUtils.subtract(currentEntries, newEntries); if (CollectionUtils.isNotEmpty(edgesToRemove)) { List<AtlasEdge> additionalElements = new ArrayList<>(); for (AtlasEdge edge : edgesToRemove) { boolean deleted = deleteHandler.deleteEdgeReference(edge, entryType.getTypeCategory(), attribute.isOwnedRef(), true, attribute.getRelationshipEdgeDirection(), entityVertex); if (!deleted) { additionalElements.add(edge); } } return additionalElements; } } } return Collections.emptyList(); } private void setArrayElementsProperty(AtlasType elementType, AtlasVertex vertex, String vertexPropertyName, List<Object> values) {
AtlasRelationshipEdgeDirection edgeDirection = ctx.getAttribute().getRelationshipEdgeDirection(); String edgeLabel = ctx.getAttribute().getRelationshipEdgeLabel(); true, ctx.getAttribute().getRelationshipEdgeDirection(), ctx.getReferringVertex());
AtlasRelationshipEdgeDirection edgeDirection = ctx.getAttribute().getRelationshipEdgeDirection(); String edgeLabel = ctx.getAttribute().getRelationshipEdgeLabel(); true, ctx.getAttribute().getRelationshipEdgeDirection(), ctx.getReferringVertex());
AtlasType type = typeRegistry.getType(AtlasGraphUtilsV2.getTypeName(entityVertex)); AtlasRelationshipEdgeDirection edgeDirection = ctx.getAttribute().getRelationshipEdgeDirection();
AtlasType type = typeRegistry.getType(AtlasGraphUtilsV2.getTypeName(entityVertex)); AtlasRelationshipEdgeDirection edgeDirection = ctx.getAttribute().getRelationshipEdgeDirection(); String edgeLabel = ctx.getAttribute().getRelationshipEdgeLabel();
String edgeLabel = EDGE_LABEL_PREFIX + attribute.getQualifiedName(); boolean isOwnedAttribute = attribute.isOwnedRef(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection();
String edgeLabel = EDGE_LABEL_PREFIX + attribute.getQualifiedName(); boolean isOwnedAttribute = attribute.isOwnedRef(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection();
private Map<String, Object> mapVertexToMap(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, AtlasAttribute attribute, final boolean isMinExtInfo) throws AtlasBaseException { Map<String, Object> ret = null; AtlasMapType mapType = (AtlasMapType) attribute.getAttributeType(); AtlasType mapValueType = mapType.getValueType(); if (LOG.isDebugEnabled()) { LOG.debug("Mapping map attribute {} for vertex {}", mapType.getTypeName(), entityVertex); } if (isReference(mapValueType)) { Map<String, Object> currentMap = getReferenceMap(entityVertex, attribute); if (MapUtils.isNotEmpty(currentMap)) { ret = new HashMap<>(); for (Map.Entry<String, Object> entry : currentMap.entrySet()) { String mapKey = entry.getKey(); Object keyValue = entry.getValue(); Object mapValue = mapVertexToCollectionEntry(entityVertex, mapValueType, keyValue, attribute.getRelationshipEdgeLabel(), entityExtInfo, isOwnedAttribute, attribute.getRelationshipEdgeDirection(), isMinExtInfo); if (mapValue != null) { ret.put(mapKey, mapValue); } } } } else { ret = getPrimitiveMap(entityVertex, attribute.getVertexPropertyName()); } if (MapUtils.isEmpty(ret)) { ret = null; } return ret; }
private Map<String, Object> mapVertexToMap(AtlasVertex entityVertex, AtlasEntityExtInfo entityExtInfo, boolean isOwnedAttribute, AtlasAttribute attribute, final boolean isMinExtInfo) throws AtlasBaseException { Map<String, Object> ret = null; AtlasMapType mapType = (AtlasMapType) attribute.getAttributeType(); AtlasType mapValueType = mapType.getValueType(); if (LOG.isDebugEnabled()) { LOG.debug("Mapping map attribute {} for vertex {}", mapType.getTypeName(), entityVertex); } if (isReference(mapValueType)) { Map<String, Object> currentMap = getReferenceMap(entityVertex, attribute); if (MapUtils.isNotEmpty(currentMap)) { ret = new HashMap<>(); for (Map.Entry<String, Object> entry : currentMap.entrySet()) { String mapKey = entry.getKey(); Object keyValue = entry.getValue(); Object mapValue = mapVertexToCollectionEntry(entityVertex, mapValueType, keyValue, attribute.getRelationshipEdgeLabel(), entityExtInfo, isOwnedAttribute, attribute.getRelationshipEdgeDirection(), isMinExtInfo); if (mapValue != null) { ret.put(mapKey, mapValue); } } } } else { ret = getPrimitiveMap(entityVertex, attribute.getVertexPropertyName()); } if (MapUtils.isEmpty(ret)) { ret = null; } return ret; }
private List<AtlasEdge> removeUnusedArrayEntries(AtlasAttribute attribute, List<AtlasEdge> currentEntries, List<AtlasEdge> newEntries, AtlasVertex entityVertex) throws AtlasBaseException { if (CollectionUtils.isNotEmpty(currentEntries)) { AtlasType entryType = ((AtlasArrayType) attribute.getAttributeType()).getElementType(); if (isReference(entryType)) { Collection<AtlasEdge> edgesToRemove = CollectionUtils.subtract(currentEntries, newEntries); if (CollectionUtils.isNotEmpty(edgesToRemove)) { List<AtlasEdge> additionalElements = new ArrayList<>(); for (AtlasEdge edge : edgesToRemove) { boolean deleted = deleteDelegate.getHandler().deleteEdgeReference(edge, entryType.getTypeCategory(), attribute.isOwnedRef(), true, attribute.getRelationshipEdgeDirection(), entityVertex); if (!deleted) { additionalElements.add(edge); } } return additionalElements; } } } return Collections.emptyList(); } private void setArrayElementsProperty(AtlasType elementType, boolean isSoftReference, AtlasVertex vertex, String vertexPropertyName, List<Object> values) {
private List<AtlasRelatedObjectId> mapRelationshipArrayAttribute(AtlasVertex entityVertex, AtlasAttribute attribute) throws AtlasBaseException { List<AtlasRelatedObjectId> ret = new ArrayList<>(); Iterator<AtlasEdge> edges = null; if (attribute.getRelationshipEdgeDirection() == IN) { edges = getIncomingEdgesByLabel(entityVertex, attribute.getRelationshipEdgeLabel()); } else if (attribute.getRelationshipEdgeDirection() == OUT) { edges = getOutGoingEdgesByLabel(entityVertex, attribute.getRelationshipEdgeLabel()); } else if (attribute.getRelationshipEdgeDirection() == BOTH) { edges = getAdjacentEdgesByLabel(entityVertex, AtlasEdgeDirection.BOTH, attribute.getRelationshipEdgeLabel()); } if (edges != null) { while (edges.hasNext()) { AtlasEdge relationshipEdge = edges.next(); AtlasRelatedObjectId relatedObjectId = mapVertexToRelatedObjectId(entityVertex, relationshipEdge); ret.add(relatedObjectId); } } return ret; }
private List<AtlasRelatedObjectId> mapRelationshipArrayAttribute(AtlasVertex entityVertex, AtlasAttribute attribute) throws AtlasBaseException { List<AtlasRelatedObjectId> ret = new ArrayList<>(); Iterator<AtlasEdge> edges = null; if (attribute.getRelationshipEdgeDirection() == IN) { edges = getIncomingEdgesByLabel(entityVertex, attribute.getRelationshipEdgeLabel()); } else if (attribute.getRelationshipEdgeDirection() == OUT) { edges = getOutGoingEdgesByLabel(entityVertex, attribute.getRelationshipEdgeLabel()); } else if (attribute.getRelationshipEdgeDirection() == BOTH) { edges = getAdjacentEdgesByLabel(entityVertex, AtlasEdgeDirection.BOTH, attribute.getRelationshipEdgeLabel()); } if (edges != null) { while (edges.hasNext()) { AtlasEdge relationshipEdge = edges.next(); AtlasRelatedObjectId relatedObjectId = mapVertexToRelatedObjectId(entityVertex, relationshipEdge); ret.add(relatedObjectId); } } return ret; }
private List<AtlasVertex> getAssignedEntities(AtlasVertex glossaryTerm) { List<AtlasVertex> ret = new ArrayList<>(); AtlasEntityType termType = getTermEntityType(); AtlasAttribute attr = termType.getRelationshipAttribute(TermSearchProcessor.ATLAS_GLOSSARY_TERM_ATTR_ASSIGNED_ENTITIES); Iterator<AtlasEdge> edges = GraphHelper.getEdgesForLabel(glossaryTerm, attr.getRelationshipEdgeLabel(), attr.getRelationshipEdgeDirection()); boolean excludeDeletedEntities = searchParameters.getExcludeDeletedEntities(); if (edges != null) { while (edges.hasNext()) { AtlasEdge edge = edges.next(); AtlasVertex inVertex = edge.getInVertex(); if (excludeDeletedEntities && AtlasGraphUtilsV2.getState(inVertex) == AtlasEntity.Status.DELETED) { continue; } ret.add(inVertex); } } return ret; }
private AtlasObjectId mapRelatedVertexToObjectId(AtlasVertex entityVertex, AtlasAttribute attribute) throws AtlasBaseException { AtlasEdge edge = graphHelper.getEdgeForLabel(entityVertex, attribute.getRelationshipEdgeLabel(), attribute.getRelationshipEdgeDirection()); return mapVertexToRelatedObjectId(entityVertex, edge); }
private AtlasObjectId mapRelatedVertexToObjectId(AtlasVertex entityVertex, AtlasAttribute attribute) throws AtlasBaseException { AtlasEdge edge = graphHelper.getEdgeForLabel(entityVertex, attribute.getRelationshipEdgeLabel(), attribute.getRelationshipEdgeDirection()); return mapVertexToRelatedObjectId(entityVertex, edge); }
public static List<AtlasEdge> getCollectionElementsUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute) { List<AtlasEdge> ret; String edgeLabel = attribute.getRelationshipEdgeLabel(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection(); Iterator<AtlasEdge> edgesForLabel = getEdgesForLabel(vertex, edgeLabel, edgeDirection); ret = IteratorUtils.toList(edgesForLabel); sortCollectionElements(attribute, ret); return ret; }
public static List<AtlasEdge> getMapValuesUsingRelationship(AtlasVertex vertex, AtlasAttribute attribute) { String edgeLabel = attribute.getRelationshipEdgeLabel(); AtlasRelationshipEdgeDirection edgeDirection = attribute.getRelationshipEdgeDirection(); Iterator<AtlasEdge> edgesForLabel = getEdgesForLabel(vertex, edgeLabel, edgeDirection); return (List<AtlasEdge>) IteratorUtils.toList(edgesForLabel); }