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
The following commit(s) were added to refs/heads/main by this push:
new 143fbaad73 GH-2487: add OntModel#writeAll; add more OntModel builtins
accessors; add OntProperty#addSubProperty & OntProperty#removeSubProperty &
OntClass#removeSubClass
143fbaad73 is described below
commit 143fbaad73bfa81c5c173c18a38291e336c8d572
Author: sszuev <[email protected]>
AuthorDate: Sat Jun 1 11:32:53 2024 +0300
GH-2487: add OntModel#writeAll; add more OntModel builtins accessors; add
OntProperty#addSubProperty & OntProperty#removeSubProperty &
OntClass#removeSubClass
---
.../apache/jena/ontapi/impl/OntGraphModelImpl.java | 24 +++
.../java/org/apache/jena/ontapi/model/IOModel.java | 179 +++++++++++++++++++++
.../jena/ontapi/model/OntAnnotationProperty.java | 21 +++
.../org/apache/jena/ontapi/model/OntClass.java | 16 ++
.../apache/jena/ontapi/model/OntDataProperty.java | 21 +++
.../org/apache/jena/ontapi/model/OntModel.java | 20 +++
.../jena/ontapi/model/OntObjectProperty.java | 23 ++-
.../org/apache/jena/ontapi/model/OntProperty.java | 18 ++-
.../jena/ontapi/OntAnnotationPropertyTest.java | 79 +++++++++
.../org/apache/jena/ontapi/OntClassMiscTest.java | 27 ++--
.../apache/jena/ontapi/OntDataPropertyTest.java | 22 +++
.../org/apache/jena/ontapi/OntModelMiscTest.java | 31 ++++
.../apache/jena/ontapi/OntModelOWLSpecsTest.java | 46 +++++-
.../apache/jena/ontapi/OntModelRDFSSpecTest.java | 26 +++
.../apache/jena/ontapi/OntObjectPropertyTest.java | 21 +++
.../org/apache/jena/ontapi/OntPropertyTest.java | 30 ----
16 files changed, 559 insertions(+), 45 deletions(-)
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
index d88d89596a..7cfa1d4d23 100644
---
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
+++
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/impl/OntGraphModelImpl.java
@@ -1534,6 +1534,30 @@ public class OntGraphModelImpl extends ModelCom
implements OntModel, OntEnhGraph
return this;
}
+ @Override
+ public OntModel writeAll(Writer writer, String lang, String base) {
+ super.write(writer, lang, base);
+ return this;
+ }
+
+ @Override
+ public OntModel writeAll(Writer writer, String lang) {
+ super.write(writer, lang);
+ return this;
+ }
+
+ @Override
+ public OntModel writeAll(OutputStream out, String lang, String base) {
+ super.write(out, lang, base);
+ return this;
+ }
+
+ @Override
+ public OntModel writeAll(OutputStream out, String lang) {
+ super.write(out, lang);
+ return this;
+ }
+
@Override
public OntAnnotationProperty getRDFSComment() {
return findNodeAs(RDFS.Nodes.comment, OntAnnotationProperty.class);
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java
index 4d23fdc793..cdf331c20c 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/IOModel.java
@@ -55,22 +55,201 @@ interface IOModel<R extends Model> extends Model {
@Override
R read(String url, String base, String lang);
+ /**
+ * Writes a serialized representation of a model in a specified language.
+ * <strong>Note(1):</strong> this method is adapted for the ontology
+ * model to write out only the base model (which contains the asserted
data).
+ * To write all triples, including imported data and inferred triples, use
+ * {@link #writeAll(Writer, String, String) writeAll }.
+ * <strong>Note(2):</strong> it is often better to use an {@code
OutputStream} rather than a {@code Writer},
+ * since this will avoid character encoding errors.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param writer the output writer
+ * @return this model
+ */
@Override
R write(Writer writer);
+ /**
+ * Writes a serialized representation of a model in a specified language.
+ * <strong>Note(1):</strong> this method is adapted for the ontology
+ * model to write out only the base model (which contains the asserted
data).
+ * To write all triples, including imported data and inferred triples, use
+ * {@link #writeAll(Writer, String) writeAll }.
+ * <strong>Note(2):</strong> it is often better to use an {@code
OutputStream} rather than a {@code Writer},
+ * since this will avoid character encoding errors.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param writer the output writer
+ * @param lang the language in which the RDF should be written
+ * @return this model
+ */
@Override
R write(Writer writer, String lang);
+ /**
+ * Writes a serialized representation of a model in a specified language.
+ * <strong>Note(1):</strong> this method is adapted for the ontology
+ * model to write out only the base model (which contains the asserted
data).
+ * To write all triples, including imported data and inferred triples, use
+ * {@link #writeAll(Writer, String, String) writeAll }.
+ * <strong>Note(2):</strong> it is often better to use an {@code
OutputStream} rather than a {@code Writer},
+ * since this will avoid character encoding errors.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param writer the output writer
+ * @param lang the language in which the RDF should be written
+ * @param base the base URI for relative URI calculations;
+ * {@code null} means use only absolute URI's.
+ * @return this model
+ */
@Override
R write(Writer writer, String lang, String base);
+ /**
+ * Writes a serialized representation of a model in a specified language.
+ * <strong>Note:</strong> this method is adapted for the ontology
+ * model to write out only the base model (which contains the asserted
data).
+ * To write all triples, including imported data and inferred triples, use
+ * {@link #writeAll(OutputStream, String, String) writeAll }.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param out tre output stream to which the RDF is written
+ * @return this model
+ */
@Override
R write(OutputStream out);
+ /**
+ * Writes a serialized representation of a model in a specified language.
+ * <strong>Note:</strong> this method is adapted for the ontology
+ * model to write out only the base model (which contains the asserted
data).
+ * To write all triples, including imported data and inferred triples, use
+ * {@link #writeAll(OutputStream, String) writeAll }.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param out tre output stream to which the RDF is written
+ * @param lang the language in which the RDF should be written
+ * @return this model
+ */
@Override
R write(OutputStream out, String lang);
+ /**
+ * Writes a serialized representation of a model in a specified language.
+ * <strong>Note:</strong> this method is adapted for the ontology
+ * model to write out only the base model (which contains the asserted
data).
+ * To write all triples, including imported data and inferred triples, use
+ * {@link #writeAll(OutputStream, String, String) writeAll }.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param out tre output stream to which the RDF is written
+ * @param lang the language in which the RDF should be written
+ * @param base the base URI for relative URI calculations;
+ * {@code null} means use only absolute URI's.
+ * @return this model
+ */
@Override
R write(OutputStream out, String lang, String base);
+ /**
+ * Writes a serialized representation of all the model's contents,
+ * including inferred statements and statements imported from other
documents.
+ * To write only the data asserted in the base model, use
+ * {@link #write(Writer, String, String) write}.
+ * <strong>Note:</strong> it is often better to use an {@code
OutputStream} rather than a {@code Writer},
+ * since this will avoid character encoding errors.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param writer the output writer
+ * @param lang the language in which the RDF should be written
+ * @param base the base URI for relative URI calculations;
+ * {@code null} means use only absolute URI's.
+ * @return this model
+ */
+ R writeAll(Writer writer, String lang, String base);
+
+ /**
+ * Writes a serialized representation of all the model's contents,
+ * including inferred statements and statements imported from other
documents.
+ * To write only the data asserted in the base model, use
+ * {@link #write(Writer, String) write}.
+ * <strong>Note:</strong> it is often better to use an {@code
OutputStream} rather than a {@code Writer},
+ * since this will avoid character encoding errors.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param writer the output writer
+ * @param lang the language in which the RDF should be written
+ * @return this model
+ */
+ R writeAll(Writer writer, String lang);
+
+ /**
+ * Writes a serialized representation of all the model's contents,
+ * including inferred statements and statements imported from other
documents.
+ * To write only the data asserted in the base model, use
+ * {@link #write(OutputStream, String, String) write}.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param out tre output stream to which the RDF is written
+ * @param lang the language in which the RDF should be written
+ * @param base the base URI for relative URI calculations;
+ * {@code null} means use only absolute URI's.
+ * @return this model
+ */
+ R writeAll(OutputStream out, String lang, String base);
+
+ /**
+ * Writes a serialized representation of all the model's contents,
+ * including inferred statements and statements imported from other
documents.
+ * To write only the data asserted in the base model, use
+ * {@link #write(OutputStream, String) write}.
+ * <p>
+ * The language in which to write the model is specified by the {@code
lang} argument.
+ * Some of the supported formats are "RDF/XML", "RDF/XML-ABBREV",
"N-TRIPLE", "TURTLE".
+ * See {@link org.apache.jena.riot.Lang Lang} for all supported formats.
+ * The default value, represented by {@code null}, is "RDF/XML".
+ *
+ * @param out tre output stream to which the RDF is written
+ * @param lang the language in which the RDF should be written
+ * @return this model
+ */
+ R writeAll(OutputStream out, String lang);
}
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntAnnotationProperty.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntAnnotationProperty.java
index 9f227fbb1f..30e44f66b0 100644
---
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntAnnotationProperty.java
+++
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntAnnotationProperty.java
@@ -148,6 +148,18 @@ public interface OntAnnotationProperty extends
OntProperty, OntNamedProperty<Ont
return this;
}
+ /**
+ * Adds the given property as sub property returning this property itself.
+ *
+ * @param property {@link OntAnnotationProperty}, not {@code null}
+ * @return <b>this</b> instance to allow cascading calls
+ * @see #removeSubProperty(Resource)
+ */
+ default OntAnnotationProperty addSubProperty(OntAnnotationProperty
property) {
+ property.addSubPropertyOfStatement(this);
+ return this;
+ }
+
/**
* {@inheritDoc}
*/
@@ -157,4 +169,13 @@ public interface OntAnnotationProperty extends
OntProperty, OntNamedProperty<Ont
return this;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ default OntAnnotationProperty removeSubProperty(Resource property) {
+ getModel().statements(property, RDFS.subPropertyOf,
this).toList().forEach(s -> getModel().remove(s.clearAnnotations()));
+ return this;
+ }
+
}
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntClass.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntClass.java
index 4fdf92b6c1..cc6e88a6b0 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntClass.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntClass.java
@@ -600,6 +600,22 @@ public interface OntClass extends OntObject,
AsNamed<OntClass.Named>, HasDisjoin
return this;
}
+ /**
+ * Removes a subclass relationship for the given resource including all
possible annotations.
+ * No-op in case no match found.
+ * Removes all {@link RDFS#subClassOf rdfs:subClassOf} statements with all
their annotations
+ * in case {@code null} is specified.
+ *
+ * @param other {@link Resource} or {@code null} to remove all {@code
rdfs:subClassOf} statements
+ * @return <b>this</b> instance to allow cascading calls
+ * @see #addSubClassOfStatement(OntClass)
+ * @see #addSubClass(OntClass)
+ */
+ default OntClass removeSubClass(Resource other) {
+ getModel().statements(other, RDFS.subClassOf, this).toList().forEach(s
-> getModel().remove(s.clearAnnotations()));
+ return this;
+ }
+
/**
* Removes the specified disjoint class resource.
* No-op in case no match found.
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntDataProperty.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntDataProperty.java
index 794cd20857..8f3ac159f5 100644
---
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntDataProperty.java
+++
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntDataProperty.java
@@ -207,6 +207,18 @@ public interface OntDataProperty extends
OntRelationalProperty, OntNamedProperty
return this;
}
+ /**
+ * Adds the given property as sub property returning this property itself.
+ *
+ * @param property {@link OntDataProperty}, not {@code null}
+ * @return <b>this</b> instance to allow cascading calls
+ * @see #removeSubProperty(Resource)
+ */
+ default OntDataProperty addSubProperty(OntDataProperty property) {
+ property.addSubPropertyOfStatement(this);
+ return this;
+ }
+
/**
* Adds a statement with the {@link RDFS#range} as predicate
* and the specified {@link OntDataRange data range} as an object.
@@ -268,6 +280,15 @@ public interface OntDataProperty extends
OntRelationalProperty, OntNamedProperty
return this;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ default OntDataProperty removeSubProperty(Resource property) {
+ getModel().statements(property, RDFS.subPropertyOf,
this).toList().forEach(s -> getModel().remove(s.clearAnnotations()));
+ return this;
+ }
+
/**
* {@inheritDoc}
*/
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntModel.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntModel.java
index b460aff775..ac0c0f49e4 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntModel.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntModel.java
@@ -684,6 +684,26 @@ public interface OntModel extends Model,
return getAnnotationProperty(RDFS.isDefinedBy);
}
+ default OntAnnotationProperty getOWLDeprecated() {
+ return getAnnotationProperty(OWL2.deprecated);
+ }
+
+ default OntAnnotationProperty getOWLVersionInfo() {
+ return getAnnotationProperty(OWL2.versionInfo);
+ }
+
+ default OntAnnotationProperty getOWLPriorVersion() {
+ return getAnnotationProperty(OWL2.priorVersion);
+ }
+
+ default OntAnnotationProperty getOWLBackwardCompatibleWith() {
+ return getAnnotationProperty(OWL2.backwardCompatibleWith);
+ }
+
+ default OntAnnotationProperty getOWLIncompatibleWith() {
+ return getAnnotationProperty(OWL2.incompatibleWith);
+ }
+
default OntClass.Named getOWLThing() {
return getOntClass(OWL2.Thing);
}
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntObjectProperty.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntObjectProperty.java
index 24ad7ced21..9f59ac64d4 100644
---
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntObjectProperty.java
+++
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntObjectProperty.java
@@ -444,7 +444,7 @@ public interface OntObjectProperty extends
OntRelationalProperty, AsNamed<OntObj
/**
* Adds the given property as super property returning this property
itself.
*
- * @param property {@link OntDataProperty}, not {@code null}
+ * @param property {@link OntObjectProperty}, not {@code null}
* @return <b>this</b> instance to allow cascading calls
* @see OntProperty#removeSuperProperty(Resource)
*/
@@ -453,6 +453,18 @@ public interface OntObjectProperty extends
OntRelationalProperty, AsNamed<OntObj
return this;
}
+ /**
+ * Adds the given property as sub property returning this property itself.
+ *
+ * @param property {@link OntObjectProperty}, not {@code null}
+ * @return <b>this</b> instance to allow cascading calls
+ * @see #removeSubProperty(Resource)
+ */
+ default OntObjectProperty addSubProperty(OntObjectProperty property) {
+ property.addSubPropertyOfStatement(this);
+ return this;
+ }
+
/**
* Adds a statement with the {@link RDFS#range} as predicate
* and the specified {@link OntClass class expression} as an object.
@@ -559,6 +571,15 @@ public interface OntObjectProperty extends
OntRelationalProperty, AsNamed<OntObj
return this;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ default OntObjectProperty removeSubProperty(Resource property) {
+ getModel().statements(property, RDFS.subPropertyOf,
this).toList().forEach(s -> getModel().remove(s.clearAnnotations()));
+ return this;
+ }
+
/**
* {@inheritDoc}
*/
diff --git
a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntProperty.java
b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntProperty.java
index 5e772d38f7..16922f264e 100644
--- a/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntProperty.java
+++ b/jena-ontapi/src/main/java/org/apache/jena/ontapi/model/OntProperty.java
@@ -252,7 +252,8 @@ public interface OntProperty extends OntObject {
* Removes the specified super property (predicate is {@link
RDFS#subPropertyOf rdfs:subPropertyOf}),
* including the corresponding statement's annotations.
* No-op in case no such super-property is found.
- * Removes all triples with predicate {@code rdfs:subPropertyOf} if {@code
null} is specified.
+ * If {@code null} is specified,
+ * the method removes all triples with predicate {@code
rdfs:subPropertyOf} and this property as a subject.
*
* @param property {@link Resource} or {@code null} to remove all direct
super properties
* @return <b>this</b> instance to allow cascading calls
@@ -261,4 +262,19 @@ public interface OntProperty extends OntObject {
remove(RDFS.subPropertyOf, property);
return this;
}
+
+ /**
+ * Removes the specified sub property (predicate is {@link
RDFS#subPropertyOf rdfs:subPropertyOf}),
+ * including the corresponding statement's annotations.
+ * No-op in case no such super-property is found.
+ * If {@code null} is specified,
+ * the method removes all triples with predicate {@code
rdfs:subPropertyOf} and this property as an object.
+ *
+ * @param property {@link Resource} or {@code null} to remove all direct
super properties
+ * @return <b>this</b> instance to allow cascading calls
+ */
+ default OntProperty removeSubProperty(Resource property) {
+ getModel().statements(property, RDFS.subPropertyOf,
this).toList().forEach(s -> getModel().remove(s.clearAnnotations()));
+ return this;
+ }
}
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntAnnotationPropertyTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntAnnotationPropertyTest.java
new file mode 100644
index 0000000000..e842224970
--- /dev/null
+++
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntAnnotationPropertyTest.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jena.ontapi;
+
+import org.apache.jena.ontapi.model.OntAnnotationProperty;
+import org.apache.jena.ontapi.model.OntModel;
+import org.apache.jena.vocabulary.RDFS;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+public class OntAnnotationPropertyTest {
+
+ @Test
+ public void testAnnotationPropertyDomainsAndRanges() {
+ OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
+ OntAnnotationProperty p = m.createAnnotationProperty("A");
+ Assertions.assertNotNull(p.addRangeStatement(m.getRDFSComment()));
+ Assertions.assertNotNull(p.addDomainStatement(m.getRDFSComment()));
+ Assertions.assertSame(p,
p.addDomain(m.getOWLThing()).addRange(m.getOWLNothing()).addDomain(m.getRDFSLabel()));
+ Assertions.assertEquals(2, p.ranges().count());
+ Assertions.assertEquals(3, p.domains().count());
+
+ Assertions.assertSame(p,
p.removeDomain(m.getOWLThing()).removeRange(m.getRDFSComment()));
+ Assertions.assertEquals(1, p.ranges().count());
+ Assertions.assertEquals(2, p.domains().count());
+ }
+
+ @Test
+ public void testAnnotationSuperProperties() {
+ OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
+ OntAnnotationProperty p = m.createAnnotationProperty("A");
+
Assertions.assertNotNull(p.addSubPropertyOfStatement(m.getRDFSComment()));
+ Assertions.assertSame(p, p.addSuperProperty(m.getRDFSLabel())
+ .addSuperProperty(m.getAnnotationProperty(RDFS.seeAlso)));
+ Assertions.assertEquals(3, p.superProperties().count());
+
+ Assertions.assertSame(p,
p.removeSuperProperty(m.getOWLThing()).removeSuperProperty(m.getRDFSComment()));
+ Assertions.assertEquals(2, p.superProperties().count());
+ p.removeSuperProperty(null);
+ Assertions.assertEquals(0, p.superProperties().count());
+ }
+
+ @Test
+ public void testAnnotationSubProperties() {
+ OntModel m = OntModelFactory.createModel();
+
+ OntAnnotationProperty p1 = m.createAnnotationProperty("p1");
+ OntAnnotationProperty p2 = m.createAnnotationProperty("p2");
+ Assertions.assertSame(p1, p1.addSubProperty(p2));
+ Assertions.assertEquals(List.of(p2), p1.subProperties().toList());
+ Assertions.assertEquals(List.of(), p1.superProperties().toList());
+ m.statements(p2, RDFS.subPropertyOf,
p1).toList().get(0).addAnnotation(m.getRDFSComment(), "xxx");
+ Assertions.assertEquals(8, m.size());
+
+ Assertions.assertSame(p1, p1.removeSubProperty(p2));
+ Assertions.assertEquals(List.of(), p1.subProperties().toList());
+ Assertions.assertEquals(List.of(), p1.superProperties().toList());
+
+ Assertions.assertEquals(2, m.size());
+ }
+}
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntClassMiscTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntClassMiscTest.java
index d5240e913d..2f02e540db 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntClassMiscTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntClassMiscTest.java
@@ -25,6 +25,7 @@ import org.apache.jena.ontapi.model.OntModel;
import org.apache.jena.ontapi.model.OntObjectProperty;
import org.apache.jena.rdf.model.RDFList;
import org.apache.jena.rdf.model.RDFNode;
+import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.XSD;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -40,7 +41,7 @@ public class OntClassMiscTest {
@Test
public void testCreateCardinalityRestrictions() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass c = m.createOntClass("C");
OntObjectProperty op = m.createObjectProperty("OP");
OntDataProperty dp = m.createDataProperty("DP");
@@ -64,7 +65,7 @@ public class OntClassMiscTest {
@Test
public void testListClassHierarchy() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass a = m.createOntClass("A");
OntClass b = m.createOntClass("B");
OntClass c = m.createOntClass("C");
@@ -82,20 +83,28 @@ public class OntClassMiscTest {
@Test
public void testClassExpressionSubClassOf() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass a = m.createOntClass("A");
OntClass b = m.createOntClass("B");
OntClass c = m.createOntClass("C");
+
Assertions.assertNotNull(a.addSubClassOfStatement(b));
Assertions.assertSame(a,
a.addSuperClass(c).addSuperClass(m.getOWLThing()).removeSuperClass(b));
Assertions.assertEquals(2, a.superClasses().count());
Assertions.assertSame(a, a.removeSuperClass(null));
Assertions.assertEquals(3, m.size());
+
+ Assertions.assertSame(a, a.addSubClass(b));
+ m.statements(b, RDFS.subClassOf,
a).toList().get(0).addAnnotation(m.getRDFSLabel(), "xxx");
+ Assertions.assertEquals(9, m.size());
+
+ Assertions.assertSame(a, a.removeSubClass(b));
+ Assertions.assertEquals(3, m.size());
}
@Test
public void testClassExpressionDisjointWith() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass a = m.createOntClass("A");
OntClass b = m.createOntClass("B");
OntClass c = m.createOntClass("C");
@@ -108,7 +117,7 @@ public class OntClassMiscTest {
@Test
public void testClassExpressionEquivalentClass() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass.Named a = m.createOntClass("A");
OntClass.Named b = m.createOntClass("B");
OntClass.Named c = m.createOntClass("C");
@@ -121,7 +130,7 @@ public class OntClassMiscTest {
@Test
public void testHasKeys() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntObjectProperty o1 = m.createObjectProperty("O1");
OntObjectProperty o2 = m.createObjectProperty("O2");
OntDataProperty d1 = m.createDataProperty("D1");
@@ -141,7 +150,7 @@ public class OntClassMiscTest {
@Test
public void testClassExpressionCollectionOf() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass c1 = m.createOntClass("C1");
OntClass c2 = m.createOntClass("C2");
OntClass c3 = m.createOntClass("C3");
@@ -177,7 +186,7 @@ public class OntClassMiscTest {
@Test
public void testListDisjoints() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass c1 = m.createOntClass("C1");
OntClass c2 = m.createOntClass("C2");
OntClass c3 = m.createOntClass("C3");
@@ -193,7 +202,7 @@ public class OntClassMiscTest {
@Test
public void testIsDisjoint() {
- OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF).setNsPrefixes(OntModelFactory.STANDARD);
+ OntModel m =
OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM_BUILTIN_INF);
OntClass c1 = m.createOntClass(":C1");
OntClass c2 = m.createOntClass(":C2");
OntClass c3 = m.createOntClass(":C3");
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntDataPropertyTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntDataPropertyTest.java
index 65c79b19c2..a6048a5f68 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntDataPropertyTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntDataPropertyTest.java
@@ -22,10 +22,13 @@ import org.apache.jena.ontapi.model.OntClass;
import org.apache.jena.ontapi.model.OntDataProperty;
import org.apache.jena.ontapi.model.OntDataRange;
import org.apache.jena.ontapi.model.OntModel;
+import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.XSD;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import java.util.List;
+
public class OntDataPropertyTest {
@Test
@@ -64,6 +67,25 @@ public class OntDataPropertyTest {
Assertions.assertEquals(0, p1.superProperties().count());
}
+ @Test
+ public void testDataSubProperties() {
+ OntModel m = OntModelFactory.createModel();
+
+ OntDataProperty p1 = m.createDataProperty("p1");
+ OntDataProperty p2 = m.createDataProperty("p2");
+ Assertions.assertSame(p1, p1.addSubProperty(p2));
+ Assertions.assertEquals(List.of(p2), p1.subProperties().toList());
+ Assertions.assertEquals(List.of(), p1.superProperties().toList());
+ m.statements(p2, RDFS.subPropertyOf,
p1).toList().get(0).addAnnotation(m.getRDFSComment(), "xxx");
+ Assertions.assertEquals(8, m.size());
+
+ Assertions.assertSame(p1, p1.removeSubProperty(p2));
+ Assertions.assertEquals(List.of(), p1.subProperties().toList());
+ Assertions.assertEquals(List.of(), p1.superProperties().toList());
+
+ Assertions.assertEquals(2, m.size());
+ }
+
@Test
public void testDataPropertyAdditionalDeclarations() {
OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
index 5504fe9ef2..fe11343c04 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelMiscTest.java
@@ -24,12 +24,15 @@ import org.apache.jena.ontapi.impl.GraphListenerBase;
import org.apache.jena.ontapi.model.OntClass;
import org.apache.jena.ontapi.model.OntModel;
import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.vocabulary.OWL2;
import org.apache.jena.vocabulary.RDF;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.util.ArrayList;
import java.util.List;
@@ -68,4 +71,32 @@ public class OntModelMiscTest {
UnionGraph ug = (UnionGraph) m.getGraph();
Assertions.assertEquals(0L, ug.superGraphs().count());
}
+
+ @Test
+ public void testWriteAll() {
+ OntModel a = OntModelFactory.createModel();
+ a.createOntClass("A");
+ OntModel b =
OntModelFactory.createModel().setID("http://ont#B").getModel();
+ b.createOntClass("B");
+ a.addImport(b);
+
+ ByteArrayOutputStream res1 = new ByteArrayOutputStream();
+ a.writeAll(res1, "ttl");
+ Model c = ModelFactory.createDefaultModel();
+ c.read(new ByteArrayInputStream(res1.toByteArray()), "http://ex1#",
"ttl");
+
+ Assertions.assertEquals(5, c.size());
+ Assertions.assertTrue(c.contains(c.createResource("http://ex1/A"),
RDF.type, OWL2.Class));
+ Assertions.assertTrue(c.contains(c.createResource("http://ex1/B"),
RDF.type, OWL2.Class));
+
+ ByteArrayOutputStream res2 = new ByteArrayOutputStream();
+ a.writeAll(res2, "ttl", "http://ex2#");
+ Model d = ModelFactory.createDefaultModel();
+ d.read(new ByteArrayInputStream(res2.toByteArray()), "http://ex1#",
"ttl");
+
+ Assertions.assertEquals(5, d.size());
+ Assertions.assertTrue(d.contains(d.createResource("http://ex2/A"),
RDF.type, OWL2.Class));
+ Assertions.assertTrue(d.contains(d.createResource("http://ex2/B"),
RDF.type, OWL2.Class));
+ }
+
}
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWLSpecsTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWLSpecsTest.java
index a62801ee0e..7d4c179186 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWLSpecsTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelOWLSpecsTest.java
@@ -55,6 +55,7 @@ import org.apache.jena.vocabulary.RDF;
import org.apache.jena.vocabulary.RDFS;
import org.apache.jena.vocabulary.XSD;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
@@ -1294,11 +1295,11 @@ public class OntModelOWLSpecsTest {
data.createFacetRestriction(OntFacetRestriction.MaxExclusive.class,
data.createTypedLiteral(42)),
data.createFacetRestriction(OntFacetRestriction.Pattern.class,
data.createTypedLiteral("42"))
);
- OntDataRange d4 = data.createDataUnionOf(d1, d2);
- OntDataRange d5 = data.createDataComplementOf(d2);
+ data.createDataUnionOf(d1, d2);
+ data.createDataComplementOf(d2);
- OntDataRange d6 = data.createDataIntersectionOf(d1, d2);
- OntDataRange d7 = data.createDataIntersectionOf(d2, d3);
+ data.createDataIntersectionOf(d1, d2);
+ data.createDataIntersectionOf(d2, d3);
OntModel m = OntModelFactory.createModel(data.getGraph(), spec.inst);
@@ -1325,5 +1326,42 @@ public class OntModelOWLSpecsTest {
Assertions.assertEquals(expectedNamedDataRanges,
m.ontObjects(OntDataRange.Named.class).count());
Assertions.assertEquals(expectedNamedDataRanges + 2,
m.ontObjects(OntDataRange.class).count());
}
+
+ @Test
+ public void testBuiltins() {
+ OntModel m = OntModelFactory.createModel(OntSpecification.OWL2_DL_MEM);
+
+ Assertions.assertNotNull(m.getRDFSLabel());
+ Assertions.assertNotNull(m.getRDFSComment());
+ Assertions.assertNotNull(m.getRDFSSeeAlso());
+ Assertions.assertNotNull(m.getRDFSIsDefinedBy());
+ Assertions.assertNotNull(m.getOWLDeprecated());
+ Assertions.assertNotNull(m.getOWLVersionInfo());
+ Assertions.assertNotNull(m.getOWLPriorVersion());
+ Assertions.assertNotNull(m.getOWLBackwardCompatibleWith());
+ Assertions.assertNotNull(m.getOWLIncompatibleWith());
+ Assertions.assertNotNull(m.getOWLThing());
+ Assertions.assertNotNull(m.getOWLNothing());
+ Assertions.assertNotNull(m.getOWLTopDataProperty());
+ Assertions.assertNotNull(m.getOWLTopObjectProperty());
+ Assertions.assertNotNull(m.getOWLBottomDataProperty());
+ Assertions.assertNotNull(m.getOWLBottomObjectProperty());
+
+ Assertions.assertTrue(m.getRDFSLabel().isBuiltIn());
+ Assertions.assertTrue(m.getRDFSComment().isBuiltIn());
+ Assertions.assertTrue(m.getRDFSSeeAlso().isBuiltIn());
+ Assertions.assertTrue(m.getRDFSIsDefinedBy().isBuiltIn());
+ Assertions.assertTrue(m.getOWLDeprecated().isBuiltIn());
+ Assertions.assertTrue(m.getOWLVersionInfo().isBuiltIn());
+ Assertions.assertTrue(m.getOWLPriorVersion().isBuiltIn());
+ Assertions.assertTrue(m.getOWLBackwardCompatibleWith().isBuiltIn());
+ Assertions.assertTrue(m.getOWLIncompatibleWith().isBuiltIn());
+ Assertions.assertTrue(m.getOWLThing().isBuiltIn());
+ Assertions.assertTrue(m.getOWLNothing().isBuiltIn());
+ Assertions.assertTrue(m.getOWLTopDataProperty().isBuiltIn());
+ Assertions.assertTrue(m.getOWLTopObjectProperty().isBuiltIn());
+ Assertions.assertTrue(m.getOWLBottomDataProperty().isBuiltIn());
+ Assertions.assertTrue(m.getOWLBottomObjectProperty().isBuiltIn());
+ }
}
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelRDFSSpecTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelRDFSSpecTest.java
index a9ed3fd2fe..7ad09209d9 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelRDFSSpecTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntModelRDFSSpecTest.java
@@ -273,4 +273,30 @@ public class OntModelRDFSSpecTest {
Assertions.assertEquals(6, m.size());
}
+
+ @Test
+ public void testBuiltins() {
+ OntModel m = OntModelFactory.createModel(OntSpecification.RDFS_MEM);
+
+ Assertions.assertNotNull(m.getRDFSLabel());
+ Assertions.assertNotNull(m.getRDFSComment());
+ Assertions.assertNotNull(m.getRDFSSeeAlso());
+ Assertions.assertNotNull(m.getRDFSIsDefinedBy());
+ Assertions.assertNull(m.getOWLDeprecated());
+ Assertions.assertNull(m.getOWLVersionInfo());
+ Assertions.assertNull(m.getOWLPriorVersion());
+ Assertions.assertNull(m.getOWLBackwardCompatibleWith());
+ Assertions.assertNull(m.getOWLIncompatibleWith());
+ Assertions.assertNull(m.getOWLThing());
+ Assertions.assertNull(m.getOWLNothing());
+ Assertions.assertNull(m.getOWLTopDataProperty());
+ Assertions.assertNull(m.getOWLTopObjectProperty());
+ Assertions.assertNull(m.getOWLBottomDataProperty());
+ Assertions.assertNull(m.getOWLBottomObjectProperty());
+
+ Assertions.assertTrue(m.getRDFSLabel().isBuiltIn());
+ Assertions.assertTrue(m.getRDFSComment().isBuiltIn());
+ Assertions.assertTrue(m.getRDFSSeeAlso().isBuiltIn());
+ Assertions.assertTrue(m.getRDFSIsDefinedBy().isBuiltIn());
+ }
}
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntObjectPropertyTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntObjectPropertyTest.java
index 4183de0613..ba4eac4332 100644
---
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntObjectPropertyTest.java
+++
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntObjectPropertyTest.java
@@ -21,10 +21,12 @@ package org.apache.jena.ontapi;
import org.apache.jena.ontapi.model.OntClass;
import org.apache.jena.ontapi.model.OntModel;
import org.apache.jena.ontapi.model.OntObjectProperty;
+import org.apache.jena.vocabulary.RDFS;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
+import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@@ -65,6 +67,25 @@ public class OntObjectPropertyTest {
Assertions.assertEquals(0, p1.superProperties().count());
}
+ @Test
+ public void testObjectSubProperties() {
+ OntModel m = OntModelFactory.createModel();
+
+ OntObjectProperty p1 = m.createObjectProperty("p1");
+ OntObjectProperty p2 = m.createObjectProperty("p2");
+ Assertions.assertSame(p1, p1.addSubProperty(p2));
+ Assertions.assertEquals(List.of(p2), p1.subProperties().toList());
+ Assertions.assertEquals(List.of(), p1.superProperties().toList());
+ m.statements(p2, RDFS.subPropertyOf,
p1).toList().get(0).addAnnotation(m.getRDFSComment(), "xxx");
+ Assertions.assertEquals(8, m.size());
+
+ Assertions.assertSame(p1, p1.removeSubProperty(p2));
+ Assertions.assertEquals(List.of(), p1.subProperties().toList());
+ Assertions.assertEquals(List.of(), p1.superProperties().toList());
+
+ Assertions.assertEquals(2, m.size());
+ }
+
@Test
public void testObjectPropertyAdditionalDeclarations() {
OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
diff --git
a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntPropertyTest.java
b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntPropertyTest.java
index 47f227bdcf..ccbc4a029c 100644
--- a/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntPropertyTest.java
+++ b/jena-ontapi/src/test/java/org/apache/jena/ontapi/OntPropertyTest.java
@@ -112,36 +112,6 @@ public class OntPropertyTest {
Assertions.assertEquals(3,
m.getRDFSComment().subProperties(false).count());
}
- @Test
- public void testAnnotationPropertyDomainsAndRanges() {
- OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
- OntAnnotationProperty p = m.createAnnotationProperty("A");
- Assertions.assertNotNull(p.addRangeStatement(m.getRDFSComment()));
- Assertions.assertNotNull(p.addDomainStatement(m.getRDFSComment()));
- Assertions.assertSame(p,
p.addDomain(m.getOWLThing()).addRange(m.getOWLNothing()).addDomain(m.getRDFSLabel()));
- Assertions.assertEquals(2, p.ranges().count());
- Assertions.assertEquals(3, p.domains().count());
-
- Assertions.assertSame(p,
p.removeDomain(m.getOWLThing()).removeRange(m.getRDFSComment()));
- Assertions.assertEquals(1, p.ranges().count());
- Assertions.assertEquals(2, p.domains().count());
- }
-
- @Test
- public void testAnnotationSuperProperties() {
- OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD);
- OntAnnotationProperty p = m.createAnnotationProperty("A");
-
Assertions.assertNotNull(p.addSubPropertyOfStatement(m.getRDFSComment()));
- Assertions.assertSame(p, p.addSuperProperty(m.getRDFSLabel())
- .addSuperProperty(m.getAnnotationProperty(RDFS.seeAlso)));
- Assertions.assertEquals(3, p.superProperties().count());
-
- Assertions.assertSame(p,
p.removeSuperProperty(m.getOWLThing()).removeSuperProperty(m.getRDFSComment()));
- Assertions.assertEquals(2, p.superProperties().count());
- p.removeSuperProperty(null);
- Assertions.assertEquals(0, p.superProperties().count());
- }
-
@Test
public void testIndirectDomains() {
OntModel m =
OntModelFactory.createModel().setNsPrefixes(OntModelFactory.STANDARD).setNsPrefix("",
"http://ex.com#");