Search in sources :

Example 1 with ExpressionResult

use of edu.mit.simile.backstage.model.data.ExpressionResult in project backstage by zepheira.

the class ListFacet method update.

@Override
public void update(TupleQueryBuilder queryBuilder, Var itemVar, BackChannel backChannel) throws ExpressionException {
    _builder = queryBuilder;
    _itemVar = itemVar;
    ExpressionResult result = _expression.computeOutputOnItem(_context.getDatabase(), _builder, _itemVar);
    if (!(result.valueExpr instanceof Var)) {
        throw new ExpressionException("Facet expression does not evaluate to a Var");
    }
    _valueVar = (Var) result.valueExpr;
    _valueType = result.valueType;
    _countVar = _builder.makeVar("count");
    backChannel.addComponentChangingState(this);
}
Also used : ExpressionResult(edu.mit.simile.backstage.model.data.ExpressionResult) Var(org.openrdf.query.algebra.Var) ExpressionException(edu.mit.simile.backstage.model.data.ExpressionException)

Example 2 with ExpressionResult

use of edu.mit.simile.backstage.model.data.ExpressionResult in project backstage by zepheira.

the class ListFacet method restrict.

@Override
public void restrict(TupleQueryBuilder builder, Var itemVar) throws ExpressionException {
    if (!hasRestrictions()) {
        return;
    }
    ExpressionResult result = _expression.computeOutputOnItem(_context.getDatabase(), builder, itemVar);
    if (!(result.valueExpr instanceof Var)) {
        throw new ExpressionException("Facet expression does not evaluate to a Var");
    }
    ValueExpr input = result.valueExpr;
    ValueExpr condition = null;
    if (_selectMissing) {
    // what do we do???
    }
    for (String v : _selection) {
        condition = createRestrictionClause(builder, v, result.valueType, input, condition);
    }
    builder.addCondition(condition);
}
Also used : ValueExpr(org.openrdf.query.algebra.ValueExpr) ExpressionResult(edu.mit.simile.backstage.model.data.ExpressionResult) Var(org.openrdf.query.algebra.Var) ExpressionException(edu.mit.simile.backstage.model.data.ExpressionException)

Aggregations

ExpressionException (edu.mit.simile.backstage.model.data.ExpressionException)2 ExpressionResult (edu.mit.simile.backstage.model.data.ExpressionResult)2 Var (org.openrdf.query.algebra.Var)2 ValueExpr (org.openrdf.query.algebra.ValueExpr)1