diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/BuildElementVisitor.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/BuildElementVisitor.java index 5a1a1185d84..6e21ddc0564 100644 --- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/BuildElementVisitor.java +++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/BuildElementVisitor.java @@ -20,24 +20,7 @@ import java.util.List; import org.apache.jena.arq.querybuilder.handlers.WhereHandler; -import org.apache.jena.sparql.syntax.Element; -import org.apache.jena.sparql.syntax.ElementAssign; -import org.apache.jena.sparql.syntax.ElementBind; -import org.apache.jena.sparql.syntax.ElementData; -import org.apache.jena.sparql.syntax.ElementDataset; -import org.apache.jena.sparql.syntax.ElementExists; -import org.apache.jena.sparql.syntax.ElementFilter; -import org.apache.jena.sparql.syntax.ElementGroup; -import org.apache.jena.sparql.syntax.ElementMinus; -import org.apache.jena.sparql.syntax.ElementNamedGraph; -import org.apache.jena.sparql.syntax.ElementNotExists; -import org.apache.jena.sparql.syntax.ElementOptional; -import org.apache.jena.sparql.syntax.ElementPathBlock; -import org.apache.jena.sparql.syntax.ElementService; -import org.apache.jena.sparql.syntax.ElementSubQuery; -import org.apache.jena.sparql.syntax.ElementTriplesBlock; -import org.apache.jena.sparql.syntax.ElementUnion; -import org.apache.jena.sparql.syntax.ElementVisitor; +import org.apache.jena.sparql.syntax.*; /** * An element visitor that does an in-place modification of the elements to fix @@ -114,6 +97,17 @@ public void visit(ElementUnion el) { } } + @Override + public void visit(ElementLateral el) { + el.getLateralElement().visit(this); + if (result == el.getLateralElement()) { + result = el; + } else { + result = new ElementOptional(result); + } + } + + @Override public void visit(ElementOptional el) { el.getOptionalElement().visit(this); diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/ElementRewriter.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/ElementRewriter.java index c3528bbce49..969ebaa63ec 100644 --- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/ElementRewriter.java +++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/ElementRewriter.java @@ -27,24 +27,7 @@ import org.apache.jena.sparql.core.TriplePath; import org.apache.jena.sparql.core.Var; import org.apache.jena.sparql.engine.binding.Binding; -import org.apache.jena.sparql.syntax.Element; -import org.apache.jena.sparql.syntax.ElementAssign; -import org.apache.jena.sparql.syntax.ElementBind; -import org.apache.jena.sparql.syntax.ElementData; -import org.apache.jena.sparql.syntax.ElementDataset; -import org.apache.jena.sparql.syntax.ElementExists; -import org.apache.jena.sparql.syntax.ElementFilter; -import org.apache.jena.sparql.syntax.ElementGroup; -import org.apache.jena.sparql.syntax.ElementMinus; -import org.apache.jena.sparql.syntax.ElementNamedGraph; -import org.apache.jena.sparql.syntax.ElementNotExists; -import org.apache.jena.sparql.syntax.ElementOptional; -import org.apache.jena.sparql.syntax.ElementPathBlock; -import org.apache.jena.sparql.syntax.ElementService; -import org.apache.jena.sparql.syntax.ElementSubQuery; -import org.apache.jena.sparql.syntax.ElementTriplesBlock; -import org.apache.jena.sparql.syntax.ElementUnion; -import org.apache.jena.sparql.syntax.ElementVisitor; +import org.apache.jena.sparql.syntax.*; /** * A rewriter that implements an ElementVisitor @@ -54,7 +37,7 @@ public class ElementRewriter extends AbstractRewriter implements Elemen /** * Constructor - * + * * @param values The values to rewrite with. */ public ElementRewriter(Map values) { @@ -140,6 +123,12 @@ public void visit(ElementUnion el) { push(retval); } + @Override + public void visit(ElementLateral el) { + el.getLateralElement().visit(this); + push(new ElementLateral(getResult())); + } + @Override public void visit(ElementOptional el) { el.getOptionalElement().visit(this); diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/OpRewriter.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/OpRewriter.java index 719927fb37e..65a80d9fce1 100644 --- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/OpRewriter.java +++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/rewriters/OpRewriter.java @@ -27,46 +27,9 @@ import org.apache.jena.sparql.algebra.Op; import org.apache.jena.sparql.algebra.OpVisitor; import org.apache.jena.sparql.algebra.Table; -import org.apache.jena.sparql.algebra.op.OpAssign; -import org.apache.jena.sparql.algebra.op.OpBGP; -import org.apache.jena.sparql.algebra.op.OpConditional; -import org.apache.jena.sparql.algebra.op.OpDatasetNames; -import org.apache.jena.sparql.algebra.op.OpDiff; -import org.apache.jena.sparql.algebra.op.OpDisjunction; -import org.apache.jena.sparql.algebra.op.OpDistinct; -import org.apache.jena.sparql.algebra.op.OpExt; -import org.apache.jena.sparql.algebra.op.OpExtend; -import org.apache.jena.sparql.algebra.op.OpFilter; -import org.apache.jena.sparql.algebra.op.OpGraph; -import org.apache.jena.sparql.algebra.op.OpGroup; -import org.apache.jena.sparql.algebra.op.OpJoin; -import org.apache.jena.sparql.algebra.op.OpLabel; -import org.apache.jena.sparql.algebra.op.OpLeftJoin; -import org.apache.jena.sparql.algebra.op.OpList; -import org.apache.jena.sparql.algebra.op.OpMinus; -import org.apache.jena.sparql.algebra.op.OpNull; -import org.apache.jena.sparql.algebra.op.OpOrder; -import org.apache.jena.sparql.algebra.op.OpPath; -import org.apache.jena.sparql.algebra.op.OpProcedure; -import org.apache.jena.sparql.algebra.op.OpProject; -import org.apache.jena.sparql.algebra.op.OpPropFunc; -import org.apache.jena.sparql.algebra.op.OpQuad; -import org.apache.jena.sparql.algebra.op.OpQuadBlock; -import org.apache.jena.sparql.algebra.op.OpQuadPattern; -import org.apache.jena.sparql.algebra.op.OpReduced; -import org.apache.jena.sparql.algebra.op.OpSequence; -import org.apache.jena.sparql.algebra.op.OpService; -import org.apache.jena.sparql.algebra.op.OpSlice; -import org.apache.jena.sparql.algebra.op.OpTable; -import org.apache.jena.sparql.algebra.op.OpTopN; -import org.apache.jena.sparql.algebra.op.OpTriple; -import org.apache.jena.sparql.algebra.op.OpUnion; +import org.apache.jena.sparql.algebra.op.*; import org.apache.jena.sparql.algebra.table.TableN; -import org.apache.jena.sparql.core.BasicPattern; -import org.apache.jena.sparql.core.Quad; -import org.apache.jena.sparql.core.QuadPattern; -import org.apache.jena.sparql.core.Var; -import org.apache.jena.sparql.core.VarExprList; +import org.apache.jena.sparql.core.*; import org.apache.jena.sparql.engine.binding.Binding; import org.apache.jena.sparql.expr.ExprAggregator; import org.apache.jena.sparql.expr.ExprList; @@ -80,7 +43,7 @@ class OpRewriter extends AbstractRewriter implements OpVisitor { /** * Constructor. - * + * * @param values The values to replace. */ OpRewriter(Map values) { @@ -275,6 +238,13 @@ public void visit(OpMinus opMinus) { push(OpMinus.create(pop(), pop())); } + @Override + public void visit(OpLateral opLateral) { + opLateral.getRight().visit(this); + opLateral.getLeft().visit(this); + push(OpLateral.create(pop(), pop())); + } + @Override public void visit(OpConditional opCondition) { opCondition.getRight().visit(this); diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/updatebuilder/QuadIteratorBuilder.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/updatebuilder/QuadIteratorBuilder.java index 54247bb1486..39be11c8703 100644 --- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/updatebuilder/QuadIteratorBuilder.java +++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/updatebuilder/QuadIteratorBuilder.java @@ -26,24 +26,7 @@ import org.apache.jena.query.QueryParseException; import org.apache.jena.sparql.core.Quad; import org.apache.jena.sparql.core.TriplePath; -import org.apache.jena.sparql.syntax.Element; -import org.apache.jena.sparql.syntax.ElementAssign; -import org.apache.jena.sparql.syntax.ElementBind; -import org.apache.jena.sparql.syntax.ElementData; -import org.apache.jena.sparql.syntax.ElementDataset; -import org.apache.jena.sparql.syntax.ElementExists; -import org.apache.jena.sparql.syntax.ElementFilter; -import org.apache.jena.sparql.syntax.ElementGroup; -import org.apache.jena.sparql.syntax.ElementMinus; -import org.apache.jena.sparql.syntax.ElementNamedGraph; -import org.apache.jena.sparql.syntax.ElementNotExists; -import org.apache.jena.sparql.syntax.ElementOptional; -import org.apache.jena.sparql.syntax.ElementPathBlock; -import org.apache.jena.sparql.syntax.ElementService; -import org.apache.jena.sparql.syntax.ElementSubQuery; -import org.apache.jena.sparql.syntax.ElementTriplesBlock; -import org.apache.jena.sparql.syntax.ElementUnion; -import org.apache.jena.sparql.syntax.ElementVisitor; +import org.apache.jena.sparql.syntax.*; import org.apache.jena.util.iterator.ExtendedIterator; import org.apache.jena.util.iterator.WrappedIterator; @@ -69,7 +52,7 @@ public Quad apply(Triple triple) { /** * Constructor. - * + * * @param defaultGraph the default graph name. */ QuadIteratorBuilder(Node defaultGraph) { @@ -120,6 +103,11 @@ public void visit(ElementUnion el) { } } + @Override + public void visit(ElementLateral el) { + throw new QueryParseException("lateral not permitted in data quad", -1, -1); + } + @Override public void visit(ElementOptional el) { throw new QueryParseException("optional not permitted in data quad", -1, -1); diff --git a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/WhereValidator.java b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/WhereValidator.java index c1f188cd942..b94c3d8052c 100644 --- a/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/WhereValidator.java +++ b/jena-extras/jena-querybuilder/src/test/java/org/apache/jena/arq/querybuilder/WhereValidator.java @@ -19,24 +19,7 @@ import java.util.List; -import org.apache.jena.sparql.syntax.Element; -import org.apache.jena.sparql.syntax.ElementAssign; -import org.apache.jena.sparql.syntax.ElementBind; -import org.apache.jena.sparql.syntax.ElementData; -import org.apache.jena.sparql.syntax.ElementDataset; -import org.apache.jena.sparql.syntax.ElementExists; -import org.apache.jena.sparql.syntax.ElementFilter; -import org.apache.jena.sparql.syntax.ElementGroup; -import org.apache.jena.sparql.syntax.ElementMinus; -import org.apache.jena.sparql.syntax.ElementNamedGraph; -import org.apache.jena.sparql.syntax.ElementNotExists; -import org.apache.jena.sparql.syntax.ElementOptional; -import org.apache.jena.sparql.syntax.ElementPathBlock; -import org.apache.jena.sparql.syntax.ElementService; -import org.apache.jena.sparql.syntax.ElementSubQuery; -import org.apache.jena.sparql.syntax.ElementTriplesBlock; -import org.apache.jena.sparql.syntax.ElementUnion; -import org.apache.jena.sparql.syntax.ElementVisitor; +import org.apache.jena.sparql.syntax.*; import org.apache.jena.sparql.util.NodeIsomorphismMap; /** @@ -131,6 +114,14 @@ public void visit(ElementUnion el) { return; } + @Override + public void visit(ElementLateral el) { + checkMatching(el); + if (!matching) { + el.getLateralElement().visit(this); + } + } + @Override public void visit(ElementOptional el) { checkMatching(el);