use of org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public Object visit(ASTOptPathExprTail tailNode, Object data) throws VisitorException {
List<Var> subjVars = (List<Var>) data;
// Create new sub-graph pattern for optional path expressions
graphPattern = new GraphPattern(graphPattern);
// optional path expression tail
tailNode.getOptionalTail().jjtAccept(this, subjVars);
ASTWhere whereNode = tailNode.getWhereClause();
if (whereNode != null) {
// boolean contraint on optional path expression tail
whereNode.jjtAccept(this, null);
}
graphPattern.getParent().addOptionalTE(graphPattern);
graphPattern = graphPattern.getParent();
ASTPathExprTail nextTailNode = tailNode.getNextTail();
if (nextTailNode != null) {
// branch after optional path expression tail
nextTailNode.jjtAccept(this, subjVars);
}
return null;
}
use of org.eclipse.rdf4j.query.parser.serql.ast.ASTPathExprTail in project rdf4j by eclipse.
the class QueryModelBuilder method visit.
@Override
public Object visit(ASTBasicPathExprTail tailNode, Object data) throws VisitorException {
List<Var> subjVars = (List<Var>) data;
Var predVar = (Var) tailNode.getEdge().jjtAccept(this, null);
List<Var> objVars = (List<Var>) tailNode.getNode().jjtAccept(this, null);
Var contextVar = graphPattern.getContextVar();
StatementPattern.Scope spScope = graphPattern.getStatementPatternScope();
for (Var subjVar : subjVars) {
for (Var objVar : objVars) {
StatementPattern sp = new StatementPattern(spScope, subjVar, predVar, objVar, contextVar);
graphPattern.addRequiredTE(sp);
}
}
// Process next tail segment
ASTPathExprTail nextTailNode = tailNode.getNextTail();
if (nextTailNode != null) {
List<Var> joinVars = nextTailNode.isBranch() ? subjVars : objVars;
nextTailNode.jjtAccept(this, joinVars);
}
return null;
}
Aggregations