1818
1919package org .incenp .obofoundry .odk ;
2020
21+ import java .util .ArrayList ;
2122import java .util .HashSet ;
23+ import java .util .List ;
2224import java .util .Set ;
2325
2426import org .apache .commons .cli .CommandLine ;
2729import org .semanticweb .owlapi .model .OWLAnnotationAssertionAxiom ;
2830import org .semanticweb .owlapi .model .OWLAxiom ;
2931import org .semanticweb .owlapi .model .OWLClass ;
32+ import org .semanticweb .owlapi .model .OWLClassAxiom ;
33+ import org .semanticweb .owlapi .model .OWLDataProperty ;
3034import org .semanticweb .owlapi .model .OWLEntity ;
35+ import org .semanticweb .owlapi .model .OWLNamedIndividual ;
3136import org .semanticweb .owlapi .model .OWLObjectProperty ;
3237import org .semanticweb .owlapi .model .OWLOntology ;
3338import 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