Skip to content

Commit

Permalink
ont-api: 4.0.0-SNAPSHOT -- java-17 + jena-ontapi-5.1.0, related fixin…
Browse files Browse the repository at this point in the history
…g and refactoring
  • Loading branch information
sszuev committed Aug 4, 2024
1 parent 8a95471 commit be58554
Show file tree
Hide file tree
Showing 245 changed files with 1,532 additions and 1,504 deletions.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ONT-API (ver. 3.x.x)
# ONT-API (ver. 4.x.x)

<a href="https://maven-badges.herokuapp.com/maven-central/com.github.owlcs/ontapi"><img src="https://maven-badges.herokuapp.com/maven-central/com.github.owlcs/ontapi/badge.svg" height="25" alt="Maven Central"></a>
<a href="https://javadoc.io/doc/com.github.owlcs/ontapi/latest/index.html"><img src="https://javadoc.io/badge2/com.github.owlcs/ontapi/javadoc.svg" height="25" alt="Javadoc"></a>
Expand All @@ -13,14 +13,13 @@ For more info about the library see the project [wiki](https://github.com/owlcs/

## Dependencies

- **[Apache Jena](https://github.com/apache/jena)** (**4.x.x**)
- **[Apache Jena](https://github.com/apache/jena)** (**5.x.x**)
- **[OWL-API](https://github.com/owlcs/owlapi)** (**5.x.x**)
- **[concurrent-rdf-graph](https://github.com/sszuev/concurrent-rdf-graph)** (jitpack)
- **[jena-owl2](https://github.com/sszuev/jena-owl2)** (jitpack)

## Requirements

- Java **11+**
- Java **17+**

## License

Expand All @@ -33,13 +32,13 @@ For more info about the library see the project [wiki](https://github.com/owlcs/
import com.github.owlcs.ontapi.OntManagers;
import com.github.owlcs.ontapi.Ontology;
import com.github.owlcs.ontapi.OntologyManager;
import com.github.sszuev.jena.ontapi.OntSpecification;
import com.github.sszuev.jena.ontapi.model.OntModel;
import com.github.sszuev.jena.ontapi.vocabulary.OWL;
import org.apache.jena.ontapi.OntSpecification;
import org.apache.jena.ontapi.model.OntModel;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.vocabulary.OWL;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLDataFactory;

Expand Down
61 changes: 27 additions & 34 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,46 +20,44 @@

<groupId>com.github.owlcs</groupId>
<artifactId>ontapi</artifactId>
<version>3.5.0</version>
<version>4.0.0-SNAPSHOT</version>

<name>${project.groupId}:${project.artifactId}</name>
<description>ONT-API is an RDF-centric library to work with OWL</description>
<url>https://github.com/owlcs/ont-api</url>

<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<!--https://mvnrepository.com/artifact/org.apache.jena/jena-arq-->
<version.jena>4.10.0</version.jena>
<!--https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-api-->
<!-- https://mvnrepository.com/artifact/org.apache.jena/jena-arq -->
<version.jena>5.1.0</version.jena>
<!-- https://mvnrepository.com/artifact/net.sourceforge.owlapi/owlapi-api -->
<version.owlapi>5.5.0</version.owlapi>
<!--https://mvnrepository.com/artifact/org.slf4j/slf4j-api-->
<version.slf4j>2.0.12</version.slf4j>
<!--https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine-->
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<version.slf4j>2.0.13</version.slf4j>
<!-- https://mvnrepository.com/artifact/com.github.ben-manes.caffeine/caffeine -->
<version.caffeine>3.1.8</version.caffeine>
<!--https://jitpack.io/#sszuev/concurrent-rdf-graph-->
<!-- https://jitpack.io/#sszuev/concurrent-rdf-graph -->
<version.concurrent-rdf-graph>1.1.0-java</version.concurrent-rdf-graph>
<!--https://jitpack.io/#sszuev/jena-owl2-->
<version.jena-owl2>0.3.1-SNAPSHOT</version.jena-owl2>
<!--https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-->
<version.junit>5.10.2</version.junit>
<!--https://mvnrepository.com/artifact/org.mockito/mockito-core-->
<versio.mockito>5.11.0</versio.mockito>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<version.junit>5.10.3</version.junit>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<versio.mockito>5.12.0</versio.mockito>

<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-gpg-plugin-->
<version.maven-gpg-plugin>3.2.2</version.maven-gpg-plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin-->
<version.maven-source-plugin>3.3.0</version.maven-source-plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin-->
<version.maven-javadoc-plugin>3.6.3</version.maven-javadoc-plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin-->
<version.maven-jar-plugin>3.3.0</version.maven-jar-plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin-->
<version.maven-compiler-plugin>3.12.1</version.maven-compiler-plugin>
<!--https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin-->
<version.maven-surefire-plugin>3.2.5</version.maven-surefire-plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-gpg-plugin -->
<version.maven-gpg-plugin>3.2.4</version.maven-gpg-plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-source-plugin -->
<version.maven-source-plugin>3.3.1</version.maven-source-plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-javadoc-plugin -->
<version.maven-javadoc-plugin>3.8.0</version.maven-javadoc-plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-jar-plugin -->
<version.maven-jar-plugin>3.4.2</version.maven-jar-plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<version.maven-compiler-plugin>3.13.0</version.maven-compiler-plugin>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<version.maven-surefire-plugin>3.3.1</version.maven-surefire-plugin>
</properties>

<licenses>
Expand Down Expand Up @@ -150,7 +148,7 @@
<!-- Apache Jena: -->
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<artifactId>jena-ontapi</artifactId>
<version>${version.jena}</version>
</dependency>
<!-- OWL-API: -->
Expand All @@ -171,11 +169,6 @@
<artifactId>concurrent-rdf-graph</artifactId>
<version>${version.concurrent-rdf-graph}</version>
</dependency>
<dependency>
<groupId>com.github.sszuev</groupId>
<artifactId>jena-owl2</artifactId>
<version>${version.jena-owl2}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/github/owlcs/ontapi/BlankNodeId.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.owlcs.ontapi;

import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;

import java.io.Serializable;

public record BlankNodeId(String label) implements AsNode, Serializable {

public static BlankNodeId of(Node node) {
if (node.isBlank()) {
return new BlankNodeId(node.getBlankNodeLabel());
}
throw new IllegalArgumentException();
}

public static BlankNodeId of(String id) {
return new BlankNodeId(id);
}

public static BlankNodeId of() {
return new BlankNodeId(org.apache.jena.graph.BlankNodeId.createFreshId());
}

@Override
public Node asNode() {
return NodeFactory.createBlankNode(label);
}

@Override
public String toString() {
return label;
}

@Override
public int hashCode() {
return label.hashCode();
}
}
1 change: 0 additions & 1 deletion src/main/java/com/github/owlcs/ontapi/DataFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package com.github.owlcs.ontapi;

import org.apache.jena.graph.BlankNodeId;
import org.apache.jena.graph.impl.LiteralLabel;
import org.semanticweb.owlapi.model.OWLAnonymousIndividual;
import org.semanticweb.owlapi.model.OWLDataFactory;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/github/owlcs/ontapi/DataFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@
import com.github.owlcs.ontapi.owlapi.objects.swrl.ObjectPropertyAtomImpl;
import com.github.owlcs.ontapi.owlapi.objects.swrl.SameIndividualAtomImpl;
import com.github.owlcs.ontapi.owlapi.objects.swrl.VariableImpl;
import org.apache.jena.graph.BlankNodeId;
import org.apache.jena.graph.impl.LiteralLabel;
import org.semanticweb.owlapi.model.*;
import org.semanticweb.owlapi.util.VersionInfo;
import org.semanticweb.owlapi.vocab.OWL2Datatype;
import org.semanticweb.owlapi.vocab.OWLFacet;
import org.semanticweb.owlapi.vocab.OWLRDFVocabulary;

import java.io.Serial;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -163,6 +163,7 @@
*/
@SuppressWarnings("NullableProblems")
public class DataFactoryImpl implements DataFactory {
@Serial
private static final long serialVersionUID = -4032031232398404873L;

private static final String LEXICAL_VALUE_CANNOT_BE_NULL = "lexicalValue cannot be null";
Expand Down Expand Up @@ -336,12 +337,12 @@ public OWLNamedIndividual getOWLNamedIndividual(IRI iri) {

@Override
public OWLAnonymousIndividual getOWLAnonymousIndividual(String id) {
return getOWLAnonymousIndividual(BlankNodeId.create(notNull(id, ID_CANNOT_BE_NULL)));
return getOWLAnonymousIndividual(BlankNodeId.of(notNull(id, ID_CANNOT_BE_NULL)));
}

@Override
public OWLAnonymousIndividual getOWLAnonymousIndividual() {
return getOWLAnonymousIndividual(BlankNodeId.create());
return getOWLAnonymousIndividual(BlankNodeId.of());
}

/**
Expand All @@ -353,7 +354,7 @@ public OWLAnonymousIndividual getOWLAnonymousIndividual() {
*/
@Override
public OWLAnonymousIndividual getOWLAnonymousIndividual(BlankNodeId id) {
return new AnonymousIndividualImpl(notNull(id, ID_CANNOT_BE_NULL));
return new AnonymousIndividualImpl(notNull(id.label(), ID_CANNOT_BE_NULL));
}

@Override
Expand Down
23 changes: 6 additions & 17 deletions src/main/java/com/github/owlcs/ontapi/ID.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

package com.github.owlcs.ontapi;

import com.github.sszuev.jena.ontapi.model.OntID;
import com.github.sszuev.jena.ontapi.model.OntModel;
import org.apache.jena.graph.Node;
import org.apache.jena.graph.NodeFactory;
import org.apache.jena.ontapi.model.OntID;
import org.apache.jena.ontapi.model.OntModel;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyID;

import java.lang.reflect.Field;
import java.util.Objects;
import java.util.Optional;

Expand Down Expand Up @@ -113,20 +112,10 @@ public ID(Node id, String version) throws OntApiException, IllegalStateException
hashCode += 37 * internalID.hashCode();
hashCode += 37 * ontologyIRI.hashCode();
hashCode += 37 * versionIRI.hashCode();
setField("hashCode", hashCode);
setField("internalID", internalID);
setField("ontologyIRI", ontologyIRI);
setField("versionIRI", versionIRI);
}

private void setField(String name, Object value) {
try {
Field field = getClass().getSuperclass().getDeclaredField(name);
field.setAccessible(true);
field.set(this, value);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new IllegalStateException("Can't get access to " + name, e);
}
this.hashCode = hashCode;
this.internalID = internalID;
this.ontologyIRI = ontologyIRI;
this.versionIRI = versionIRI;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/github/owlcs/ontapi/ModelConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
import com.github.owlcs.ontapi.config.OntWriterConfiguration;
import com.github.owlcs.ontapi.internal.InternalCache;
import com.github.owlcs.ontapi.internal.InternalConfig;
import com.github.sszuev.jena.ontapi.OntSpecification;
import org.apache.jena.ontapi.OntSpecification;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyLoaderConfiguration;
import org.semanticweb.owlapi.model.OWLOntologyWriterConfiguration;
import org.semanticweb.owlapi.model.OWLPrimitive;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
Expand All @@ -39,6 +40,7 @@
*/
@SuppressWarnings("WeakerAccess")
public class ModelConfig implements InternalConfig, Serializable {
@Serial
private static final long serialVersionUID = 3681978037818003272L;

protected OntLoaderConfiguration readConf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import com.github.owlcs.ontapi.config.CacheSettings;
import com.github.owlcs.ontapi.config.OntLoaderConfiguration;
import com.github.sszuev.jena.ontapi.UnionGraph;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.jena.graph.Graph;
import org.apache.jena.ontapi.UnionGraph;
import org.semanticweb.owlapi.io.OWLOntologyCreationIOException;
import org.semanticweb.owlapi.io.OWLOntologyDocumentSource;
import org.semanticweb.owlapi.io.OWLOntologyInputSourceException;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/owlcs/ontapi/OntApiException.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

package com.github.owlcs.ontapi;

import com.github.sszuev.jena.ontapi.OntJenaException;
import org.apache.jena.ontapi.OntJenaException;
import org.semanticweb.owlapi.model.OWLRuntimeException;

/**
* A base {@code RuntimeException}, that must be used only in OWL-API part of implementation.
* For a {@link com.github.sszuev.jena.ontapi Jena sybsustem}
* For a {@link org.apache.jena.ontapi Jena sybsustem}
* there is its own exception: {@link OntJenaException}.
* <p>
* Created by @ssz on 27.09.2016.
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/github/owlcs/ontapi/OntBaseModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import com.github.owlcs.ontapi.internal.InternalConfig;
import com.github.owlcs.ontapi.internal.InternalGraphModel;
import com.github.owlcs.ontapi.internal.InternalGraphModelImpl;
import com.github.sszuev.jena.ontapi.OntSpecification;
import com.github.sszuev.jena.ontapi.UnionGraph;
import com.github.sszuev.jena.ontapi.impl.UnionGraphImpl;
import com.github.sszuev.jena.ontapi.model.OntModel;
import org.apache.jena.graph.Graph;
import org.apache.jena.ontapi.OntSpecification;
import org.apache.jena.ontapi.UnionGraph;
import org.apache.jena.ontapi.impl.UnionGraphImpl;
import org.apache.jena.ontapi.model.OntModel;
import org.apache.jena.reasoner.ReasonerFactory;
import org.semanticweb.owlapi.model.OWLPrimitive;

Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/github/owlcs/ontapi/OntBaseModelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

import com.github.owlcs.ontapi.internal.InternalGraphModel;
import com.github.owlcs.ontapi.owlapi.OWLObjectImpl;
import com.github.sszuev.jena.ontapi.model.OntModel;
import com.github.sszuev.jena.ontapi.utils.Graphs;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.jena.graph.Graph;
import org.apache.jena.graph.GraphMemFactory;
import org.apache.jena.ontapi.model.OntModel;
import org.apache.jena.ontapi.utils.Graphs;
import org.apache.jena.riot.RDFDataMgr;
import org.semanticweb.owlapi.model.AxiomType;
import org.semanticweb.owlapi.model.EntityType;
Expand Down Expand Up @@ -103,6 +103,7 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serial;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
Expand All @@ -122,6 +123,7 @@
public abstract class OntBaseModelImpl implements OWLOntology, OntBaseModel {
// binary format to provide serialization:
public static final OntFormat DEFAULT_SERIALIZATION_FORMAT = OntFormat.RDF_THRIFT;
@Serial
private static final long serialVersionUID = 7605836729147058594L;

protected transient InternalGraphModel base;
Expand Down Expand Up @@ -1182,6 +1184,7 @@ public Stream<OWLDifferentIndividualsAxiom> differentIndividualAxioms(OWLIndivid
* @throws ClassNotFoundException if the class of a serialized object could not be found
* @see OntologyManagerImpl#readObject(ObjectInputStream)
*/
@Serial
@SuppressWarnings("JavadocReference")
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
Expand All @@ -1202,6 +1205,7 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE
* @throws IOException if I/O errors occur while writing to the underlying <code>OutputStream</code>
* @throws OntApiException in case this instance encapsulates graph which is not plain in-memory graph
*/
@Serial
private void writeObject(ObjectOutputStream out) throws IOException, OntApiException {
Graph g = base.getBaseGraph();
if (!Graphs.isGraphMem(g)) {
Expand Down
Loading

0 comments on commit be58554

Please sign in to comment.