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;
}
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;
}
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;
}
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();
}
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);
}
Aggregations