commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [06/50] incubator-commonsrdf git commit: fromJena(Graph) now uses factory salt
Date Fri, 07 Oct 2016 14:23:00 GMT
fromJena(Graph) now uses factory salt


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

Branch: refs/heads/rdf4j
Commit: 20c7ad3b391f6a0a4126e74dc3166b74de4fa0ee
Parents: 3a09004
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Jul 8 16:44:36 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Jul 8 16:44:36 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jena/JenaRDFTermFactory.java    | 45 ++++++++++++++++----
 .../jena/TestJenaGraphToCommonsRDFGraph.java    |  2 +-
 2 files changed, 38 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/20c7ad3b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
index 78dc5f7..6560894 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/JenaRDFTermFactory.java
@@ -414,7 +414,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	}
 
 	/**
-	 * Adapt an existing Jena Quad to CommonsRDF {@link Quad}.
+	 * Adapt an existing Jena {@link org.apache.jena.sparql.core.Quad} to CommonsRDF {@link
Quad}.
 	 * <p>
 	 * If the quad contains any {@link Node#isBlank()}, then any corresponding
 	 * {@link BlankNode} will use a {@link UUID} salt from this 
@@ -431,7 +431,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	}
 	
 	/**
-	 * Adapt an existing Jena Quad to CommonsRDF {@link Quad}.
+	 * Adapt an existing Jena {@link org.apache.jena.sparql.core.Quad} to CommonsRDF {@link
Quad}.
 	 * <p>
 	 * If the quad contains any {@link Node#isBlank()}, then any corresponding
 	 * {@link BlankNode} will use the provided {@link UUID} salt
@@ -449,17 +449,46 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	}
 
 	/**
-	 * Adapt an existing Jena Graph to CommonsRDF {@link Graph}. This does not
+	 * Adapt an existing Jena {@link org.apache.jena.graph.Graph} to CommonsRDF {@link Graph}.

+	 * <p>
+	 * This does not
 	 * take a copy, changes to the CommonsRDF Graph are reflected in the jena
-	 * graph.
+	 * graph, which is accessible from {@link JenaGraph#asJenaGraph()}.
+	 * <p>
+	 * If the graph contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use a {@link UUID} salt from this 
+	 * {@link JenaRDFTermFactory} instance
+	 * in combination with {@link Node#getBlankNodeId()} 
+	 * for the purpose of its {@link BlankNode#uniqueReference()}.
+
 	 */
-	public static Graph fromJena(org.apache.jena.graph.Graph graph) {
-		// NOTE: This generates a new UUID salt per graph
-		return JenaFactory.fromJena(graph);
+	public Graph fromJena(org.apache.jena.graph.Graph graph) {
+		return JenaFactory.fromJena(graph, salt);
 	}
+
 	
 
+	/**
+	 * Adapt an existing Jena {@link org.apache.jena.graph.Graph} to CommonsRDF {@link Graph}.

+	 * <p>
+	 * This does not
+	 * take a copy, changes to the CommonsRDF Graph are reflected in the jena
+	 * graph, which is accessible from {@link JenaGraph#asJenaGraph()}.
+	 * <p>
+	 * If the graph contains any {@link Node#isBlank()}, then any corresponding
+	 * {@link BlankNode} will use the provided {@link UUID} salt
+	 * in combination with {@link Node#getBlankNodeId()} 
+	 * for the purpose of its {@link BlankNode#uniqueReference()}.
+	 * 
+	 * @param graph Jena graph to adapt
+	 * @param salt A {@link UUID} salt for adapting any {@link BlankNode}s
+	 * @return Adapted graph 
+	 */
+	public static JenaGraph fromJena(org.apache.jena.graph.Graph graph, UUID salt) {
+		return JenaFactory.fromJena(graph, salt);
+	}
 
+	
 	/**
 	 * Convert from Jena to any RDFCommons implementation. This is a copy, even
 	 * if the factory is a RDFTermFactoryJena. Use
@@ -468,7 +497,7 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	public static Graph fromJena(RDFTermFactory factory, org.apache.jena.graph.Graph graph)
{
 		if (factory instanceof JenaRDFTermFactory) {
 			// No need to convert, just wrap
-			return fromJena(graph);
+			return ((JenaRDFTermFactory)factory).fromJena(graph);
 		}
 
 		Graph g = factory.createGraph();

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/20c7ad3b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
----------------------------------------------------------------------
diff --git a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
index c81a8b1..2668343 100644
--- a/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
+++ b/jena/src/test/java/org/apache/commons/rdf/jena/TestJenaGraphToCommonsRDFGraph.java
@@ -56,7 +56,7 @@ public class TestJenaGraphToCommonsRDFGraph {
         RDFDataMgr.read(jGraph, turtleFile.toUri().toString()) ;
         
         // "graph" is a CommonsRDF graph 
-        Graph graph = JenaRDFTermFactory.fromJena(jGraph) ;
+        Graph graph = new JenaRDFTermFactory().fromJena(jGraph) ;
         
         // Add to CommonsRDF Graph
         RDFTermFactory rft = new JenaRDFTermFactory() ;


Mime
View raw message