use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class GraphHelper method getPropagatedClassificationEdge.
public static AtlasEdge getPropagatedClassificationEdge(AtlasVertex entityVertex, String classificationName, String associatedEntityGuid) {
AtlasEdge ret = null;
Iterable edges = entityVertex.query().direction(AtlasEdgeDirection.OUT).label(CLASSIFICATION_LABEL).has(CLASSIFICATION_EDGE_IS_PROPAGATED_PROPERTY_KEY, true).has(CLASSIFICATION_EDGE_NAME_PROPERTY_KEY, classificationName).edges();
if (edges != null) {
Iterator<AtlasEdge> iterator = edges.iterator();
while (iterator.hasNext()) {
AtlasEdge edge = iterator.next();
AtlasVertex classificationVertex = (edge != null) ? edge.getInVertex() : null;
if (classificationVertex != null) {
String guid = AtlasGraphUtilsV1.getProperty(classificationVertex, CLASSIFICATION_ENTITY_GUID, String.class);
if (StringUtils.equals(guid, associatedEntityGuid)) {
ret = edge;
break;
}
}
}
}
return ret;
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasGraphSONUtility method objectNodeFromElement.
/**
* Creates GraphSON for a single graph element.
*/
private ObjectNode objectNodeFromElement(final AtlasElement element) {
final boolean isEdge = element instanceof AtlasEdge;
final boolean showTypes = mode == AtlasGraphSONMode.EXTENDED;
final List<String> propertyKeys = isEdge ? this.edgePropertyKeys : this.vertexPropertyKeys;
final ElementPropertiesRule elementPropertyConfig = isEdge ? this.edgePropertiesRule : this.vertexPropertiesRule;
final ObjectNode jsonElement = createJSONMap(createPropertyMap(element, propertyKeys, elementPropertyConfig, normalized), propertyKeys, showTypes);
if ((isEdge && this.includeReservedEdgeId) || (!isEdge && this.includeReservedVertexId)) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_ID, element.getId());
}
// are graph implementations that have AtlasEdge extend from AtlasVertex
if (element instanceof AtlasEdge) {
final AtlasEdge edge = (AtlasEdge) element;
if (this.includeReservedEdgeId) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_ID, element.getId());
}
if (this.includeReservedEdgeType) {
jsonElement.put(AtlasGraphSONTokens.INTERNAL_TYPE, AtlasGraphSONTokens.EDGE);
}
if (this.includeReservedEdgeOutV) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_OUT_V, edge.getOutVertex().getId());
}
if (this.includeReservedEdgeInV) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_IN_V, edge.getInVertex().getId());
}
if (this.includeReservedEdgeLabel) {
jsonElement.put(AtlasGraphSONTokens.INTERNAL_LABEL, edge.getLabel());
}
} else if (element instanceof AtlasVertex) {
if (this.includeReservedVertexId) {
putObject(jsonElement, AtlasGraphSONTokens.INTERNAL_ID, element.getId());
}
if (this.includeReservedVertexType) {
jsonElement.put(AtlasGraphSONTokens.INTERNAL_TYPE, AtlasGraphSONTokens.VERTEX);
}
}
return jsonElement;
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasJanusVertex method getEdges.
@Override
public Iterable<AtlasEdge<AtlasJanusVertex, AtlasJanusEdge>> getEdges(AtlasEdgeDirection in) {
Direction d = AtlasJanusObjectFactory.createDirection(in);
Iterator<Edge> edges = getWrappedElement().edges(d);
return graph.wrapEdges(edges);
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class AtlasJanusVertex method getEdges.
@Override
public Iterable<AtlasEdge<AtlasJanusVertex, AtlasJanusEdge>> getEdges(AtlasEdgeDirection dir, String edgeLabel) {
Direction d = AtlasJanusObjectFactory.createDirection(dir);
Iterator<Edge> edges = getWrappedElement().edges(d, edgeLabel);
return graph.wrapEdges(edges);
}
use of org.apache.atlas.repository.graphdb.AtlasEdge in project atlas by apache.
the class TinkerpopGraphQuery method edges.
@Override
public Iterable<AtlasEdge<V, E>> edges(int offset, int limit) {
if (LOG.isDebugEnabled()) {
LOG.debug("Executing: " + queryCondition);
}
Preconditions.checkArgument(offset >= 0, "Offset must be non-negative");
Preconditions.checkArgument(limit >= 0, "Limit must be non-negative");
// Compute the overall result by combining the results of all the AndConditions (nested within OR) together.
Set<AtlasEdge<V, E>> result = new HashSet<>();
long resultIdx = 0;
for (AndCondition andExpr : queryCondition.getAndTerms()) {
if (result.size() == limit) {
break;
}
NativeTinkerpopGraphQuery<V, E> andQuery = andExpr.create(getQueryFactory());
for (AtlasEdge<V, E> edge : andQuery.edges(offset + limit)) {
if (resultIdx >= offset) {
result.add(edge);
if (result.size() == limit) {
break;
}
}
resultIdx++;
}
}
return result;
}
Aggregations