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 2012/01/24 15:43:00 UTC

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

Author: andy
Date: Tue Jan 24 14:43:00 2012
New Revision: 1235278

URL: http://svn.apache.org/viewvc?rev=1235278&view=rev
Log:
Update Traget equality by value.
Fix MOVE and COPY for same source and destination.

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

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java?rev=1235278&r1=1235277&r2=1235278&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/UpdateEngineWorker.java Tue Jan 24 14:43:00 2012
@@ -173,7 +173,10 @@ public class UpdateEngineWorker implemen
     public void visit(UpdateAdd update)
     { 
         if ( ! validBinaryGraphOp(update) ) return ;
-        //  ADD (DEFAULT or GRAPH) TO (DEFAULT or GRAPH) 
+        if ( update.getSrc().equals(update.getDest()) )
+            return ;
+        //  ADD (DEFAULT or GRAPH) TO (DEFAULT or GRAPH)
+        // Different source and destination.
         gsCopyTriples(graphStore, update.getSrc(), update.getDest()) ;
     }
 
@@ -181,6 +184,8 @@ public class UpdateEngineWorker implemen
     public void visit(UpdateCopy update)
     { 
         if ( ! validBinaryGraphOp(update) ) return ;
+        if ( update.getSrc().equals(update.getDest()) )
+            return ;
         // COPY (DEFAULT or GRAPH) TO (DEFAULT or GRAPH) 
         gsCopy(graphStore, update.getSrc(), update.getDest(), update.getSilent()) ;
     }
@@ -189,7 +194,10 @@ public class UpdateEngineWorker implemen
     public void visit(UpdateMove update)
     { 
         if ( ! validBinaryGraphOp(update) ) return ;
-        // MOVE (DEFAULT or GRAPH) TO (DEFAULT or GRAPH) 
+        if ( update.getSrc().equals(update.getDest()) )
+            return ;
+        // MOVE (DEFAULT or GRAPH) TO (DEFAULT or GRAPH)
+        // Difefrent source and destination.
         gsCopy(graphStore, update.getSrc(), update.getDest(), update.getSilent()) ;
         gsDrop(graphStore, update.getSrc(), true) ;
     }
@@ -208,6 +216,7 @@ public class UpdateEngineWorker implemen
                     error("No such graph: "+gn) ;
                 return false ;
             }
+            return true ;
         }
         error("Invalid source target for oepration; "+update.getSrc()) ;
         return false ;
@@ -218,6 +227,8 @@ public class UpdateEngineWorker implemen
     
     protected static void gsCopy(GraphStore gStore, Target src, Target dest, boolean isSilent)
     {
+        if ( dest.equals(src) ) 
+            return ;
         gsClear(gStore, dest, true) ;
         gsCopyTriples(gStore, src, dest) ;
     }

Modified: incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/Target.java
URL: http://svn.apache.org/viewvc/incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/Target.java?rev=1235278&r1=1235277&r2=1235278&view=diff
==============================================================================
--- incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/Target.java (original)
+++ incubator/jena/Jena2/ARQ/trunk/src/main/java/com/hp/hpl/jena/sparql/modify/request/Target.java Tue Jan 24 14:43:00 2012
@@ -58,4 +58,30 @@ public class Target
         else    
             return decl.toString() ;
     }
+
+    @Override
+    public int hashCode()
+    {
+        final int prime = 31 ;
+        int result = 1 ;
+        result = prime * result + ((decl == null) ? 0 : decl.hashCode()) ;
+        result = prime * result + ((graphIRI == null) ? 0 : graphIRI.hashCode()) ;
+        return result ;
+    }
+
+    @Override
+    public boolean equals(Object obj)
+    {
+        if (this == obj) return true ;
+        if (obj == null) return false ;
+        if (getClass() != obj.getClass()) return false ;
+        Target other = (Target)obj ;
+        if (decl != other.decl) return false ;
+        if (graphIRI == null)
+        {
+            if (other.graphIRI != null) return false ;
+        } else
+            if (!graphIRI.equals(other.graphIRI)) return false ;
+        return true ;
+    }
 }