Search in sources :

Example 1 with CypherAstBase

use of org.vertexium.cypher.ast.model.CypherAstBase in project vertexium by visallo.

the class GraphGlue method parseParameterValue.

private Object parseParameterValue(String valueString) {
    valueString = valueString.trim();
    CypherAstBase expression = CypherAstParser.getInstance().parseExpression(valueString);
    return ctx.getExpressionExecutor().executeExpression(ctx, expression, null);
}
Also used : CypherAstBase(org.vertexium.cypher.ast.model.CypherAstBase)

Example 2 with CypherAstBase

use of org.vertexium.cypher.ast.model.CypherAstBase 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);
}
Also used : Vertex(org.vertexium.Vertex) VertexiumCypherTypeErrorException(org.vertexium.cypher.exceptions.VertexiumCypherTypeErrorException) CypherAstBase(org.vertexium.cypher.ast.model.CypherAstBase) Edge(org.vertexium.Edge) VertexiumException(org.vertexium.VertexiumException)

Example 3 with CypherAstBase

use of org.vertexium.cypher.ast.model.CypherAstBase in project vertexium by visallo.

the class ExistsFunction method invoke.

@Override
public Object invoke(VertexiumCypherQueryContext ctx, CypherAstBase[] arguments, ExpressionScope scope) {
    CypherAstBase lookup = arguments[0];
    Object value = ctx.getExpressionExecutor().executeExpression(ctx, lookup, scope);
    return value != null;
}
Also used : CypherAstBase(org.vertexium.cypher.ast.model.CypherAstBase)

Aggregations

CypherAstBase (org.vertexium.cypher.ast.model.CypherAstBase)3 Edge (org.vertexium.Edge)1 Vertex (org.vertexium.Vertex)1 VertexiumException (org.vertexium.VertexiumException)1 VertexiumCypherTypeErrorException (org.vertexium.cypher.exceptions.VertexiumCypherTypeErrorException)1