You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2024/09/10 08:05:31 UTC
(jena) branch main updated (73699fc1b1 -> 3143309c2e)
This is an automated email from the ASF dual-hosted git repository.
andy pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
from 73699fc1b1 GH-2673: [ontapi] OntDisjoints - require more than one member (for EL, QL, RL)
new 22c7b64238 rdfdiff: Use a same-term model
new 3143309c2e Clear-up same-term/same-value graphs for the Model API.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/jena/sparql/graph/GraphFactory.java | 10 ++--
jena-cmds/src/main/java/arq/rdfdiff.java | 6 ++-
.../org/apache/jena/graph/GraphMemFactory.java | 19 ++++---
.../org/apache/jena/rdf/model/ModelFactory.java | 60 ++++++++++++++--------
.../apache/jena/fuseki/system/GraphLoadUtils.java | 4 +-
5 files changed, 64 insertions(+), 35 deletions(-)
(jena) 02/02: Clear-up same-term/same-value graphs for the Model API.
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
commit 3143309c2e3b003258b6d763edaf0fde0ffa31b7
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Mon Sep 9 21:28:18 2024 +0100
Clear-up same-term/same-value graphs for the Model API.
---
.../org/apache/jena/sparql/graph/GraphFactory.java | 10 ++--
.../org/apache/jena/graph/GraphMemFactory.java | 19 ++++---
.../org/apache/jena/rdf/model/ModelFactory.java | 60 ++++++++++++++--------
.../apache/jena/fuseki/system/GraphLoadUtils.java | 4 +-
4 files changed, 60 insertions(+), 33 deletions(-)
diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphFactory.java b/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphFactory.java
index 12d0127dae..f3442f57ac 100644
--- a/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphFactory.java
+++ b/jena-arq/src/main/java/org/apache/jena/sparql/graph/GraphFactory.java
@@ -61,7 +61,7 @@ public class GraphFactory {
* @see #createDefaultGraph
*/
public static Graph createGraphMem() {
- return GraphMemFactory.createGraphMem();
+ return GraphMemFactory.createDefaultGraphSameTerm();
}
/**
@@ -76,14 +76,18 @@ public class GraphFactory {
return new GraphTxn();
}
- /** Create a graph - ARQ-wide default type */
+ /**
+ * Create a graph - ARQ-wide default type.
+ *
+ * In Jena5, this is "same-term"
+ */
public static Graph createDefaultGraph() {
// Normal usage is SystemARQ.UsePlainGraph = false and use
// createJenaDefaultGraph
return SystemARQ.UsePlainGraph ? createPlainGraph() : createJenaDefaultGraph();
}
- /** Create a graph - always the Jena default graph type */
+ /** Create a graph - the Jena default graph for ARQ and RIOT */
public static Graph createJenaDefaultGraph() {
return GraphMemFactory.createDefaultGraph();
}
diff --git a/jena-core/src/main/java/org/apache/jena/graph/GraphMemFactory.java b/jena-core/src/main/java/org/apache/jena/graph/GraphMemFactory.java
index d14ee93658..388c74e0ff 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/GraphMemFactory.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/GraphMemFactory.java
@@ -98,12 +98,13 @@ public class GraphMemFactory
}
/**
- * This function will track the preferred general purpose graph.
- * It will switch from "same value" to "same term"
+ * This function will track the preferred general purpose graph for the Model API.
*/
- @SuppressWarnings("deprecation")
- public static Graph createGraphMem()
- { return new org.apache.jena.mem.GraphMem(); }
+ public static Graph createGraphMem() {
+ @SuppressWarnings("deprecation")
+ Graph g = new org.apache.jena.mem.GraphMem();
+ return g;
+ }
/**
* Answer a memory-based graph with "same value" semantics
@@ -111,9 +112,11 @@ public class GraphMemFactory
* Jena5 changed to "same term" semantics.
* This method will continue to provide a "same value" graph.
*/
- @SuppressWarnings("deprecation")
- public static Graph createDefaultGraphSameValue()
- { return new org.apache.jena.mem.GraphMem(); }
+ public static Graph createDefaultGraphSameValue() {
+ @SuppressWarnings("deprecation")
+ Graph g = new org.apache.jena.mem.GraphMem();
+ return g;
+ }
/**
* Answer a memory-based graph with "same term" semantics
diff --git a/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java b/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
index ca281faa3a..af03920bac 100644
--- a/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
+++ b/jena-core/src/main/java/org/apache/jena/rdf/model/ModelFactory.java
@@ -62,8 +62,9 @@ public class ModelFactory extends ModelFactoryBase
roots in a description, and <code>assemblerModelFrom(Resource)</code>
for assembling a model from its single description.
*/
- public static Model assembleModelFrom( Model singleRoot )
- { return assembleModelFrom( AssemblerHelp.singleModelRoot( singleRoot ) ); }
+ public static Model assembleModelFrom(Model singleRoot) {
+ return assembleModelFrom(AssemblerHelp.singleModelRoot(singleRoot));
+ }
/**
Answer a Set of resources present in <code>m</code> that are
@@ -73,8 +74,9 @@ public class ModelFactory extends ModelFactoryBase
their <code>getModel()</code> - they may be members of an
extended constructed model.
*/
- public static Set<Resource> findAssemblerRoots( Model m )
- { return AssemblerHelp.findAssemblerRoots( m ); }
+ public static Set<Resource> findAssemblerRoots(Model m) {
+ return AssemblerHelp.findAssemblerRoots(m);
+ }
/**
Answer a Model as described the Assembler specification rooted
@@ -82,14 +84,35 @@ public class ModelFactory extends ModelFactoryBase
must be of rdf:type <code>ja:Object</code>, where <code>ja</code>
is the prefix of Jena Assembler objects.
*/
- public static Model assembleModelFrom( Resource root )
- { return Assembler.general.openModel( root ); }
+ public static Model assembleModelFrom(Resource root) {
+ return Assembler.general.openModel(root);
+ }
/**
- Answer a fresh Model with the default specification.
- */
- public static Model createDefaultModel()
- { return new ModelCom( GraphMemFactory.createGraphMem( ) ); }
+ * Answer a fresh Model for use with the Model API.
+ * <p>
+ * This model is "same value" for Model API compatibility.
+ *
+ * @see #createModelSameTerm() for a same-term equality Model.
+ */
+ public static Model createDefaultModel() {
+ return createModelForGraph(GraphMemFactory.createDefaultGraphSameValue());
+ }
+
+ /**
+ * Answer a fresh Model with "same term" semantics.
+ */
+ public static Model createModelSameTerm() {
+ return createModelForGraph(GraphMemFactory.createDefaultGraphSameTerm());
+ }
+
+ /**
+ * Answer a fresh Model with "same value" semantics.
+ */
+ public static Model createModelSameValue() {
+ return createModelForGraph(GraphMemFactory.createDefaultGraphSameValue());
+ }
+
/**
Answer a model that encapsulates the given graph. Existing prefixes are
@@ -143,7 +166,7 @@ public class ModelFactory extends ModelFactoryBase
* Build an inferred model by attaching the given RDF model to the given reasoner.
*
* @param reasoner the reasoner to use to process the data
- * @param model the Model containing both instance data and schema assertions to be inferenced over,
+ * @param model the Model containing both instance data and schema assertions to be inferenced over,
* any statements added to the InfModel will be added to this underlying data model.
*/
public static InfModel createInfModel( Reasoner reasoner, Model model ) {
@@ -201,7 +224,6 @@ public class ModelFactory extends ModelFactoryBase
return createOntologyModel( ProfileRegistry.OWL_LANG );
}
-
/**
* <p>
* Answer a new ontology model which will process in-memory models of
@@ -218,7 +240,6 @@ public class ModelFactory extends ModelFactoryBase
return createOntologyModel( OntModelSpec.getDefaultSpec( languageURI ), null );
}
-
/**
* <p>
* Answer a new ontology model which will process in-memory models of
@@ -242,7 +263,6 @@ public class ModelFactory extends ModelFactoryBase
return createOntologyModel( _spec, base );
}
-
/**
* <p>
* Answer a new ontology model, constructed according to the given ontology model specification,
@@ -263,9 +283,9 @@ public class ModelFactory extends ModelFactoryBase
* Answer a new ontology model constructed according to the specification, which includes
* a ModelMaker which will create the necessary base model.
*/
- public static OntModel createOntologyModel( OntModelSpec spec )
- { return new OntModelImpl( spec ); }
-
+ public static OntModel createOntologyModel(OntModelSpec spec) {
+ return new OntModelImpl(spec);
+ }
/**
Answer a new model that is the dynamic union of two other models. By
@@ -278,7 +298,7 @@ public class ModelFactory extends ModelFactoryBase
<p>
<code>createUnion</code> only creates two-element unions.
*/
- public static Model createUnion(Model m1, Model m2)
- { return createModelForGraph( new Union( m1.getGraph(), m2.getGraph() ) ); }
-
+ public static Model createUnion(Model m1, Model m2) {
+ return createModelForGraph(new Union(m1.getGraph(), m2.getGraph()));
}
+}
diff --git a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/GraphLoadUtils.java b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/GraphLoadUtils.java
index 79d9e22498..f097501376 100644
--- a/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/GraphLoadUtils.java
+++ b/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/system/GraphLoadUtils.java
@@ -35,7 +35,7 @@ public class GraphLoadUtils
// ---- Model level
public static Model readModel(String uri, int limit) {
- Graph g = GraphMemFactory.createGraphMem();
+ Graph g = GraphMemFactory.createDefaultGraphSameTerm();
readUtil(g, uri, limit);
return ModelFactory.createModelForGraph(g);
}
@@ -48,7 +48,7 @@ public class GraphLoadUtils
// ---- Graph level
public static Graph readGraph(String uri, int limit) {
- Graph g = GraphMemFactory.createGraphMem();
+ Graph g = GraphMemFactory.createDefaultGraphSameTerm();
readUtil(g, uri, limit);
return g;
}
(jena) 01/02: rdfdiff: Use a same-term model
Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/jena.git
commit 22c7b64238511b9ad26691d406e27c501920686b
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Mon Sep 9 21:23:38 2024 +0100
rdfdiff: Use a same-term model
---
jena-cmds/src/main/java/arq/rdfdiff.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/jena-cmds/src/main/java/arq/rdfdiff.java b/jena-cmds/src/main/java/arq/rdfdiff.java
index de1a9ba090..077b1aacc0 100644
--- a/jena-cmds/src/main/java/arq/rdfdiff.java
+++ b/jena-cmds/src/main/java/arq/rdfdiff.java
@@ -31,6 +31,7 @@ import java.util.Set;
import java.util.TreeSet;
import java.io.FileInputStream;
+import org.apache.jena.graph.GraphMemFactory;
import org.apache.jena.rdf.model.*;
import org.apache.jena.sparql.util.Closure;
@@ -93,8 +94,9 @@ public class rdfdiff extends java.lang.Object {
//System.out.println(in1 + " " + in2 + " " + lang1 + " " + lang2 + " " + base1 + " " + base2);
try {
- Model m1 = ModelFactory.createDefaultModel();
- Model m2 = ModelFactory.createDefaultModel();
+ // Term-equality.
+ Model m1 = ModelFactory.createModelForGraph(GraphMemFactory.createDefaultGraphSameTerm());
+ Model m2 = ModelFactory.createModelForGraph(GraphMemFactory.createDefaultGraphSameTerm());
read(m1, in1, lang1, base1);
read(m2, in2, lang2, base2);