Search in sources :

Example 1 with AtlasRelatedObjectId

use of org.apache.atlas.model.instance.AtlasRelatedObjectId in project atlas by apache.

the class EntityGraphRetriever method mapRelationshipArrayAttribute.

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;
}
Also used : AtlasRelatedObjectId(org.apache.atlas.model.instance.AtlasRelatedObjectId) ArrayList(java.util.ArrayList) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Example 2 with AtlasRelatedObjectId

use of org.apache.atlas.model.instance.AtlasRelatedObjectId in project atlas by apache.

the class AtlasRelationshipStoreV1Test method toAtlasObjectIds.

protected static List<AtlasObjectId> toAtlasObjectIds(Object object) {
    List<AtlasObjectId> ret = new ArrayList<>();
    if (object instanceof List) {
        List<?> objectIds = (List) object;
        if (CollectionUtils.isNotEmpty(objectIds)) {
            for (Object obj : objectIds) {
                if (obj instanceof AtlasRelatedObjectId) {
                    AtlasRelatedObjectId relatedObjectId = (AtlasRelatedObjectId) obj;
                    ret.add(new AtlasObjectId(relatedObjectId.getGuid(), relatedObjectId.getTypeName(), relatedObjectId.getUniqueAttributes()));
                }
            }
        }
    }
    return ret;
}
Also used : AtlasRelatedObjectId(org.apache.atlas.model.instance.AtlasRelatedObjectId) ArrayList(java.util.ArrayList) AtlasTypeUtil.getAtlasObjectId(org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List)

Example 3 with AtlasRelatedObjectId

use of org.apache.atlas.model.instance.AtlasRelatedObjectId in project atlas by apache.

the class EntityGraphRetriever method mapVertexToRelatedObjectId.

private AtlasRelatedObjectId mapVertexToRelatedObjectId(AtlasVertex entityVertex, AtlasEdge edge) throws AtlasBaseException {
    AtlasRelatedObjectId ret = null;
    if (GraphHelper.elementExists(edge)) {
        AtlasVertex referenceVertex = edge.getInVertex();
        if (StringUtils.equals(getIdFromVertex(referenceVertex), getIdFromVertex(entityVertex))) {
            referenceVertex = edge.getOutVertex();
        }
        if (referenceVertex != null) {
            String entityTypeName = getTypeName(referenceVertex);
            String entityGuid = getGuid(referenceVertex);
            AtlasRelationship relationship = mapEdgeToAtlasRelationship(edge);
            ret = new AtlasRelatedObjectId(entityGuid, entityTypeName, relationship.getGuid(), new AtlasStruct(relationship.getTypeName(), relationship.getAttributes()));
            Object displayText = getDisplayText(referenceVertex, entityTypeName);
            if (displayText != null) {
                ret.setDisplayText(displayText.toString());
            }
        }
    }
    return ret;
}
Also used : AtlasStruct(org.apache.atlas.model.instance.AtlasStruct) AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasRelatedObjectId(org.apache.atlas.model.instance.AtlasRelatedObjectId) AtlasRelationship(org.apache.atlas.model.instance.AtlasRelationship)

Aggregations

AtlasRelatedObjectId (org.apache.atlas.model.instance.AtlasRelatedObjectId)3 ArrayList (java.util.ArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)1 List (java.util.List)1 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)1 AtlasRelationship (org.apache.atlas.model.instance.AtlasRelationship)1 AtlasStruct (org.apache.atlas.model.instance.AtlasStruct)1 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)1 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)1 AtlasTypeUtil.getAtlasObjectId (org.apache.atlas.type.AtlasTypeUtil.getAtlasObjectId)1