You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/07/05 10:22:09 UTC

git commit: since the semantics of the listResources changed, introduced also a listSubjects method

Updated Branches:
  refs/heads/develop dc20aedc9 -> a71238c81


since the semantics of the listResources changed, introduced also a listSubjects method


Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/a71238c8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/a71238c8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/a71238c8

Branch: refs/heads/develop
Commit: a71238c81219096c8e2f8fdfa9ec837416fa00a8
Parents: dc20aed
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Fri Jul 5 10:22:02 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Fri Jul 5 10:22:02 2013 +0200

----------------------------------------------------------------------
 .../commons/sesame/repository/ResourceUtils.java | 19 ++++++++++++++++---
 .../marmotta/kiwi/test/RepositoryTest.java       |  2 +-
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/a71238c8/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
----------------------------------------------------------------------
diff --git a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
index 276ba2a..156c95f 100644
--- a/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
+++ b/commons/marmotta-commons/src/main/java/org/apache/marmotta/commons/sesame/repository/ResourceUtils.java
@@ -257,11 +257,24 @@ public class ResourceUtils {
                 }
             };
         } else {
-            return listResourcesInternal(con,null,null,null);
+            return listSubjectsInternal(con, null, null, null);
         }
     }
 
     /**
+     * List all resources contained in the KiWi System, regardless of knowledge space or type. Since this
+     * operation works directly on the triple store, there is no guarantee the result is free of duplicates.
+     * In case the underlying connection does not directly support listing resources (i.e. is not an instance of
+     * ResourceConnection), the method will iterate over all triples and return their subjects
+     *
+     * @return
+     */
+    public static Iterable<Resource> listSubjects(RepositoryConnection con) {
+        return listSubjectsInternal(con, null, null, null);
+    }
+
+
+    /**
      * List all resources of a specific type in the KiWi system.
      *
      * @param type the type of the resources to list
@@ -281,7 +294,7 @@ public class ResourceUtils {
     public static Iterable<Resource> listResources(final RepositoryConnection con, final Resource type, final URI context) {
         URI rdf_type = con.getValueFactory().createURI(Namespaces.NS_RDF + "type");
 
-        return listResourcesInternal(con,rdf_type,type,context);
+        return listSubjectsInternal(con, rdf_type, type, context);
     }
 
     /**
@@ -359,7 +372,7 @@ public class ResourceUtils {
         return listResourcesByPrefix(con,prefix,0,0);
     }
 
-    private static Iterable<Resource> listResourcesInternal(final RepositoryConnection con, final URI property, final Value value, final URI context) {
+    private static Iterable<Resource> listSubjectsInternal(final RepositoryConnection con, final URI property, final Value value, final URI context) {
         final Resource[] contexts;
         if(context != null) {
             contexts = new Resource[] { context };

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/a71238c8/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
index 37e7ab1..4e8c50c 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/RepositoryTest.java
@@ -356,7 +356,7 @@ public class RepositoryTest {
             // the resource hans_meier should not be contained in the list of resources
             List<String> resources2 = ImmutableList.copyOf(
                     Iterables.transform(
-                            ResourceUtils.listResources(connection),
+                            ResourceUtils.listSubjects(connection),
                             new Function<Resource, String>() {
                                 @Override
                                 public String apply(Resource input) {