Search in sources :

Example 81 with AtlasEdge

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

the class GraphHelper method addEdge.

public AtlasEdge addEdge(AtlasVertex fromVertex, AtlasVertex toVertex, String edgeLabel) {
    AtlasEdge ret;
    if (LOG.isDebugEnabled()) {
        LOG.debug("Adding edge for {} -> label {} -> {}", string(fromVertex), edgeLabel, string(toVertex));
    }
    ret = graph.addEdge(fromVertex, toVertex, edgeLabel);
    if (ret != null) {
        setProperty(ret, Constants.STATE_PROPERTY_KEY, Id.EntityState.ACTIVE.name());
        setProperty(ret, Constants.TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime());
        setProperty(ret, Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY, RequestContextV1.get().getRequestTime());
        setProperty(ret, Constants.CREATED_BY_KEY, RequestContextV1.get().getUser());
        setProperty(ret, Constants.MODIFIED_BY_KEY, RequestContextV1.get().getUser());
        if (LOG.isDebugEnabled()) {
            LOG.debug("Added {}", string(ret));
        }
    }
    return ret;
}
Also used : AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Example 82 with AtlasEdge

use of org.apache.atlas.repository.graphdb.AtlasEdge 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)

Example 83 with AtlasEdge

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

the class GraphHelper method getClassificationVertex.

public static AtlasVertex getClassificationVertex(AtlasVertex entityVertex, String classificationName) {
    AtlasVertex ret = null;
    Iterable edges = entityVertex.query().direction(AtlasEdgeDirection.OUT).label(CLASSIFICATION_LABEL).has(CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, false).has(CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, classificationName).edges();
    if (edges != null) {
        Iterator<AtlasEdge> iterator = edges.iterator();
        if (iterator.hasNext()) {
            AtlasEdge edge = iterator.next();
            ret = (edge != null) ? edge.getInVertex() : null;
        }
    }
    return ret;
}
Also used : AtlasVertex(org.apache.atlas.repository.graphdb.AtlasVertex) AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge)

Example 84 with AtlasEdge

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

the class AtlasJanusGraph method removeEdge.

@Override
public void removeEdge(AtlasEdge<AtlasJanusVertex, AtlasJanusEdge> edge) {
    Edge wrapped = edge.getE().getWrappedElement();
    wrapped.remove();
}
Also used : AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge) Edge(org.apache.tinkerpop.gremlin.structure.Edge)

Example 85 with AtlasEdge

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

the class AtlasJanusGraph method getEdge.

@Override
public AtlasEdge<AtlasJanusVertex, AtlasJanusEdge> getEdge(String edgeId) {
    Iterator<Edge> it = getGraph().edges(edgeId);
    Edge e = getSingleElement(it, edgeId);
    return GraphDbObjectFactory.createEdge(this, e);
}
Also used : AtlasEdge(org.apache.atlas.repository.graphdb.AtlasEdge) Edge(org.apache.tinkerpop.gremlin.structure.Edge)

Aggregations

AtlasEdge (org.apache.atlas.repository.graphdb.AtlasEdge)138 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)60 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)28 AtlasType (org.apache.atlas.type.AtlasType)15 ArrayList (java.util.ArrayList)13 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)13 AtlasStructType (org.apache.atlas.type.AtlasStructType)12 AtlasAttribute (org.apache.atlas.type.AtlasStructType.AtlasAttribute)12 RepositoryException (org.apache.atlas.repository.RepositoryException)11 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)11 Edge (org.apache.tinkerpop.gremlin.structure.Edge)10 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)8 AtlasRelationship (org.apache.atlas.model.instance.AtlasRelationship)8 AtlasMapType (org.apache.atlas.type.AtlasMapType)8 AtlasArrayType (org.apache.atlas.type.AtlasArrayType)7 HashSet (java.util.HashSet)6 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)6 Id (org.apache.atlas.typesystem.persistence.Id)6 AtlasException (org.apache.atlas.AtlasException)5 Iterator (java.util.Iterator)4