jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1488997 - in /jena/trunk/jena-arq/src: main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java
Date Mon, 03 Jun 2013 14:03:30 GMT
Author: andy
Date: Mon Jun  3 14:03:30 2013
New Revision: 1488997

URL: http://svn.apache.org/r1488997
Log:
JENA-465 : Implement conversion of OpMinus back to query syntax.

Modified:
    jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java
    jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java

Modified: jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java?rev=1488997&r1=1488996&r2=1488997&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java (original)
+++ jena/trunk/jena-arq/src/main/java/com/hp/hpl/jena/sparql/algebra/OpAsQuery.java Mon Jun
 3 14:03:30 2013
@@ -325,8 +325,15 @@ public class OpAsQuery
         { throw new ARQNotImplemented("OpDiff") ; }
 
         @Override
-        public void visit(OpMinus opMinus)
-        { throw new ARQNotImplemented("OpMinus") ; }
+        public void visit(OpMinus opMinus) {
+            Element eLeft = asElement(opMinus.getLeft()) ;
+            Element eRight = asElementGroup(opMinus.getRight()) ;
+            ElementMinus elMinus = new ElementMinus(eRight) ;
+            ElementGroup g = currentGroup() ;
+            if ( ! emptyGroup(eLeft) )
+                g.addElement(eLeft) ;
+            g.addElement(elMinus) ;
+        }
 
         @Override
         public void visit(OpUnion opUnion)

Modified: jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java?rev=1488997&r1=1488996&r2=1488997&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java (original)
+++ jena/trunk/jena-arq/src/test/java/com/hp/hpl/jena/sparql/algebra/TestOpAsQuery.java Mon
Jun  3 14:03:30 2013
@@ -272,6 +272,19 @@ public class TestOpAsQuery {
         Query r[] = checkQueryParseable(query, false);
     }
 
+    @Test
+    public void testMinus1() {
+        String query = "PREFIX : <http://example/> SELECT * { ?s :p ?o MINUS { ?s :q
?v .FILTER(?v<5) } }" ; 
+        Query r[] = checkQueryParseable(query, true);
+    }
+    
+    @Test
+    public void testMinus2() {
+        // query gains a level of {} but the meaning is the same. 
+        String query = "PREFIX : <http://example/> SELECT * { ?s :p ?o OPTIONAL { ?s
:x ?2 } MINUS { ?s :q ?v .FILTER(?v<5) } }" ; 
+        Query r[] = checkQueryParseable(query, false);
+    }
+    
     public Query[] checkQuery(String query) {
         Query orig = QueryFactory.create(query, Syntax.syntaxSPARQL_11);
         Op toReconstruct = Algebra.compile(orig);



Mime
View raw message