use of org.vertexium.Vertex in project vertexium by visallo.
the class SetClauseExecutor method executeSetNodeLabels.
private void executeSetNodeLabels(VertexiumCypherQueryContext ctx, CypherSetNodeLabels setItem, VertexiumCypherScope.Item item) {
Object left = ctx.getExpressionExecutor().executeExpression(ctx, setItem.getLeft(), item);
VertexiumCypherTypeErrorException.assertType(left, Vertex.class, null);
if (left == null) {
return;
}
Vertex vertex = (Vertex) left;
ExistingElementMutation<Vertex> m = vertex.prepareMutation();
for (CypherLabelName labelName : setItem.getRight()) {
ctx.setLabelProperty(m, labelName.getValue());
}
ctx.saveVertex(m);
}
use of org.vertexium.Vertex in project vertexium by visallo.
the class LabelsFunction method invoke.
@Override
public Object invoke(VertexiumCypherQueryContext ctx, CypherAstBase[] arguments, ExpressionScope scope) {
CypherAstBase lookup = arguments[0];
Object item = ctx.getExpressionExecutor().executeExpression(ctx, lookup, scope);
if (item == null) {
throw new VertexiumException("Could not find Vertex using " + lookup);
}
if (item instanceof Vertex) {
Vertex vertex = (Vertex) item;
return ctx.getVertexLabels(vertex);
}
if (item instanceof Edge) {
Edge edge = (Edge) item;
return Lists.newArrayList(edge.getLabel());
}
throw new VertexiumCypherTypeErrorException(item, Vertex.class, Edge.class);
}
use of org.vertexium.Vertex in project vertexium by visallo.
the class LazyVertexMap method get.
public Object get(String vertexId) {
if (vertexId.endsWith("*")) {
String vertexIdPrefix = vertexId.substring(0, vertexId.length() - 1);
Iterable<Vertex> vertices = getGraph().getVerticesWithPrefix(vertexIdPrefix, getGraph().getDefaultFetchHints(), getTime(), getAuthorizations());
List<String> results = new ArrayList<>();
for (Vertex v : vertices) {
results.add(v.getId());
}
return new LazyVertexList(results);
} else {
Vertex v = getGraph().getVertex(vertexId, getGraph().getDefaultFetchHints(), getTime(), getAuthorizations());
if (v == null) {
return null;
}
return new LazyVertex(vertexId);
}
}
Aggregations