jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [1/3] jena git commit: JENA-1451: "contains" for special graphs
Date Thu, 21 Dec 2017 19:48:37 GMT
Repository: jena
Updated Branches:
  refs/heads/master 2b3a4c7bc -> ba2b415f4


JENA-1451: "contains" for special graphs


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/0d2f51b8
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/0d2f51b8
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/0d2f51b8

Branch: refs/heads/master
Commit: 0d2f51b89cec6b9c67cd52919046f979f8964397
Parents: 2b3a4c7
Author: Andy Seaborne <andy@apache.org>
Authored: Thu Dec 21 10:53:20 2017 +0000
Committer: Andy Seaborne <andy@apache.org>
Committed: Thu Dec 21 13:10:17 2017 +0000

----------------------------------------------------------------------
 .../jena/sparql/core/DatasetGraphBase.java      |  9 +++++++--
 .../jena/sparql/core/DatasetGraphMapLink.java   |  2 ++
 .../jena/sparql/core/AbstractTestDataset.java   | 20 ++++++++++++++++++++
 3 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/0d2f51b8/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
index eac9985..1ebc4ab 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphBase.java
@@ -53,8 +53,13 @@ abstract public class DatasetGraphBase implements DatasetGraph
     protected DatasetGraphBase() {}
     
     @Override
-    public boolean containsGraph(Node graphNode)
-    { return contains(graphNode, Node.ANY, Node.ANY, Node.ANY) ; }
+    public boolean containsGraph(Node graphNode) { 
+        if ( Quad.isDefaultGraph(graphNode) )
+            return true;
+        if ( Quad.isUnionGraph(graphNode) )
+            return true;
+        return contains(graphNode, Node.ANY, Node.ANY, Node.ANY);
+    }
     
     // Explicit record of what's not provided here.
     

http://git-wip-us.apache.org/repos/asf/jena/blob/0d2f51b8/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMapLink.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMapLink.java b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMapLink.java
index c6d455b..605778a 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMapLink.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/core/DatasetGraphMapLink.java
@@ -136,6 +136,8 @@ public class DatasetGraphMapLink extends DatasetGraphCollection
 
     @Override
     public boolean containsGraph(Node graphNode) {
+        if ( Quad.isDefaultGraph(graphNode) || Quad.isUnionGraph(graphNode) )
+            return true;
         return graphs.containsKey(graphNode);
     }
 

http://git-wip-us.apache.org/repos/asf/jena/blob/0d2f51b8/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java
----------------------------------------------------------------------
diff --git a/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java b/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java
index b55991d..cd5fbc5 100644
--- a/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java
+++ b/jena-arq/src/test/java/org/apache/jena/sparql/core/AbstractTestDataset.java
@@ -116,4 +116,24 @@ public abstract class AbstractTestDataset extends BaseTest
         ds.addNamedModel(graphName, model1) ;
         assertFalse("Dataset should not be empty after a named graph has been added!", ds.isEmpty());
     }
+    
+    @Test public void dataset_07()
+    {
+        String graphName = "http://example/" ;
+        Dataset ds = createDataset() ;
+        ds.addNamedModel(graphName, model1) ;
+        assertTrue("Named graph not found", ds.containsNamedModel(graphName));
+    }
+    
+    // Even if empty, union and named default graph exist (sort of).
+
+    @Test public void dataset_08() {
+        Dataset ds = createDataset();
+        assertTrue("Union named graph not found", ds.containsNamedModel(Quad.unionGraph.getURI()));
+    }
+
+    @Test public void dataset_09() {
+        Dataset ds = createDataset();
+        assertTrue("Default graph not found using '<"+Quad.defaultGraphIRI.getURI()+">'",
ds.containsNamedModel(Quad.defaultGraphIRI.getURI()));
+    }
 }


Mime
View raw message