commonsrdf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [10/50] incubator-commonsrdf git commit: Added fromJena(DatasetGraph)
Date Fri, 07 Oct 2016 14:22:23 GMT
Added fromJena(DatasetGraph)


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

Branch: refs/heads/master
Commit: d912b6bf0d81a190bcb4eb3792c08750f39b95dc
Parents: 20c7ad3
Author: Stian Soiland-Reyes <stain@apache.org>
Authored: Fri Jul 8 16:49:06 2016 +0100
Committer: Stian Soiland-Reyes <stain@apache.org>
Committed: Fri Jul 8 16:49:06 2016 +0100

----------------------------------------------------------------------
 .../commons/rdf/jena/JenaRDFTermFactory.java    | 43 +++++++++++++++++++-
 .../commons/rdf/jena/impl/JenaFactory.java      |  9 ++++
 2 files changed, 50 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d912b6bf/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 6560894..d8e41b1 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
@@ -44,6 +44,7 @@ import org.apache.jena.riot.Lang;
 import org.apache.jena.riot.RDFLanguages;
 import org.apache.jena.riot.system.StreamRDF;
 import org.apache.jena.riot.system.StreamRDFBase;
+import org.apache.jena.sparql.core.DatasetGraph;
 import org.apache.jena.sparql.graph.GraphFactory;
 
 /**
@@ -462,11 +463,10 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 	 * for the purpose of its {@link BlankNode#uniqueReference()}.
 
 	 */
-	public Graph fromJena(org.apache.jena.graph.Graph graph) {
+	public JenaGraph 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}.

@@ -488,6 +488,45 @@ public final class JenaRDFTermFactory implements RDFTermFactory {
 		return JenaFactory.fromJena(graph, salt);
 	}
 
+	/**
+	 * Adapt an existing Jena {@link DatasetGraph} to CommonsRDF {@link Dataset}. 
+	 * <p>
+	 * This does not
+	 * take a copy, changes to the CommonsRDF Dataset are reflected in the jena
+	 * dataset graph, which is accessible from {@link JenaDataset#asJenaDatasetGraph()}.
+	 * <p>
+	 * If the dataset 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()}.
+	 * 
+	 * @param datasetGraph Jena dataset graph to adapt
+	 * @return Adapted dataset 
+	 */
+	public JenaDataset fromJena(DatasetGraph datasetGraph) {
+		return JenaFactory.fromJena(datasetGraph, salt);
+	}	
+	
+	/**
+	 * Adapt an existing Jena {@link DatasetGraph} to CommonsRDF {@link Dataset}. 
+	 * <p>
+	 * This does not
+	 * take a copy, changes to the CommonsRDF Dataset are reflected in the jena
+	 * dataset graph, which is accessible from {@link JenaDataset#asJenaDatasetGraph()}.
+	 * <p>
+	 * If the dataset 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 datasetGraph Jena dataset graph to adapt
+	 * @param salt A {@link UUID} salt for adapting any {@link BlankNode}s
+	 * @return Adapted dataset 
+	 */
+	public static JenaDataset fromJena(DatasetGraph datasetGraph, UUID salt) {
+		return JenaFactory.fromJena(datasetGraph, salt);
+	}	
 	
 	/**
 	 * Convert from Jena to any RDFCommons implementation. This is a copy, even

http://git-wip-us.apache.org/repos/asf/incubator-commonsrdf/blob/d912b6bf/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
----------------------------------------------------------------------
diff --git a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
index da24277..1832232 100644
--- a/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
+++ b/jena/src/main/java/org/apache/commons/rdf/jena/impl/JenaFactory.java
@@ -30,6 +30,7 @@ import org.apache.commons.rdf.api.RDFTerm;
 import org.apache.commons.rdf.jena.ConversionException;
 import org.apache.commons.rdf.jena.JenaAny;
 import org.apache.commons.rdf.jena.JenaBlankNode;
+import org.apache.commons.rdf.jena.JenaDataset;
 import org.apache.commons.rdf.jena.JenaGraph;
 import org.apache.commons.rdf.jena.JenaIRI;
 import org.apache.commons.rdf.jena.JenaLiteral;
@@ -150,6 +151,14 @@ public class JenaFactory {
 		return new GraphImpl(graph, salt);
 	}
 
+	public static JenaDataset fromJena(DatasetGraph datasetGraph) {
+		return new DatasetImpl(datasetGraph, UUID.randomUUID());
+	}
+
+	public static JenaDataset fromJena(DatasetGraph datasetGraph, UUID salt) {
+		return new DatasetImpl(datasetGraph, salt);
+	}
+	
 	public static JenaTriple fromJena(org.apache.jena.graph.Triple triple, UUID salt) {
 		return new TripleImpl(triple, salt);
 	}


Mime
View raw message