use of org.openrdf.query.algebra.TupleExpr in project backstage by zepheira.
the class TupleQueryBuilder method joinTupleExpressions.
public TupleExpr joinTupleExpressions() {
Iterator<TupleExpr> i = _tupleExprs.iterator();
TupleExpr result = i.hasNext() ? i.next() : null;
while (i.hasNext()) {
result = new Join(result, i.next());
}
return result;
}
use of org.openrdf.query.algebra.TupleExpr 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.TupleExpr in project gocd by gocd.
the class SesameGraph method contextualize.
private void contextualize(Query query) throws Exception {
if (contextVar == null) {
return;
}
TupleExpr tupleExpr = ((SailQuery) query).getParsedQuery().getTupleExpr();
tupleExpr.visit(new QueryModelVisitorBase() {
public void meet(StatementPattern node) throws Exception {
if (node.getContextVar() != null) {
throw new UnsupportedSPARQLStatementException("Attempted to execute a SPARQL statement with a GRAPH clause against a context aware graph.");
}
node.setContextVar(contextVar);
}
});
}
use of org.openrdf.query.algebra.TupleExpr 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;
}
use of org.openrdf.query.algebra.TupleExpr 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