Search in sources :

Example 1 with TermVertexWrapper

use of org.apache.atlas.catalog.TermVertexWrapper in project incubator-atlas by apache.

the class AtlasEntityTagQuery method getQueryPipe.

@Override
protected Pipe getQueryPipe() {
    GremlinPipeline p;
    if (guid.equals("*")) {
        p = new GremlinPipeline().has(Constants.ENTITY_TEXT_PROPERTY_KEY).hasNot(Constants.ENTITY_TYPE_PROPERTY_KEY, "Taxonomy").outE();
    } else {
        p = new GremlinPipeline().has(Constants.GUID_PROPERTY_KEY, guid).outE();
    }
    // todo: this is basically the same pipeline used in TagRelation.asPipe()
    p.add(new FilterFunctionPipe<>(new PipeFunction<Edge, Boolean>() {

        @Override
        public Boolean compute(Edge edge) {
            String type = edge.getVertex(Direction.OUT).getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
            VertexWrapper v = new TermVertexWrapper(edge.getVertex(Direction.IN));
            return edge.getLabel().startsWith(type) && v.getPropertyKeys().contains("available_as_tag");
        }
    }));
    return p.inV();
}
Also used : GremlinPipeline(com.tinkerpop.gremlin.java.GremlinPipeline) TermVertexWrapper(org.apache.atlas.catalog.TermVertexWrapper) TermVertexWrapper(org.apache.atlas.catalog.TermVertexWrapper) VertexWrapper(org.apache.atlas.catalog.VertexWrapper) PipeFunction(com.tinkerpop.pipes.PipeFunction) Edge(com.tinkerpop.blueprints.Edge)

Example 2 with TermVertexWrapper

use of org.apache.atlas.catalog.TermVertexWrapper in project incubator-atlas by apache.

the class TraitRelation method traverse.

@Override
public Collection<RelationSet> traverse(VertexWrapper vWrapper) {
    Vertex v = vWrapper.getVertex();
    Collection<VertexWrapper> vertices = new ArrayList<>();
    for (Edge e : v.getEdges(Direction.OUT)) {
        if (e.getLabel().startsWith(v.<String>getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY))) {
            VertexWrapper trait = new TermVertexWrapper(e.getVertex(Direction.IN));
            if (!trait.getPropertyKeys().contains("available_as_tag") && !isDeleted(trait.getVertex())) {
                vertices.add(trait);
            }
        }
    }
    return Collections.singletonList(new RelationSet("traits", vertices));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TermVertexWrapper(org.apache.atlas.catalog.TermVertexWrapper) TermVertexWrapper(org.apache.atlas.catalog.TermVertexWrapper) VertexWrapper(org.apache.atlas.catalog.VertexWrapper) ArrayList(java.util.ArrayList) Edge(com.tinkerpop.blueprints.Edge)

Example 3 with TermVertexWrapper

use of org.apache.atlas.catalog.TermVertexWrapper in project incubator-atlas by apache.

the class TagRelation method traverse.

@Override
public Collection<RelationSet> traverse(VertexWrapper vWrapper) {
    Vertex v = vWrapper.getVertex();
    Collection<VertexWrapper> vertices = new ArrayList<>();
    for (Edge e : v.getEdges(Direction.OUT)) {
        if (e.getLabel().startsWith(v.<String>getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY))) {
            VertexWrapper trait = new TermVertexWrapper(e.getVertex(Direction.IN));
            if (trait.getPropertyKeys().contains("available_as_tag") && !isDeleted(trait.getVertex())) {
                vertices.add(trait);
            }
        }
    }
    return Collections.singletonList(new RelationSet("tags", vertices));
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) TermVertexWrapper(org.apache.atlas.catalog.TermVertexWrapper) TermVertexWrapper(org.apache.atlas.catalog.TermVertexWrapper) VertexWrapper(org.apache.atlas.catalog.VertexWrapper) ArrayList(java.util.ArrayList) Edge(com.tinkerpop.blueprints.Edge)

Aggregations

Edge (com.tinkerpop.blueprints.Edge)3 TermVertexWrapper (org.apache.atlas.catalog.TermVertexWrapper)3 VertexWrapper (org.apache.atlas.catalog.VertexWrapper)3 Vertex (com.tinkerpop.blueprints.Vertex)2 ArrayList (java.util.ArrayList)2 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)1 PipeFunction (com.tinkerpop.pipes.PipeFunction)1