Search in sources :

Example 1 with ProjectionElem

use of org.openrdf.query.algebra.ProjectionElem in project backstage by zepheira.

the class Expression method computeOutputOnValue.

public ExpressionQueryResult computeOutputOnValue(Value value, Database database, SailRepositoryConnection connection) throws ExpressionException {
    TupleQueryBuilder builder = new TupleQueryBuilder();
    Var valueVar = builder.makeVar("value", value);
    ExpressionResult expressionResult = computeOutputOnItem(database, builder, valueVar);
    if (expressionResult.valueExpr instanceof Var) {
        Var resultVar = (Var) expressionResult.valueExpr;
        ProjectionElemList projectionElements = new ProjectionElemList();
        projectionElements.addElement(new ProjectionElem(resultVar.getName()));
        TupleExpr t = builder.makeFilterTupleExpr();
        if (t == null) {
            // TODO[dfhuynh]: This happens if the expression is just "value". I'm not sure what to do here.
            return null;
        }
        Projection projection = new Projection(t, projectionElements);
        TupleQuery query = new MyTupleQuery(new ParsedTupleQuery(projection), connection);
        return new ExpressionQueryResult(query, expressionResult.valueType, resultVar);
    }
    return null;
}
Also used : ProjectionElemList(org.openrdf.query.algebra.ProjectionElemList) Var(org.openrdf.query.algebra.Var) Projection(org.openrdf.query.algebra.Projection) TupleQueryBuilder(edu.mit.simile.backstage.model.TupleQueryBuilder) ParsedTupleQuery(org.openrdf.query.parser.ParsedTupleQuery) MyTupleQuery(edu.mit.simile.backstage.util.MyTupleQuery) TupleQuery(org.openrdf.query.TupleQuery) MyTupleQuery(edu.mit.simile.backstage.util.MyTupleQuery) ProjectionElem(org.openrdf.query.algebra.ProjectionElem) TupleExpr(org.openrdf.query.algebra.TupleExpr) ParsedTupleQuery(org.openrdf.query.parser.ParsedTupleQuery)

Aggregations

TupleQueryBuilder (edu.mit.simile.backstage.model.TupleQueryBuilder)1 MyTupleQuery (edu.mit.simile.backstage.util.MyTupleQuery)1 TupleQuery (org.openrdf.query.TupleQuery)1 Projection (org.openrdf.query.algebra.Projection)1 ProjectionElem (org.openrdf.query.algebra.ProjectionElem)1 ProjectionElemList (org.openrdf.query.algebra.ProjectionElemList)1 TupleExpr (org.openrdf.query.algebra.TupleExpr)1 Var (org.openrdf.query.algebra.Var)1 ParsedTupleQuery (org.openrdf.query.parser.ParsedTupleQuery)1