Search in sources :

Example 1 with TupleQueryBuilder

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

the class TileView method getComponentState.

@Override
public Scriptable getComponentState() {
    _logger.debug("> getComponentState");
    TupleQueryBuilder builder = new TupleQueryBuilder();
    Var itemVar = getCollection().getRestrictedItems(builder, null);
    String key = "tile-view-rendering:" + builder.getStringSerialization();
    _logger.debug("component: " + key);
    Scriptable result = (Scriptable) _context.getDatabase().cacheAndRun(key, new ViewRenderingCacheableQuery(builder, itemVar));
    _logger.debug("< getComponentState");
    return result;
}
Also used : Var(org.openrdf.query.algebra.Var) TupleQueryBuilder(edu.mit.simile.backstage.model.TupleQueryBuilder) Scriptable(org.mozilla.javascript.Scriptable)

Example 2 with TupleQueryBuilder

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

the class Collection method updateOneFacet.

protected void updateOneFacet(Facet facet, BackChannel backChannel) {
    TupleQueryBuilder builder = new TupleQueryBuilder();
    Var itemVar = getAllItems(builder, null);
    computeRestrictedItems(builder, itemVar, facet);
    try {
        facet.update(builder, itemVar, backChannel);
    } catch (ExpressionException e) {
        _logger.error("Failed to update facet", e);
    }
}
Also used : Var(org.openrdf.query.algebra.Var) TupleQueryBuilder(edu.mit.simile.backstage.model.TupleQueryBuilder)

Example 3 with TupleQueryBuilder

use of edu.mit.simile.backstage.model.TupleQueryBuilder 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)3 Var (org.openrdf.query.algebra.Var)3 MyTupleQuery (edu.mit.simile.backstage.util.MyTupleQuery)1 Scriptable (org.mozilla.javascript.Scriptable)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 ParsedTupleQuery (org.openrdf.query.parser.ParsedTupleQuery)1