You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commonsrdf.apache.org by st...@apache.org on 2016/10/07 15:00:25 UTC

[1/7] incubator-commonsrdf git commit: Support Option also for asRDFTermGraphUnion

Repository: incubator-commonsrdf
Updated Branches:
  refs/heads/rdf4j 45faf6ee8 -> 3134a2d1d


Support Option also for asRDFTermGraphUnion


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

Branch: refs/heads/rdf4j
Commit: 850b29c3fe0932882534ab829607e8ac8fb0b5d5
Parents: 45faf6e
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 15:36:38 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 15:36:38 2016 +0100

----------------------------------------------------------------------
 .../org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/850b29c3/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
index 634648a..2456714 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
@@ -333,7 +333,7 @@ public final class RDF4JTermFactory implements RDFTermFactory {
 		return rdf4j.createRepositoryGraphImpl(repository, 
 				opts.contains(Option.handleInitAndShutdown), 
 				opts.contains(Option.includeInferred), 
-				new Resource[0]);
+				new Resource[]{null}); // default graph
 	}
 
 	/**
@@ -345,10 +345,17 @@ public final class RDF4JTermFactory implements RDFTermFactory {
 	 *
 	 * @param repository
 	 *            RDF4J {@link Repository} to connect to.
+	 * @param options
+	 *            Zero or more {@link Option}
 	 * @return A union {@link Graph} backed by the RDF4J repository.
 	 */
-	public RDF4JGraph asRDFTermGraphUnion(Repository repository) {
-		return rdf4j.createRepositoryGraphImpl(repository, false, true);
+	public RDF4JGraph asRDFTermGraphUnion(Repository repository, Option... options) {
+		EnumSet<Option> opts = optionSet(options);
+		return rdf4j.createRepositoryGraphImpl(repository, 
+				opts.contains(Option.handleInitAndShutdown), 
+				opts.contains(Option.includeInferred),
+				new Resource[]{}); // union graph 
+		
 	}
 
 	/**


[5/7] incubator-commonsrdf git commit: avoid javadoc warnings

Posted by st...@apache.org.
avoid javadoc warnings


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

Branch: refs/heads/rdf4j
Commit: 0f8ef7a90fa94faf3016e2e03d6b086848b15e18
Parents: 62fe6b3
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 15:57:22 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 15:57:22 2016 +0100

----------------------------------------------------------------------
 rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/0f8ef7a9/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
index e384f3d..a3928f3 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/package-info.java
@@ -34,7 +34,7 @@
  * {@link org.apache.commons.rdf.api.Dataset}, e.g. using
  * {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory#asRDFTermGraph(org.eclipse.rdf4j.model.Model)}
  * or
- * {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository)}.
+ * {@link org.apache.commons.rdf.rdf4j.RDF4JTermFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
  * The returned adapted graph/dataset is directly mapped, so changes are
  * propagated both ways. For convenience, the marker interface
  * {@link org.apache.commons.rdf.rdf4j.RDF4JGraph} and


[4/7] incubator-commonsrdf git commit: Dataset pass on its salt to its constituent graphs

Posted by st...@apache.org.
Dataset pass on its salt to its constituent graphs


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

Branch: refs/heads/rdf4j
Commit: 62fe6b3843012c536ff25664773d542d3a7ac56e
Parents: 88c75a9
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 15:57:00 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 15:57:00 2016 +0100

----------------------------------------------------------------------
 .../rdf/rdf4j/impl/AbstractRepositoryGraphLike.java      | 11 +++++++----
 .../commons/rdf/rdf4j/impl/InternalRDF4JFactory.java     |  6 +++---
 .../commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java    | 11 +++++++----
 .../commons/rdf/rdf4j/impl/RepositoryGraphImpl.java      |  5 +++--
 4 files changed, 20 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
index a0c577f..6a1aae6 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/AbstractRepositoryGraphLike.java
@@ -18,6 +18,7 @@
 package org.apache.commons.rdf.rdf4j.impl;
 
 import java.util.Optional;
+import java.util.UUID;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
 import org.apache.commons.rdf.api.IRI;
@@ -37,17 +38,19 @@ abstract class AbstractRepositoryGraphLike<T extends TripleLike<BlankNodeOrIRI,
 	protected final boolean includeInferred;
 	protected final boolean handleInitAndShutdown;
 	protected final RDF4JTermFactory rdf4jTermFactory;
+	protected final UUID salt;
 
-	AbstractRepositoryGraphLike(Repository repository, boolean handleInitAndShutdown, boolean includeInferred) {
+	AbstractRepositoryGraphLike(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred) {
 		this.repository = repository;
+		this.salt = salt;
 		this.includeInferred = includeInferred;
 		this.handleInitAndShutdown = handleInitAndShutdown;
 		if (handleInitAndShutdown && !repository.isInitialized()) {
 			repository.initialize();
 		}
-		rdf4jTermFactory = new RDF4JTermFactory(repository.getValueFactory());
-	}
-
+		rdf4jTermFactory = new RDF4JTermFactory(repository.getValueFactory(), salt);
+	}	
+	
 	@Override
 	public void close() throws Exception {
 		if (handleInitAndShutdown) {

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
index 2a5fad5..fa4344f 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/InternalRDF4JFactory.java
@@ -45,7 +45,7 @@ import org.eclipse.rdf4j.repository.Repository;
  * {@link RDF4JTermFactory} methods like
  * {@link RDF4JTermFactory#createBlankNode()},
  * {@link RDF4JTermFactory#asRDFTerm(org.eclipse.rdf4j.model.Value)} and
- * {@link RDF4JTermFactory#asRDFTermGraph(Repository)}.
+ * {@link RDF4JTermFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
  * <p>
  * This class exists as a <code>public</code> bridge between the packages
  * {@link org.apache.commons.rdf.rdf4j} and
@@ -139,7 +139,7 @@ public abstract class InternalRDF4JFactory {
 	 */
 	public RDF4JDataset createRepositoryDatasetImpl(Repository repository, boolean handleInitAndShutdown,
 			boolean includeInferred) {
-		return new RepositoryDatasetImpl(repository, handleInitAndShutdown, includeInferred);
+		return new RepositoryDatasetImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred);
 	}
 
 	/**
@@ -164,7 +164,7 @@ public abstract class InternalRDF4JFactory {
 	 */
 	public RDF4JGraph createRepositoryGraphImpl(Repository repository, boolean handleInitAndShutdown,
 			boolean includeInferred, Resource... contextMask) {
-		return new RepositoryGraphImpl(repository, handleInitAndShutdown, includeInferred, contextMask);
+		return new RepositoryGraphImpl(repository, UUID.randomUUID(), handleInitAndShutdown, includeInferred, contextMask);
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
index 2efef42..64f3bbd 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryDatasetImpl.java
@@ -19,6 +19,7 @@ package org.apache.commons.rdf.rdf4j.impl;
 
 import java.util.ConcurrentModificationException;
 import java.util.Optional;
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
@@ -40,8 +41,8 @@ import org.eclipse.rdf4j.repository.RepositoryResult;
 
 class RepositoryDatasetImpl extends AbstractRepositoryGraphLike<Quad> implements RDF4JDataset, Dataset {
 
-	RepositoryDatasetImpl(Repository repository, boolean handleInitAndShutdown, boolean includeInferred) {
-		super(repository, handleInitAndShutdown, includeInferred);
+	RepositoryDatasetImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred) {
+		super(repository, salt, handleInitAndShutdown, includeInferred);
 	}
 
 	@Override
@@ -197,14 +198,16 @@ class RepositoryDatasetImpl extends AbstractRepositoryGraphLike<Quad> implements
 	@Override
 	public Graph getGraph() {
 		// default context only
-		return new RepositoryGraphImpl(repository, false, includeInferred, (Resource)null);
+		// NOTE: We carry over the 'salt' as the graph's BlankNode should be equal to our BlankNodes
+		return new RepositoryGraphImpl(repository, salt, false, includeInferred, (Resource)null);
 	}
 
 	@Override
 	public Optional<Graph> getGraph(BlankNodeOrIRI graphName) {
 		// NOTE: May be null to indicate default context
 		Resource context = (Resource) rdf4jTermFactory.asValue(graphName);
-		return Optional.of(new RepositoryGraphImpl(repository, false, includeInferred, context));
+		// NOTE: We carry over the 'salt' as the graph's BlankNode should be equal to our BlankNodes
+		return Optional.of(new RepositoryGraphImpl(repository, salt, false, includeInferred, context));
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/62fe6b38/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
index 52eda30..58eff70 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/impl/RepositoryGraphImpl.java
@@ -22,6 +22,7 @@ import java.util.ConcurrentModificationException;
 import java.util.HashSet;
 import java.util.Objects;
 import java.util.Set;
+import java.util.UUID;
 import java.util.stream.Stream;
 
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
@@ -45,8 +46,8 @@ class RepositoryGraphImpl extends AbstractRepositoryGraphLike<Triple> implements
 	
 	private final Resource[] contextMask;
 
-	RepositoryGraphImpl(Repository repository, boolean handleInitAndShutdown, boolean includeInferred, Resource... contextMask) {
-		super(repository, handleInitAndShutdown, includeInferred);
+	RepositoryGraphImpl(Repository repository, UUID salt, boolean handleInitAndShutdown, boolean includeInferred, Resource... contextMask) {
+		super(repository, salt, handleInitAndShutdown, includeInferred);
 		this.contextMask = Objects.requireNonNull(contextMask);
 	}
 


[7/7] incubator-commonsrdf git commit: javadoc and HTML ...

Posted by st...@apache.org.
javadoc and HTML ...


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

Branch: refs/heads/rdf4j
Commit: 3134a2d1d0df6f9228c9209edc2e9532cb755612
Parents: af598ff
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 16:00:07 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 16:00:07 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java  | 5 +++--
 .../java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java | 1 -
 2 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/3134a2d1/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
index 3e889a2..9079e99 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
@@ -65,9 +65,10 @@ public interface RDF4JGraph extends Graph, RDF4JGraphLike<Triple> {
 	 * Note that the context mask itself cannot be <code>null</code>.
 	 * <p>
 	 * The returned set is an immutable copy; to specify a different mask, use
-	 * {@link RDF4JTermFactory#asRDFTermGraph(Repository, Set, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
+	 * {@link RDF4JTermFactory#asRDFTermGraph(Repository, Set, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)}
 	 *
-	 * @return The context mask as a set of {@link BlankNodeOrIRI}s, which may contain the value null
+	 * @return The context mask as a set of {@link BlankNodeOrIRI} graph names, which
+	 *         may contain the value <code>null</code>.
 	 */
 	public Set<RDF4JBlankNodeOrIRI<Resource>> getContextMask();
 	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/3134a2d1/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
index 238122f..4d47e0c 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.util.Collections;
 import java.util.Set;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.rdf.api.AbstractGraphTest;
 import org.apache.commons.rdf.api.BlankNodeOrIRI;


[3/7] incubator-commonsrdf git commit: javadoc and code tidy

Posted by st...@apache.org.
javadoc and code tidy


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

Branch: refs/heads/rdf4j
Commit: 88c75a9ea47a634191b013c83658815bf6cc8ed0
Parents: 252f68c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 15:56:34 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 15:56:34 2016 +0100

----------------------------------------------------------------------
 .../apache/commons/rdf/rdf4j/RDF4JGraph.java    |  5 +-
 .../commons/rdf/rdf4j/RDF4JTermFactory.java     | 80 ++++++++++----------
 2 files changed, 43 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88c75a9e/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
index e419375..3e889a2 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
@@ -66,9 +66,8 @@ public interface RDF4JGraph extends Graph, RDF4JGraphLike<Triple> {
 	 * <p>
 	 * The returned set is an immutable copy; to specify a different mask, use
 	 * {@link RDF4JTermFactory#asRDFTermGraph(Repository, Set, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
-	 * 
-	 * @return The context mask as an set of {@link BlankNodeOrIRI}s, which may
-	 *         contain the value <code>null</code>.
+	 *
+	 * @return The context mask as a set of {@link BlankNodeOrIRI}s, which may contain the value null
 	 */
 	public Set<RDF4JBlankNodeOrIRI<Resource>> getContextMask();
 	

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/88c75a9e/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
index 0e5fdc6..737c53e 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
@@ -119,45 +119,6 @@ public final class RDF4JTermFactory implements RDFTermFactory {
 		 */
 		handleInitAndShutdown
 	}
-	
-	/**
-	 * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
-	 * <p>
-	 * The value will be of the same kind as the term, e.g. a
-	 * {@link org.eclipse.rdf4j.model.BNode} is converted to a
-	 * {@link org.apache.commons.rdf.api.BlankNode}, a
-	 * {@link org.eclipse.rdf4j.model.IRI} is converted to a
-	 * {@link org.apache.commons.rdf.api.IRI} and a
-	 * {@link org.eclipse.rdf4j.model.Literal}. is converted to a
-	 * {@link org.apache.commons.rdf.api.Literal}
-	 *
-	 * @param value
-	 *            The RDF4J {@link Value} to convert.
-	 * @param salt
-	 *            A {@link UUID} salt to use for uniquely mapping any
-	 *            {@link BNode}s. The salt should typically be the same for
-	 *            multiple statements in the same {@link Repository} or
-	 *            {@link Model} to ensure {@link BlankNode#equals(Object)} and
-	 *            {@link BlankNode#uniqueReference()} works as intended.
-	 * @param <T>
-	 *            The subclass of {@link Value}, e.g. {@link BNode}
-	 * @return A {@link RDFTerm} that corresponds to the RDF4J value
-	 * @throws IllegalArgumentException
-	 *             if the value is not a BNode, Literal or IRI
-	 */
-	@SuppressWarnings("unchecked")
-	public static <T extends Value> RDF4JTerm<T> asRDFTerm(final T value, UUID salt) {
-		if (value instanceof BNode) {
-			return (RDF4JTerm<T>) rdf4j.createBlankNodeImpl((BNode) value, salt);
-		}
-		if (value instanceof org.eclipse.rdf4j.model.Literal) {
-			return (RDF4JTerm<T>) rdf4j.createLiteralImpl((org.eclipse.rdf4j.model.Literal) value);
-		}
-		if (value instanceof org.eclipse.rdf4j.model.IRI) {
-			return (RDF4JTerm<T>) rdf4j.createIRIImpl((org.eclipse.rdf4j.model.IRI) value);
-		}
-		throw new IllegalArgumentException("Value is not a BNode, Literal or IRI: " + value.getClass());
-	}
 
 	private final UUID salt;
 
@@ -273,6 +234,45 @@ public final class RDF4JTermFactory implements RDFTermFactory {
 	public <T extends Value> RDF4JTerm<T> asRDFTerm(T value) {
 		return asRDFTerm(value, salt);
 	}
+	
+	/**
+	 * Adapt a RDF4J {@link Value} as a Commons RDF {@link RDFTerm}.
+	 * <p>
+	 * The value will be of the same kind as the term, e.g. a
+	 * {@link org.eclipse.rdf4j.model.BNode} is converted to a
+	 * {@link org.apache.commons.rdf.api.BlankNode}, a
+	 * {@link org.eclipse.rdf4j.model.IRI} is converted to a
+	 * {@link org.apache.commons.rdf.api.IRI} and a
+	 * {@link org.eclipse.rdf4j.model.Literal}. is converted to a
+	 * {@link org.apache.commons.rdf.api.Literal}
+	 *
+	 * @param value
+	 *            The RDF4J {@link Value} to convert.
+	 * @param salt
+	 *            A {@link UUID} salt to use for uniquely mapping any
+	 *            {@link BNode}s. The salt should typically be the same for
+	 *            multiple statements in the same {@link Repository} or
+	 *            {@link Model} to ensure {@link BlankNode#equals(Object)} and
+	 *            {@link BlankNode#uniqueReference()} works as intended.
+	 * @param <T>
+	 *            The subclass of {@link Value}, e.g. {@link BNode}
+	 * @return A {@link RDFTerm} that corresponds to the RDF4J value
+	 * @throws IllegalArgumentException
+	 *             if the value is not a BNode, Literal or IRI
+	 */
+	@SuppressWarnings("unchecked")
+	public static <T extends Value> RDF4JTerm<T> asRDFTerm(final T value, UUID salt) {
+		if (value instanceof BNode) {
+			return (RDF4JTerm<T>) rdf4j.createBlankNodeImpl((BNode) value, salt);
+		}
+		if (value instanceof org.eclipse.rdf4j.model.Literal) {
+			return (RDF4JTerm<T>) rdf4j.createLiteralImpl((org.eclipse.rdf4j.model.Literal) value);
+		}
+		if (value instanceof org.eclipse.rdf4j.model.IRI) {
+			return (RDF4JTerm<T>) rdf4j.createIRIImpl((org.eclipse.rdf4j.model.IRI) value);
+		}
+		throw new IllegalArgumentException("Value is not a BNode, Literal or IRI: " + value.getClass());
+	}	
 
 	/**
 	 * Adapt an RDF4J {@link Repository} as a Commons RDF {@link Dataset}.
@@ -602,4 +602,6 @@ public final class RDF4JTermFactory implements RDFTermFactory {
 		return opts;
 	}
 	
+	
+	
 }


[2/7] incubator-commonsrdf git commit: javadoc tweaks

Posted by st...@apache.org.
javadoc tweaks


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

Branch: refs/heads/rdf4j
Commit: 252f68c96b5daf1c26b88478ca4ede3e04767cd2
Parents: 850b29c
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 15:36:48 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 15:45:33 2016 +0100

----------------------------------------------------------------------
 .../java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java     | 4 +---
 .../main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java  | 6 +++---
 .../java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java | 9 ++++++---
 3 files changed, 10 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/252f68c9/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
index 262233e..b00ab39 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JDataset.java
@@ -31,14 +31,13 @@ import org.apache.commons.rdf.api.RDFTerm;
  * Marker interface for RDF4J implementations of Dataset.
  * 
  * @see RDF4JTermFactory#createDataset()
- * @see RDF4JTermFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository)
+ * @see RDF4JTermFactory#asRDFTermDataset(org.eclipse.rdf4j.repository.Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
  */
 public interface RDF4JDataset extends Dataset, RDF4JGraphLike<Quad> {
 	
 	/**
 	 * {@inheritDoc}
 	 * <p>
-	 * <p>
 	 * Note that for datasets backed by a repository ({@link #asRepository()} is
 	 * present), the stream <strong>must be closed</strong> with
 	 * {@link Stream#close()}.
@@ -76,7 +75,6 @@ public interface RDF4JDataset extends Dataset, RDF4JGraphLike<Quad> {
 	/**
 	 * {@inheritDoc}
 	 * <p>
-	 * <p>
 	 * Note that for datasets backed by a repository ({@link #asRepository()} is
 	 * present), the stream <strong>must be closed</strong> with
 	 * {@link Stream#close()}.

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/252f68c9/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
index 6425758..e419375 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JGraph.java
@@ -36,8 +36,8 @@ import org.eclipse.rdf4j.repository.Repository;
  * 
  * @see RDF4JTermFactory#createGraph()
  * @see RDF4JTermFactory#asRDFTermGraph(Model)
- * @see RDF4JTermFactory#asRDFTermGraph(Repository)
- * @see RDF4JTermFactory#asRDFTermGraphUnion(Repository)
+ * @see RDF4JTermFactory#asRDFTermGraph(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
+ * @see RDF4JTermFactory#asRDFTermGraphUnion(Repository, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
  * @see RDF4JDataset#getGraph()
  * @see RDF4JDataset#getGraph(BlankNodeOrIRI)
  */
@@ -65,7 +65,7 @@ public interface RDF4JGraph extends Graph, RDF4JGraphLike<Triple> {
 	 * Note that the context mask itself cannot be <code>null</code>.
 	 * <p>
 	 * The returned set is an immutable copy; to specify a different mask, use
-	 * {@link RDF4JTermFactory#asRDFTermGraph(Repository, Set)}.
+	 * {@link RDF4JTermFactory#asRDFTermGraph(Repository, Set, org.apache.commons.rdf.rdf4j.RDF4JTermFactory.Option...)
 	 * 
 	 * @return The context mask as an set of {@link BlankNodeOrIRI}s, which may
 	 *         contain the value <code>null</code>.

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/252f68c9/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
index 2456714..0e5fdc6 100644
--- a/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
+++ b/rdf4j/src/main/java/org/apache/commons/rdf/rdf4j/RDF4JTermFactory.java
@@ -67,8 +67,9 @@ import org.eclipse.rdf4j.sail.memory.MemoryStore;
  * To use other models, see {@link #asRDFTermGraph(Model)}.
  * <p>
  * To adapt a RDF4J {@link Repository} as a {@link Dataset} or {@link Graph},
- * use {@link #asRDFTermDataset(Repository)} or
- * {@link #asRDFTermGraph(Repository)}.
+ * use {@link #asRDFTermDataset(Repository, Option...)} 
+ * or 
+ * {@link #asRDFTermGraph(Repository, Option...)}.
  * <p>
  * {@link #asTriple(Statement)} can be used to convert a RDF4J {@link Statement}
  * to a Commons RDF {@link Triple}, and equivalent {@link #asQuad(Statement)} to
@@ -92,7 +93,9 @@ import org.eclipse.rdf4j.sail.memory.MemoryStore;
  * the same {@link BNode#getID()}, converting them with the above methods might
  * cause accidental {@link BlankNode} equivalence. Note that the {@link Graph}
  * and {@link Dataset} adapter methods like
- * {@link #asRDFTermDataset(Repository)} and {@link #asRDFTermGraph(Model)}
+ * {@link #asRDFTermDataset(Repository, Option...)}
+ * and 
+ * {@link #asRDFTermGraph(Repository, Option...)}
  * therefore uses a unique {@link RDF4JTermFactory} internally.
  *
  */


[6/7] incubator-commonsrdf git commit: Fail if more than 15 seconds

Posted by st...@apache.org.
Fail if more than 15 seconds


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

Branch: refs/heads/rdf4j
Commit: af598ff3dcd37fdaf33d2211574444338936c163
Parents: 0f8ef7a
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Fri Oct 7 15:57:30 2016 +0100
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Fri Oct 7 15:58:26 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/rdf4j/NativeStoreGraphTest.java   | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/af598ff3/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
----------------------------------------------------------------------
diff --git a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
index aed763b..238122f 100644
--- a/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
+++ b/rdf4j/src/test/java/org/apache/commons/rdf/rdf4j/NativeStoreGraphTest.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.UncheckedIOException;
 import java.util.Collections;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.rdf.api.AbstractGraphTest;
 import org.apache.commons.rdf.api.BlankNodeOrIRI;
@@ -36,6 +37,7 @@ import org.eclipse.rdf4j.sail.nativerdf.NativeStore;
 import org.junit.After;
 import org.junit.Rule;
 import org.junit.rules.TemporaryFolder;
+import org.junit.rules.Timeout;
 
 
 /**
@@ -90,7 +92,6 @@ public class NativeStoreGraphTest extends AbstractGraphTest {
 	private SailRepository repository;
 	
 	public void createRepository() throws IOException {
-		System.out.println("Oh");
 		Sail sail = new NativeStore(tempDir.newFolder());
 		repository = new SailRepository(sail);
 		repository.initialize();
@@ -107,13 +108,24 @@ public class NativeStoreGraphTest extends AbstractGraphTest {
 		return repository;
 	}
 	
+	@Rule
+	/**
+	 * A timeout of more than 15 seconds pr test indicates typically that
+	 * shutdownAndDelete failed.
+	 */
+	public Timeout globalTimeout = Timeout.seconds(15);
+	
 	@After
 	public void shutdownAndDelete() throws IOException {
 		// must shutdown before we delete
 		if (repository != null) {
-			System.out.println("Shutting down rdf4j repository " + repository);
+			System.out.print("Shutting down rdf4j repository " + repository + "...");
+			// NOTE: 
+			// If this takes about 20 seconds it means the code forgot to close a
+			// RepositoryConnection or RespositoryResult
+			// e.g. missing a try-with-resources block
 			repository.shutDown();
-			System.out.println("rdf4j repository shut down.");
+			System.out.println("OK");
 		}
 	}