Search in sources :

Example 1 with AtlasVertexQuery

use of org.apache.atlas.repository.graphdb.AtlasVertexQuery in project atlas by apache.

the class GraphHelper method getClassificationEdges.

public static List<AtlasEdge> getClassificationEdges(AtlasVertex entityVertex, Boolean propagated) {
    List<AtlasEdge> ret = new ArrayList<>();
    AtlasVertexQuery query = entityVertex.query().direction(AtlasEdgeDirection.OUT).label(CLASSIFICATION_LABEL);
    if (propagated != null) {
        query = query.has(CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, propagated);
    }
    Iterable edges = query.edges();
    if (edges != null) {
        Iterator<AtlasEdge> iterator = edges.iterator();
        while (iterator.hasNext()) {
            AtlasEdge edge = iterator.next();
            if (edge != null) {
                ret.add(edge);
            }
        }
    }
    return ret;
}
Also used : AtlasVertexQuery(org.apache.atlas.repository.graphdb.AtlasVertexQuery) ArrayList(java.util.ArrayList) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Example 2 with AtlasVertexQuery

use of org.apache.atlas.repository.graphdb.AtlasVertexQuery in project atlas by apache.

the class GraphHelper method getTraitNames.

public static List<String> getTraitNames(AtlasVertex entityVertex, Boolean propagated) {
    List<String> ret = new ArrayList<>();
    AtlasVertexQuery query = entityVertex.query().direction(AtlasEdgeDirection.OUT).label(CLASSIFICATION_LABEL);
    if (propagated != null) {
        query = query.has(CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, propagated);
    }
    Iterable edges = query.edges();
    if (edges != null) {
        Iterator<AtlasEdge> iterator = edges.iterator();
        while (iterator.hasNext()) {
            AtlasEdge edge = iterator.next();
            ret.add(AtlasGraphUtilsV1.getProperty(edge, CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, String.class));
        }
    }
    return ret;
}
Also used : AtlasVertexQuery(org.apache.atlas.repository.graphdb.AtlasVertexQuery) ArrayList(java.util.ArrayList) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Aggregations

ArrayList (java.util.ArrayList)2 AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)2 AtlasVertexQuery (org.apache.atlas.repository.graphdb.AtlasVertexQuery)2