diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/Ontology.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/Ontology.java index a708382e..d395d725 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/Ontology.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/Ontology.java @@ -35,8 +35,7 @@ * Also, please note that although ONT-API supports the ability to change data simultaneously through both interfaces, * this is not always correct: an {@link Ontology} impls use caches, * and switching back and forth could flush these caches, which may degrade performance. - *

- * Created by szuev on 24.10.2016. + * @see org.semanticweb.owlapi.model.OWLOntology */ public interface Ontology extends OWLOntology { @@ -55,6 +54,9 @@ public interface Ontology extends OWLOntology { * then the method {@link #clearCache()} may help. * Also note: any changes in the RDF-view will reset the internal cache, * that means next attempt to retrieve data from axiomatic view (i.e. list axioms) will take the same time as the very first one. + *

+ * Note that returning {@code OntModel} is not thread-safe even with {@code ReadWriteLock} (see issue #46). + * But {@code asGraphModel().getGraph()} and {@code asGraphModel().getBaseGraph()} are thread-safe. * * @return {@link OntModel Ontology RDF Graph Model}, not {@code null} * @see org.apache.jena.graph.Graph diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyFactoryImpl.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyFactoryImpl.java index b04a7d35..4ad87b72 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyFactoryImpl.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyFactoryImpl.java @@ -30,7 +30,7 @@ * The ontology building and loading factory, the 'core' - the main point to create and load ontologies. * See also base interface {@link OWLOntologyFactory} and its single implementation * uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl in the OWLAPI-impl module. - * It is also an outer class for any {@link OWLOntologyCreationException}s sub-classes, which may occur during loading. + * It is also an outer class for any {@link OWLOntologyCreationException}s subclasses, which may occur during loading. *

* Created by szuev on 24.10.2016. * diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyManager.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyManager.java index 063672e6..de5e0cc9 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyManager.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/OntologyManager.java @@ -65,8 +65,7 @@ *

  • {@link #getGraphModel(String, String)}
  • *
  • {@link #getDocumentSourceMappers()} - since 1.3.0
  • * - *

    - * Created by szuev on 24.10.2016. + * @see org.semanticweb.owlapi.model.OWLOntologyManager */ @ParametersAreNonnullByDefault public interface OntologyManager extends OWLOntologyManager { diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/ReflectionUtils.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/ReflectionUtils.java index b463a03e..0757b9a8 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/ReflectionUtils.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/ReflectionUtils.java @@ -20,7 +20,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.text.MessageFormat; import java.util.Objects; @@ -33,22 +32,6 @@ */ class ReflectionUtils { - /** - * Finds a static method by the class and its name. - * - * @param clazz {@link Class} - * @param name String name - * @return {@link Method} - * @throws OntApiException if no method is found - */ - static Method findStaticMethod(Class clazz, String name) throws OntApiException { - try { - return clazz.getMethod(name); - } catch (NoSuchMethodException e) { - throw new OntApiException("Can't find method '" + name + "' in " + clazz, e); - } - } - /** * Returns a proxy instance that implements {@code interfaceType} by dispatching method * invocations to {@code handler}. @@ -110,7 +93,8 @@ static R newInstance(Class interfaceType, static R newInstance(Class type) throws OntApiException { try { return type.getDeclaredConstructor().newInstance(); - } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | IllegalAccessException e) { + } catch (NoSuchMethodException | InvocationTargetException | InstantiationException | + IllegalAccessException e) { throw new OntApiException("Can't create instance of " + type.getName(), e); } } diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/BaseDeclarator.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/BaseDeclarator.java index 096a4340..d73c4532 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/BaseDeclarator.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/BaseDeclarator.java @@ -16,7 +16,7 @@ import com.github.owlcs.ontapi.jena.utils.Iterators; import com.github.owlcs.ontapi.jena.vocabulary.OWL; -import com.github.owlcs.ontapi.transforms.vocabulary.AVC; +import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI; import org.apache.jena.graph.Graph; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Property; @@ -113,7 +113,7 @@ protected boolean isAnnotationProperty(Resource candidate) { } protected boolean isIndividual(Resource candidate) { - return hasType(candidate, OWL.NamedIndividual) || hasType(candidate, AVC.AnonymousIndividual); + return hasType(candidate, OWL.NamedIndividual) || hasType(candidate, ONTAPI.AnonymousIndividual); } protected BaseDeclarator declareObjectProperty(Resource resource) { @@ -153,7 +153,7 @@ protected BaseDeclarator declareIndividual(Resource resource) { // test data from owl-api-contact contains such things also: undeclare(resource, OWL.NamedIndividual); // the temporary declaration: - declare(resource, AVC.AnonymousIndividual); + declare(resource, ONTAPI.AnonymousIndividual); } else { declare(resource, OWL.NamedIndividual); } diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/ManifestDeclarator.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/ManifestDeclarator.java index 6d51c71d..06085719 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/ManifestDeclarator.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/ManifestDeclarator.java @@ -19,7 +19,7 @@ import com.github.owlcs.ontapi.jena.vocabulary.OWL; import com.github.owlcs.ontapi.jena.vocabulary.RDF; import com.github.owlcs.ontapi.jena.vocabulary.SWRL; -import com.github.owlcs.ontapi.transforms.vocabulary.AVC; +import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI; import org.apache.jena.graph.Graph; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.RDFList; @@ -297,7 +297,7 @@ private ExtendedIterator disjointIndividuals(Resource s) { protected Set collectForbiddenClassCandidates() { Set res = new HashSet<>(builtins.getSystemResources()); - res.add(AVC.AnonymousIndividual); + res.add(ONTAPI.AnonymousIndividual); res.removeAll(builtins.getBuiltinClasses()); return res; } diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLCommonTransform.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLCommonTransform.java index 23ad8aef..c3249827 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLCommonTransform.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLCommonTransform.java @@ -19,8 +19,8 @@ import com.github.owlcs.ontapi.jena.vocabulary.OWL; import com.github.owlcs.ontapi.jena.vocabulary.RDF; import com.github.owlcs.ontapi.jena.vocabulary.XSD; -import com.github.owlcs.ontapi.transforms.vocabulary.AVC; import com.github.owlcs.ontapi.transforms.vocabulary.DEPRECATED; +import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI; import org.apache.jena.datatypes.RDFDatatype; import org.apache.jena.datatypes.xsd.XSDDatatype; import org.apache.jena.graph.Graph; @@ -234,9 +234,9 @@ protected void fixDatatype(Resource r) { .forEach(s -> { RDFNode o = s.getObject(); if (o.isURIResource()) { - m.remove(s).add(s.getSubject(), OWL.onDatatype, s.getObject()); + m.remove(s).add(s.getSubject(), OWL.onDatatype, o); } else if (o.isAnon()) { - Resource auto = AVC.randomIRI().inModel(m); + Resource auto = ONTAPI.randomIRI().inModel(m); m.remove(s).add(s.getSubject(), OWL.onDatatype, auto); auto.addProperty(OWL.equivalentClass, o); } diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLDeclarationTransform.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLDeclarationTransform.java index b4dbee1d..cc5871b4 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLDeclarationTransform.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/OWLDeclarationTransform.java @@ -16,7 +16,7 @@ import com.github.owlcs.ontapi.jena.vocabulary.OWL; import com.github.owlcs.ontapi.jena.vocabulary.RDF; -import com.github.owlcs.ontapi.transforms.vocabulary.AVC; +import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Triple; import org.apache.jena.rdf.model.RDFNode; @@ -89,7 +89,7 @@ public Stream uncertainTriples() { } protected void finalActions() { - getWorkModel().removeAll(null, RDF.type, AVC.AnonymousIndividual); + getWorkModel().removeAll(null, RDF.type, ONTAPI.AnonymousIndividual); // at times the ontology could contain some rdfs garbage, // even if other transformers (OWLTransformer, RDFSTransformer) have been used. listStatements(null, RDF.type, RDF.Property) diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/RecursiveTransform.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/RecursiveTransform.java index 51f56f7f..2a5e6628 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/RecursiveTransform.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/RecursiveTransform.java @@ -15,7 +15,7 @@ package com.github.owlcs.ontapi.transforms; import com.github.owlcs.ontapi.jena.OntVocabulary; -import com.github.owlcs.ontapi.transforms.vocabulary.AVC; +import com.github.owlcs.ontapi.transforms.vocabulary.ONTAPI; import org.apache.jena.graph.Graph; import org.apache.jena.graph.Node; import org.apache.jena.graph.Triple; @@ -44,7 +44,7 @@ * Created by @szuev on 24.01.2018. *

    * Note: this transform is slow - the complexity is ~O(n*log(n)) - * @see AVC#error(String) + * @see ONTAPI#error(String) */ @SuppressWarnings("WeakerAccess") public class RecursiveTransform extends TransformationModel { @@ -158,7 +158,7 @@ public void perform() { } public Triple createReplacement(Triple base) { - return createReplacement(base, n -> AVC.error(n).asNode()); + return createReplacement(base, n -> ONTAPI.error(n).asNode()); } public Triple createReplacement(Triple base, UnaryOperator mapper) { diff --git a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/vocabulary/AVC.java b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/vocabulary/ONTAPI.java similarity index 99% rename from owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/vocabulary/AVC.java rename to owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/vocabulary/ONTAPI.java index 21e08152..b640ced4 100644 --- a/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/vocabulary/AVC.java +++ b/owlapi-impl/src/main/java/com/github/owlcs/ontapi/transforms/vocabulary/ONTAPI.java @@ -25,7 +25,7 @@ * Vocabulary with (possible, temporary) resources used by ONT-API only. * Might be moved to {@link com.github.owlcs.ontapi.jena.vocabulary} if necessary. */ -public class AVC { +public class ONTAPI { public final static String URI = "https://github.com/owlcs/ont-api"; public final static String NS = URI + "#";