Skip to content

Commit 3f274bb

Browse files
committed
Expand deprecated reference check to more axioms.
When checking for references to deprecated entities, include: * axioms defining data properties; * axioms defining individuals; * general class axioms.
1 parent da00d89 commit 3f274bb

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/main/java/org/incenp/obofoundry/odk/CheckCommand.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
package org.incenp.obofoundry.odk;
2020

21+
import java.util.ArrayList;
2122
import java.util.HashSet;
23+
import java.util.List;
2224
import java.util.Set;
2325

2426
import org.apache.commons.cli.CommandLine;
@@ -27,7 +29,10 @@
2729
import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom;
2830
import org.semanticweb.owlapi.model.OWLAxiom;
2931
import org.semanticweb.owlapi.model.OWLClass;
32+
import org.semanticweb.owlapi.model.OWLClassAxiom;
33+
import org.semanticweb.owlapi.model.OWLDataProperty;
3034
import org.semanticweb.owlapi.model.OWLEntity;
35+
import org.semanticweb.owlapi.model.OWLNamedIndividual;
3136
import org.semanticweb.owlapi.model.OWLObjectProperty;
3237
import org.semanticweb.owlapi.model.OWLOntology;
3338
import org.semanticweb.owlapi.model.parameters.Imports;
@@ -83,6 +88,10 @@ private boolean checkDeprecatedReferences(OWLOntology ontology) {
8388
axioms.addAll(ontology.getAxioms((OWLClass) entity, Imports.INCLUDED));
8489
} else if ( entity instanceof OWLObjectProperty ) {
8590
axioms.addAll(ontology.getAxioms((OWLObjectProperty) entity, Imports.INCLUDED));
91+
} else if ( entity instanceof OWLDataProperty ) {
92+
axioms.addAll(ontology.getAxioms((OWLDataProperty) entity, Imports.INCLUDED));
93+
} else if ( entity instanceof OWLNamedIndividual ) {
94+
axioms.addAll(ontology.getAxioms((OWLNamedIndividual) entity, Imports.INCLUDED));
8695
}
8796

8897
for ( OWLAxiom axiom : axioms ) {
@@ -95,6 +104,26 @@ private boolean checkDeprecatedReferences(OWLOntology ontology) {
95104
}
96105
}
97106

107+
for ( OWLOntology ont : ontology.getImportsClosure() ) {
108+
for ( OWLClassAxiom gca : ont.getGeneralClassAxioms() ) {
109+
boolean hasEntitiesInBase = false;
110+
List<String> deprecatedEntities = new ArrayList<>();
111+
for ( OWLEntity referenced : gca.getSignature() ) {
112+
if ( isInBase(referenced.getIRI().toString()) ) {
113+
hasEntitiesInBase = true;
114+
}
115+
if ( isDeprecated(ontology, referenced) ) {
116+
deprecatedEntities.add(referenced.getIRI().toString());
117+
}
118+
}
119+
if ( hasEntitiesInBase && !deprecatedEntities.isEmpty() ) {
120+
pass = false;
121+
logger.warn("A general class axiom references deprecated entities: {}",
122+
String.join(", ", deprecatedEntities));
123+
}
124+
}
125+
}
126+
98127
return pass;
99128
}
100129

0 commit comments

Comments
 (0)