You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2011/08/15 19:56:06 UTC

svn commit: r1157927 - in /incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify: UpdateEngineWorker.java request/UpdateBinaryOp.java

Author: andy
Date: Mon Aug 15 17:56:06 2011
New Revision: 1157927

URL: http://svn.apache.org/viewvc?rev=1157927&view=rev
Log:
Tidy up handling of SILENT for ADD/COPY/MOVE

Modified:
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java
    incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/request/UpdateBinaryOp.java

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java?rev=1157927&r1=1157926&r2=1157927&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java Mon Aug 15 17:56:06 2011
@@ -36,6 +36,7 @@ import com.hp.hpl.jena.sparql.graph.Node
 import com.hp.hpl.jena.sparql.graph.NodeTransformLib ;
 import com.hp.hpl.jena.sparql.modify.request.Target ;
 import com.hp.hpl.jena.sparql.modify.request.UpdateAdd ;
+import com.hp.hpl.jena.sparql.modify.request.UpdateBinaryOp ;
 import com.hp.hpl.jena.sparql.modify.request.UpdateClear ;
 import com.hp.hpl.jena.sparql.modify.request.UpdateCopy ;
 import com.hp.hpl.jena.sparql.modify.request.UpdateCreate ;
@@ -152,24 +153,49 @@ public class UpdateEngineWorker implemen
 
     public void visit(UpdateAdd update)
     { 
+        if ( ! validBinaryGraphOp(update) ) return ;
+        //  ADD (DEFAULT or GRAPH) TO (DEFAULT or GRAPH) 
         gsCopyTriples(graphStore, update.getSrc(), update.getDest()) ;
     }
 
     public void visit(UpdateCopy update)
     { 
-        gsCopy(graphStore, update.getSrc(), update.getDest()) ;
+        if ( ! validBinaryGraphOp(update) ) return ;
+        // COPY (DEFAULT or GRAPH) TO (DEFAULT or GRAPH) 
+        gsCopy(graphStore, update.getSrc(), update.getDest(), update.getSilent()) ;
     }
 
     public void visit(UpdateMove update)
     { 
-        gsCopy(graphStore, update.getSrc(), update.getDest()) ;
+        if ( ! validBinaryGraphOp(update) ) return ;
+        // MOVE (DEFAULT or GRAPH) TO (DEFAULT or GRAPH) 
+        gsCopy(graphStore, update.getSrc(), update.getDest(), update.getSilent()) ;
         gsDrop(graphStore, update.getSrc(), true) ;
     }
 
+    private boolean validBinaryGraphOp(UpdateBinaryOp update)
+    {
+        if ( update.getSrc().isDefault() )
+            return true ;
+        
+        if ( update.getSrc().isOneNamedGraph() )
+        {
+            Node gn =  update.getSrc().getGraph() ;
+            if ( ! graphStore.containsGraph(gn) )
+            {
+                if ( ! update.getSilent() )
+                    error("No such graph: "+gn) ;
+                return false ;
+            }
+        }
+        error("Invalid source target for oepration; "+update.getSrc()) ;
+        return false ;
+    }
+
     // ----
     // Core operations
     
-    protected static void gsCopy(GraphStore gStore, Target src, Target dest)
+    protected static void gsCopy(GraphStore gStore, Target src, Target dest, boolean isSilent)
     {
         gsClear(gStore, dest, true) ;
         gsCopyTriples(gStore, src, dest) ;
@@ -187,18 +213,8 @@ public class UpdateEngineWorker implemen
 
     protected static void gsClear(GraphStore gStore, Target target, boolean isSilent)
     {
-        // No create.
+        // No create - we tested earlier.
         Graph g = graph(gStore, target) ;
-        if ( target.isOneNamedGraph() )
-        {
-            if ( !gStore.containsGraph(target.getGraph()) )
-            {
-                if ( ! isSilent )
-                    error("No such graph: "+g) ;
-                return ;
-            }
-        }
-        
         g.getBulkUpdateHandler().removeAll() ;
     }
 

Modified: incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/request/UpdateBinaryOp.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/request/UpdateBinaryOp.java?rev=1157927&r1=1157926&r2=1157927&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/request/UpdateBinaryOp.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/com/hp/hpl/jena/sparql/modify/request/UpdateBinaryOp.java Mon Aug 15 17:56:06 2011
@@ -9,7 +9,7 @@ package com.hp.hpl.jena.sparql.modify.re
 import com.hp.hpl.jena.sparql.ARQException ;
 import com.hp.hpl.jena.update.Update ;
 
-abstract class UpdateBinaryOp extends Update
+public abstract class UpdateBinaryOp extends Update
 {
     private Target src ;
     private Target dest ;