use of org.unipop.structure.UniEdge in project unipop by unipop-graph.
the class NestedEdgeSchema method fromFields.
@Override
public Collection<Edge> fromFields(Map<String, Object> fields) {
Object pathValue = fields.get(this.path);
if (pathValue == null)
return null;
Vertex parentVertex = parentVertexSchema.createElement(fields);
if (parentVertex == null)
return null;
if (pathValue instanceof Collection) {
List<Edge> edges = new ArrayList<>(((Collection) pathValue).size());
Collection<Map<String, Object>> edgesFields = (Collection<Map<String, Object>>) pathValue;
for (Map<String, Object> edgeFields : edgesFields) {
UniEdge edge = createEdge(parentVertex, edgeFields);
if (edge == null)
continue;
edges.add(edge);
}
return edges;
} else if (pathValue instanceof Map) {
Map<String, Object> edgeFields = (Map<String, Object>) pathValue;
UniEdge edge = createEdge(parentVertex, edgeFields);
return Collections.singleton(edge);
}
return null;
}
use of org.unipop.structure.UniEdge in project unipop by unipop-graph.
the class NestedEdgeSchema method createEdge.
private UniEdge createEdge(Vertex parentVertex, Map<String, Object> edgeFields) {
Map<String, Object> edgeProperties = getProperties(edgeFields);
if (edgeProperties == null)
return null;
Vertex childVertex = childVertexSchema.createElement(edgeFields);
if (childVertex == null)
return null;
UniEdge edge = new UniEdge(edgeProperties, parentDirection.equals(Direction.OUT) ? parentVertex : childVertex, parentDirection.equals(Direction.IN) ? parentVertex : childVertex, graph);
return edge;
}
use of org.unipop.structure.UniEdge in project unipop by unipop-graph.
the class RestController method addEdge.
@Override
public Edge addEdge(AddEdgeQuery uniQuery) {
UniEdge edge = new UniEdge(uniQuery.getProperties(), uniQuery.getOutVertex(), uniQuery.getInVertex(), graph);
for (RestEdgeSchema edgeSchema : edgeSchemas) {
try {
BaseRequest baseRequest = edgeSchema.addElement(edge);
if (baseRequest == null)
return edge;
baseRequest.asJson();
} catch (UnirestException e) {
e.printStackTrace();
} catch (NoSuchElementException e) {
continue;
}
}
return edge;
}
use of org.unipop.structure.UniEdge in project unipop by unipop-graph.
the class DocEdgeSchema method fromFields.
@Override
public Collection<Edge> fromFields(Map<String, Object> fields) {
Map<String, Object> edgeProperties = getProperties(fields);
if (edgeProperties == null)
return null;
Vertex outVertex = outVertexSchema.createElement(fields);
if (outVertex == null)
return null;
Vertex inVertex = inVertexSchema.createElement(fields);
if (inVertex == null)
return null;
UniEdge uniEdge = new UniEdge(edgeProperties, outVertex, inVertex, graph);
return Collections.singleton(uniEdge);
}
use of org.unipop.structure.UniEdge in project unipop by unipop-graph.
the class RowEdgeSchema method fromFields.
@Override
public Collection<Edge> fromFields(Map<String, Object> fields) {
Map<String, Object> edgeProperties = getProperties(fields);
if (edgeProperties == null)
return null;
Vertex outVertex = outVertexSchema.createElement(fields);
if (outVertex == null)
return null;
Vertex inVertex = inVertexSchema.createElement(fields);
if (inVertex == null)
return null;
UniEdge uniEdge = new UniEdge(edgeProperties, outVertex, inVertex, graph);
return Collections.singleton(uniEdge);
}
Aggregations