use of org.openrdf.query.algebra.ValueExpr in project backstage by zepheira.
the class TupleQueryBuilder method makeFilterTupleExpr.
public TupleExpr makeFilterTupleExpr() {
TupleExpr tupleExprs = joinTupleExpressions();
ValueExpr conditions = joinConditions();
return (conditions == null) ? tupleExprs : new Filter(tupleExprs, conditions);
}
use of org.openrdf.query.algebra.ValueExpr in project backstage by zepheira.
the class Path method computeOutput.
@Override
public ExpressionResult computeOutput(Database database, TupleQueryBuilder builder, Map<String, ValueExpr> variableValues, Map<String, String> variableTypes) throws ExpressionException {
String rootName = _rootVariable != null ? _rootVariable : "value";
ValueExpr valueExpr = variableValues.get(rootName);
String valueType = variableTypes.get(rootName);
for (PathSegment segment : _segments) {
if (valueExpr instanceof Var) {
Var input = (Var) valueExpr;
PropertyRecord record = database.getPropertyRecord(segment.propertyID);
if (record == null) {
throw new ExpressionException("No property can be aliased to '" + segment.propertyID + "'");
}
Var output = builder.makeVar("seg");
Var propertyVar = builder.makeVar("seg", record.uri);
if (segment.forward) {
builder.addTupleExpr(new StatementPattern(input, propertyVar, output));
valueType = record.valueType;
} else {
builder.addTupleExpr(new StatementPattern(output, propertyVar, input));
valueType = "item";
}
valueExpr = output;
} else {
throw new ExpressionException("Non-final set in a path must be a variable.");
}
}
return new ExpressionResult(valueExpr, valueType);
}
use of org.openrdf.query.algebra.ValueExpr 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);
}
use of org.openrdf.query.algebra.ValueExpr in project backstage by zepheira.
the class TupleQueryBuilder method getStringSerialization.
public String getStringSerialization() {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (TupleExpr tupleExpr : _tupleExprs) {
if (first) {
first = false;
} else {
sb.append(';');
}
sb.append(QueryModelTreePrinter.printTree(tupleExpr));
}
for (ValueExpr valueExpr : _conditions) {
if (first) {
first = false;
sb.append('|');
} else {
sb.append(';');
}
sb.append(QueryModelTreePrinter.printTree(valueExpr));
}
return sb.toString();
}
Aggregations