diff options
| author | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-10 18:17:06 +0100 |
|---|---|---|
| committer | Federico Igne <federico.igne@cs.ox.ac.uk> | 2022-05-11 12:34:47 +0100 |
| commit | 17bd9beaf7f358a44e5bf36a5855fe6727d506dc (patch) | |
| tree | 47e9310a0cff869d9ec017dcb2c81876407782c8 /src/main/java/org/semanticweb/karma2/profile | |
| parent | 8651164cd632a5db310b457ce32d4fbc97bdc41c (diff) | |
| download | ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.tar.gz ACQuA-17bd9beaf7f358a44e5bf36a5855fe6727d506dc.zip | |
[pagoda] Move project to Scala
This commit includes a few changes:
- The repository still uses Maven to manage dependency but it is now a
Scala project.
- The code has been ported from OWLAPI 3.4.10 to 5.1.20
- A proof of concept program using both RSAComb and PAGOdA has been
added.
Diffstat (limited to 'src/main/java/org/semanticweb/karma2/profile')
| -rw-r--r-- | src/main/java/org/semanticweb/karma2/profile/ELHOProfile.java | 261 | ||||
| -rw-r--r-- | src/main/java/org/semanticweb/karma2/profile/MyOWLOntologyWalker.java | 914 |
2 files changed, 1175 insertions, 0 deletions
diff --git a/src/main/java/org/semanticweb/karma2/profile/ELHOProfile.java b/src/main/java/org/semanticweb/karma2/profile/ELHOProfile.java new file mode 100644 index 0000000..23761f0 --- /dev/null +++ b/src/main/java/org/semanticweb/karma2/profile/ELHOProfile.java | |||
| @@ -0,0 +1,261 @@ | |||
| 1 | package org.semanticweb.karma2.profile; | ||
| 2 | |||
| 3 | import java.util.HashSet; | ||
| 4 | import java.util.Iterator; | ||
| 5 | import java.util.Set; | ||
| 6 | |||
| 7 | import org.semanticweb.owlapi.model.AxiomType; | ||
| 8 | import org.semanticweb.owlapi.model.IRI; | ||
| 9 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 10 | import org.semanticweb.owlapi.model.OWLClassExpression; | ||
| 11 | import org.semanticweb.owlapi.model.OWLDataHasValue; | ||
| 12 | import org.semanticweb.owlapi.model.OWLDataIntersectionOf; | ||
| 13 | import org.semanticweb.owlapi.model.OWLDataOneOf; | ||
| 14 | import org.semanticweb.owlapi.model.OWLDataProperty; | ||
| 15 | import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; | ||
| 16 | import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; | ||
| 17 | import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; | ||
| 18 | import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; | ||
| 19 | import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; | ||
| 20 | import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; | ||
| 21 | import org.semanticweb.owlapi.model.OWLHasKeyAxiom; | ||
| 22 | import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; | ||
| 23 | import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; | ||
| 24 | import org.semanticweb.owlapi.model.OWLObjectHasSelf; | ||
| 25 | import org.semanticweb.owlapi.model.OWLObjectMinCardinality; | ||
| 26 | import org.semanticweb.owlapi.model.OWLObjectOneOf; | ||
| 27 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 28 | import org.semanticweb.owlapi.model.OWLOntologyCreationException; | ||
| 29 | import org.semanticweb.owlapi.model.OWLOntologyManager; | ||
| 30 | import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; | ||
| 31 | import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; | ||
| 32 | import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; | ||
| 33 | import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; | ||
| 34 | import org.semanticweb.owlapi.profiles.OWL2ELProfile; | ||
| 35 | import org.semanticweb.owlapi.profiles.OWLProfile; | ||
| 36 | import org.semanticweb.owlapi.profiles.OWLProfileReport; | ||
| 37 | import org.semanticweb.owlapi.profiles.OWLProfileViolation; | ||
| 38 | import org.semanticweb.owlapi.profiles.violations.UseOfDataOneOfWithMultipleLiterals; | ||
| 39 | import org.semanticweb.owlapi.profiles.violations.UseOfIllegalAxiom; | ||
| 40 | import org.semanticweb.owlapi.profiles.violations.UseOfIllegalClassExpression; | ||
| 41 | import org.semanticweb.owlapi.profiles.violations.UseOfObjectOneOfWithMultipleIndividuals; | ||
| 42 | import org.semanticweb.owlapi.util.OWLObjectPropertyManager; | ||
| 43 | import org.semanticweb.owlapi.util.OWLOntologyWalker; | ||
| 44 | import org.semanticweb.owlapi.util.OWLOntologyWalkerVisitor; | ||
| 45 | import uk.ac.ox.cs.pagoda.util.Utility; | ||
| 46 | |||
| 47 | public class ELHOProfile implements OWLProfile { | ||
| 48 | |||
| 49 | public OWLOntology getFragment(OWLOntology ontology) { | ||
| 50 | OWLOntologyManager manager = ontology.getOWLOntologyManager(); | ||
| 51 | OWLOntology elhoOntology = null; | ||
| 52 | try { | ||
| 53 | Utility.logDebug("OntologyID: " + ontology.getOntologyID()); | ||
| 54 | try { | ||
| 55 | String ontologyIRI = ontology.getOntologyID().getOntologyIRI().toString(); | ||
| 56 | if (ontologyIRI.contains(".owl")) | ||
| 57 | ontologyIRI = ontologyIRI.replace(".owl", "-elho.owl"); | ||
| 58 | else | ||
| 59 | ontologyIRI = ontologyIRI + "elho"; | ||
| 60 | elhoOntology = manager.createOntology(IRI.create(ontologyIRI)); | ||
| 61 | } catch (NullPointerException e) { | ||
| 62 | // e.printStackTrace(); | ||
| 63 | elhoOntology = manager.createOntology(); | ||
| 64 | } | ||
| 65 | |||
| 66 | } catch (OWLOntologyCreationException e) { | ||
| 67 | e.printStackTrace(); | ||
| 68 | } | ||
| 69 | for (OWLOntology onto: ontology.getImportsClosure()) | ||
| 70 | manager.addAxioms(elhoOntology, onto.getAxioms()); | ||
| 71 | |||
| 72 | // TODO to be checked ... | ||
| 73 | manager.removeAxioms(elhoOntology, elhoOntology.getAxioms(AxiomType.DIFFERENT_INDIVIDUALS)); | ||
| 74 | |||
| 75 | OWLProfileReport report = checkOntology(elhoOntology); | ||
| 76 | |||
| 77 | for (OWLProfileViolation violation: report.getViolations()) { | ||
| 78 | OWLAxiom axiom = violation.getAxiom(); | ||
| 79 | manager.removeAxiom(elhoOntology, axiom); | ||
| 80 | } | ||
| 81 | Utility.logDebug("ELHO fragment extracted ... "); | ||
| 82 | |||
| 83 | return elhoOntology; | ||
| 84 | } | ||
| 85 | |||
| 86 | @Override | ||
| 87 | public OWLProfileReport checkOntology(OWLOntology ontology) { | ||
| 88 | OWL2ELProfile profile = new OWL2ELProfile(); | ||
| 89 | OWLProfileReport report = profile.checkOntology(ontology); | ||
| 90 | Set<OWLProfileViolation> violations = new HashSet<OWLProfileViolation>(); | ||
| 91 | violations.addAll(report.getViolations()); | ||
| 92 | MyOWLOntologyWalker ontologyWalker = new MyOWLOntologyWalker(ontology.getImportsClosure()); | ||
| 93 | ELHOProfileObjectVisitor visitor = new ELHOProfileObjectVisitor(ontologyWalker, ontology.getOWLOntologyManager()); | ||
| 94 | ontologyWalker.walkStructure(visitor); | ||
| 95 | |||
| 96 | for (Iterator<OWLProfileViolation> iter = violations.iterator(); iter.hasNext(); ) { | ||
| 97 | OWLProfileViolation vio = iter.next(); | ||
| 98 | if (vio instanceof UseOfIllegalClassExpression) { | ||
| 99 | OWLClassExpression exp = ((UseOfIllegalClassExpression) vio).getExpression(); | ||
| 100 | if (exp instanceof OWLObjectMinCardinality && ((OWLObjectMinCardinality) exp).getCardinality() == 1) | ||
| 101 | iter.remove(); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | violations.addAll(visitor.getProfileViolations()); | ||
| 106 | return new OWLProfileReport(this, violations); | ||
| 107 | } | ||
| 108 | |||
| 109 | @Override | ||
| 110 | public String getName() { | ||
| 111 | return "ELHO"; | ||
| 112 | } | ||
| 113 | |||
| 114 | protected class ELHOProfileObjectVisitor extends OWLOntologyWalkerVisitor { | ||
| 115 | |||
| 116 | private final OWLOntologyManager man; | ||
| 117 | |||
| 118 | private OWLObjectPropertyManager propertyManager; | ||
| 119 | |||
| 120 | private final Set<OWLProfileViolation> profileViolations = new HashSet<OWLProfileViolation>(); | ||
| 121 | |||
| 122 | public ELHOProfileObjectVisitor(OWLOntologyWalker walker, OWLOntologyManager man) { | ||
| 123 | super(walker); | ||
| 124 | this.man = man; | ||
| 125 | } | ||
| 126 | |||
| 127 | public Set<OWLProfileViolation> getProfileViolations() { | ||
| 128 | return new HashSet<OWLProfileViolation>(profileViolations); | ||
| 129 | } | ||
| 130 | |||
| 131 | @SuppressWarnings("unused") | ||
| 132 | private OWLObjectPropertyManager getPropertyManager() { | ||
| 133 | if (propertyManager == null) { | ||
| 134 | propertyManager = new OWLObjectPropertyManager(getCurrentOntology()); | ||
| 135 | } | ||
| 136 | return propertyManager; | ||
| 137 | } | ||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | @Override | ||
| 142 | public void visit(OWLDataProperty p) { | ||
| 143 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 144 | } | ||
| 145 | |||
| 146 | |||
| 147 | @Override | ||
| 148 | public void visit(OWLObjectOneOf desc) { | ||
| 149 | if (desc.getIndividuals().size() != 1) { | ||
| 150 | profileViolations.add(new UseOfObjectOneOfWithMultipleIndividuals(getCurrentOntology(), getCurrentAxiom(), desc)); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | @Override | ||
| 155 | public void visit(OWLDataHasValue desc) { | ||
| 156 | profileViolations.add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), desc)); | ||
| 157 | } | ||
| 158 | |||
| 159 | @Override | ||
| 160 | public void visit(OWLDataSomeValuesFrom desc) { | ||
| 161 | profileViolations.add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), desc)); | ||
| 162 | } | ||
| 163 | |||
| 164 | @Override | ||
| 165 | public void visit(OWLDataIntersectionOf desc) { | ||
| 166 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 167 | } | ||
| 168 | |||
| 169 | @Override | ||
| 170 | public void visit(OWLSubDataPropertyOfAxiom desc) { | ||
| 171 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 172 | } | ||
| 173 | |||
| 174 | @Override | ||
| 175 | public void visit(OWLEquivalentDataPropertiesAxiom desc) { | ||
| 176 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 177 | } | ||
| 178 | |||
| 179 | @Override | ||
| 180 | public void visit(OWLTransitiveObjectPropertyAxiom desc) { | ||
| 181 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 182 | } | ||
| 183 | |||
| 184 | @Override | ||
| 185 | public void visit(OWLReflexiveObjectPropertyAxiom desc) { | ||
| 186 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 187 | } | ||
| 188 | |||
| 189 | @Override | ||
| 190 | public void visit(OWLDataPropertyDomainAxiom desc) { | ||
| 191 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 192 | } | ||
| 193 | |||
| 194 | @Override | ||
| 195 | public void visit(OWLDataPropertyRangeAxiom desc) { | ||
| 196 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 197 | } | ||
| 198 | |||
| 199 | |||
| 200 | |||
| 201 | @Override | ||
| 202 | public void visit(OWLDataPropertyAssertionAxiom desc) { | ||
| 203 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 204 | } | ||
| 205 | |||
| 206 | @Override | ||
| 207 | public void visit(OWLNegativeDataPropertyAssertionAxiom desc) { | ||
| 208 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 209 | } | ||
| 210 | |||
| 211 | @Override | ||
| 212 | public void visit(OWLNegativeObjectPropertyAssertionAxiom desc) { | ||
| 213 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 214 | } | ||
| 215 | |||
| 216 | @Override | ||
| 217 | public void visit(OWLFunctionalDataPropertyAxiom desc) { | ||
| 218 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 219 | } | ||
| 220 | |||
| 221 | @Override | ||
| 222 | public void visit(OWLHasKeyAxiom desc) { | ||
| 223 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 224 | } | ||
| 225 | |||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | @Override | ||
| 230 | public void visit(OWLObjectHasSelf node) { | ||
| 231 | profileViolations.add(new UseOfIllegalClassExpression(getCurrentOntology(), getCurrentAxiom(), node)); | ||
| 232 | } | ||
| 233 | |||
| 234 | |||
| 235 | @Override | ||
| 236 | public void visit(OWLDataOneOf node) { | ||
| 237 | profileViolations.add(new UseOfDataOneOfWithMultipleLiterals(getCurrentOntology(), getCurrentAxiom(), node)); | ||
| 238 | } | ||
| 239 | |||
| 240 | |||
| 241 | |||
| 242 | @Override | ||
| 243 | public void visit(OWLSubPropertyChainOfAxiom axiom) { | ||
| 244 | profileViolations.add(new UseOfIllegalAxiom(getCurrentOntology(), getCurrentAxiom())); | ||
| 245 | |||
| 246 | } | ||
| 247 | |||
| 248 | @Override | ||
| 249 | public void visit(OWLOntology ontology) { | ||
| 250 | propertyManager = null; | ||
| 251 | } | ||
| 252 | } | ||
| 253 | |||
| 254 | @Override | ||
| 255 | public IRI getIRI() { | ||
| 256 | return null; | ||
| 257 | } | ||
| 258 | |||
| 259 | |||
| 260 | } | ||
| 261 | |||
diff --git a/src/main/java/org/semanticweb/karma2/profile/MyOWLOntologyWalker.java b/src/main/java/org/semanticweb/karma2/profile/MyOWLOntologyWalker.java new file mode 100644 index 0000000..1ce8076 --- /dev/null +++ b/src/main/java/org/semanticweb/karma2/profile/MyOWLOntologyWalker.java | |||
| @@ -0,0 +1,914 @@ | |||
| 1 | package org.semanticweb.karma2.profile; | ||
| 2 | |||
| 3 | import java.util.ArrayList; | ||
| 4 | import java.util.Collection; | ||
| 5 | import java.util.HashSet; | ||
| 6 | import java.util.Set; | ||
| 7 | |||
| 8 | import org.semanticweb.owlapi.model.IRI; | ||
| 9 | import org.semanticweb.owlapi.model.OWLAnnotation; | ||
| 10 | import org.semanticweb.owlapi.model.OWLAnnotationAssertionAxiom; | ||
| 11 | import org.semanticweb.owlapi.model.OWLAnnotationProperty; | ||
| 12 | import org.semanticweb.owlapi.model.OWLAnnotationPropertyDomainAxiom; | ||
| 13 | import org.semanticweb.owlapi.model.OWLAnnotationPropertyRangeAxiom; | ||
| 14 | import org.semanticweb.owlapi.model.OWLAnonymousIndividual; | ||
| 15 | import org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom; | ||
| 16 | import org.semanticweb.owlapi.model.OWLAxiom; | ||
| 17 | import org.semanticweb.owlapi.model.OWLClass; | ||
| 18 | import org.semanticweb.owlapi.model.OWLClassAssertionAxiom; | ||
| 19 | import org.semanticweb.owlapi.model.OWLClassExpression; | ||
| 20 | import org.semanticweb.owlapi.model.OWLDataAllValuesFrom; | ||
| 21 | import org.semanticweb.owlapi.model.OWLDataComplementOf; | ||
| 22 | import org.semanticweb.owlapi.model.OWLDataExactCardinality; | ||
| 23 | import org.semanticweb.owlapi.model.OWLDataHasValue; | ||
| 24 | import org.semanticweb.owlapi.model.OWLDataIntersectionOf; | ||
| 25 | import org.semanticweb.owlapi.model.OWLDataMaxCardinality; | ||
| 26 | import org.semanticweb.owlapi.model.OWLDataMinCardinality; | ||
| 27 | import org.semanticweb.owlapi.model.OWLDataOneOf; | ||
| 28 | import org.semanticweb.owlapi.model.OWLDataProperty; | ||
| 29 | import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom; | ||
| 30 | import org.semanticweb.owlapi.model.OWLDataPropertyDomainAxiom; | ||
| 31 | import org.semanticweb.owlapi.model.OWLDataPropertyExpression; | ||
| 32 | import org.semanticweb.owlapi.model.OWLDataPropertyRangeAxiom; | ||
| 33 | import org.semanticweb.owlapi.model.OWLDataRange; | ||
| 34 | import org.semanticweb.owlapi.model.OWLDataSomeValuesFrom; | ||
| 35 | import org.semanticweb.owlapi.model.OWLDataUnionOf; | ||
| 36 | import org.semanticweb.owlapi.model.OWLDatatype; | ||
| 37 | import org.semanticweb.owlapi.model.OWLDatatypeDefinitionAxiom; | ||
| 38 | import org.semanticweb.owlapi.model.OWLDatatypeRestriction; | ||
| 39 | import org.semanticweb.owlapi.model.OWLDeclarationAxiom; | ||
| 40 | import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom; | ||
| 41 | import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom; | ||
| 42 | import org.semanticweb.owlapi.model.OWLDisjointDataPropertiesAxiom; | ||
| 43 | import org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom; | ||
| 44 | import org.semanticweb.owlapi.model.OWLDisjointUnionAxiom; | ||
| 45 | import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom; | ||
| 46 | import org.semanticweb.owlapi.model.OWLEquivalentDataPropertiesAxiom; | ||
| 47 | import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom; | ||
| 48 | import org.semanticweb.owlapi.model.OWLFacetRestriction; | ||
| 49 | import org.semanticweb.owlapi.model.OWLFunctionalDataPropertyAxiom; | ||
| 50 | import org.semanticweb.owlapi.model.OWLFunctionalObjectPropertyAxiom; | ||
| 51 | import org.semanticweb.owlapi.model.OWLHasKeyAxiom; | ||
| 52 | import org.semanticweb.owlapi.model.OWLIndividual; | ||
| 53 | import org.semanticweb.owlapi.model.OWLInverseFunctionalObjectPropertyAxiom; | ||
| 54 | import org.semanticweb.owlapi.model.OWLInverseObjectPropertiesAxiom; | ||
| 55 | import org.semanticweb.owlapi.model.OWLIrreflexiveObjectPropertyAxiom; | ||
| 56 | import org.semanticweb.owlapi.model.OWLLiteral; | ||
| 57 | import org.semanticweb.owlapi.model.OWLNamedIndividual; | ||
| 58 | import org.semanticweb.owlapi.model.OWLNegativeDataPropertyAssertionAxiom; | ||
| 59 | import org.semanticweb.owlapi.model.OWLNegativeObjectPropertyAssertionAxiom; | ||
| 60 | import org.semanticweb.owlapi.model.OWLObject; | ||
| 61 | import org.semanticweb.owlapi.model.OWLObjectAllValuesFrom; | ||
| 62 | import org.semanticweb.owlapi.model.OWLObjectComplementOf; | ||
| 63 | import org.semanticweb.owlapi.model.OWLObjectExactCardinality; | ||
| 64 | import org.semanticweb.owlapi.model.OWLObjectHasSelf; | ||
| 65 | import org.semanticweb.owlapi.model.OWLObjectHasValue; | ||
| 66 | import org.semanticweb.owlapi.model.OWLObjectIntersectionOf; | ||
| 67 | import org.semanticweb.owlapi.model.OWLObjectInverseOf; | ||
| 68 | import org.semanticweb.owlapi.model.OWLObjectMaxCardinality; | ||
| 69 | import org.semanticweb.owlapi.model.OWLObjectMinCardinality; | ||
| 70 | import org.semanticweb.owlapi.model.OWLObjectOneOf; | ||
| 71 | import org.semanticweb.owlapi.model.OWLObjectProperty; | ||
| 72 | import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom; | ||
| 73 | import org.semanticweb.owlapi.model.OWLObjectPropertyDomainAxiom; | ||
| 74 | import org.semanticweb.owlapi.model.OWLObjectPropertyExpression; | ||
| 75 | import org.semanticweb.owlapi.model.OWLObjectPropertyRangeAxiom; | ||
| 76 | import org.semanticweb.owlapi.model.OWLObjectSomeValuesFrom; | ||
| 77 | import org.semanticweb.owlapi.model.OWLObjectUnionOf; | ||
| 78 | import org.semanticweb.owlapi.model.OWLObjectVisitor; | ||
| 79 | import org.semanticweb.owlapi.model.OWLObjectVisitorEx; | ||
| 80 | import org.semanticweb.owlapi.model.OWLOntology; | ||
| 81 | import org.semanticweb.owlapi.model.OWLReflexiveObjectPropertyAxiom; | ||
| 82 | import org.semanticweb.owlapi.model.OWLSameIndividualAxiom; | ||
| 83 | import org.semanticweb.owlapi.model.OWLSubAnnotationPropertyOfAxiom; | ||
| 84 | import org.semanticweb.owlapi.model.OWLSubClassOfAxiom; | ||
| 85 | import org.semanticweb.owlapi.model.OWLSubDataPropertyOfAxiom; | ||
| 86 | import org.semanticweb.owlapi.model.OWLSubObjectPropertyOfAxiom; | ||
| 87 | import org.semanticweb.owlapi.model.OWLSubPropertyChainOfAxiom; | ||
| 88 | import org.semanticweb.owlapi.model.OWLSymmetricObjectPropertyAxiom; | ||
| 89 | import org.semanticweb.owlapi.model.OWLTransitiveObjectPropertyAxiom; | ||
| 90 | import org.semanticweb.owlapi.model.SWRLAtom; | ||
| 91 | import org.semanticweb.owlapi.model.SWRLBuiltInAtom; | ||
| 92 | import org.semanticweb.owlapi.model.SWRLClassAtom; | ||
| 93 | import org.semanticweb.owlapi.model.SWRLDArgument; | ||
| 94 | import org.semanticweb.owlapi.model.SWRLDataPropertyAtom; | ||
| 95 | import org.semanticweb.owlapi.model.SWRLDataRangeAtom; | ||
| 96 | import org.semanticweb.owlapi.model.SWRLDifferentIndividualsAtom; | ||
| 97 | import org.semanticweb.owlapi.model.SWRLIndividualArgument; | ||
| 98 | import org.semanticweb.owlapi.model.SWRLLiteralArgument; | ||
| 99 | import org.semanticweb.owlapi.model.SWRLObjectPropertyAtom; | ||
| 100 | import org.semanticweb.owlapi.model.SWRLRule; | ||
| 101 | import org.semanticweb.owlapi.model.SWRLSameIndividualAtom; | ||
| 102 | import org.semanticweb.owlapi.model.SWRLVariable; | ||
| 103 | import org.semanticweb.owlapi.util.OWLOntologyWalker; | ||
| 104 | |||
| 105 | |||
| 106 | public class MyOWLOntologyWalker extends OWLOntologyWalker { | ||
| 107 | |||
| 108 | private final Collection<OWLOntology> ontologies; | ||
| 109 | |||
| 110 | /** | ||
| 111 | * @param objects the set of objects to visit | ||
| 112 | */ | ||
| 113 | public MyOWLOntologyWalker(Set<OWLOntology> objects) { | ||
| 114 | this(objects, true); | ||
| 115 | } | ||
| 116 | /** | ||
| 117 | * @param visitDuplicates true if duplicates should be visited | ||
| 118 | * @param objects the set of objects to visit | ||
| 119 | */ | ||
| 120 | public MyOWLOntologyWalker(Set<OWLOntology> objects, boolean visitDuplicates) { | ||
| 121 | super(objects); | ||
| 122 | this.ontologies = new ArrayList<OWLOntology>(objects); | ||
| 123 | } | ||
| 124 | |||
| 125 | /** | ||
| 126 | * @param v visitor to use over the objects | ||
| 127 | */ | ||
| 128 | //public void walkStructure(OWLObjectVisitorEx<?> v) { | ||
| 129 | public void walkStructure(OWLObjectVisitor v) { | ||
| 130 | this.visitor = v; | ||
| 131 | StructureWalker walker = new StructureWalker(); | ||
| 132 | for (OWLOntology o : ontologies) { | ||
| 133 | o.accept(walker); | ||
| 134 | } | ||
| 135 | } | ||
| 136 | |||
| 137 | private class StructureWalker implements OWLObjectVisitor { | ||
| 138 | |||
| 139 | private final Set<OWLObject> visited = new HashSet<OWLObject>(); | ||
| 140 | |||
| 141 | public StructureWalker() {} | ||
| 142 | |||
| 143 | private void process(OWLObject object) { | ||
| 144 | if (!visitDuplicates) { | ||
| 145 | if (!visited.contains(object)) { | ||
| 146 | visited.add(object); | ||
| 147 | object.accept(visitor); | ||
| 148 | } | ||
| 149 | } | ||
| 150 | else { | ||
| 151 | object.accept(visitor); | ||
| 152 | } | ||
| 153 | } | ||
| 154 | |||
| 155 | @Override | ||
| 156 | public void visit(IRI iri) { | ||
| 157 | process(iri); | ||
| 158 | } | ||
| 159 | |||
| 160 | @Override | ||
| 161 | public void visit(OWLOntology ontologyToVisit) { | ||
| 162 | MyOWLOntologyWalker.this.ontology = ontologyToVisit; | ||
| 163 | MyOWLOntologyWalker.this.ax = null; | ||
| 164 | process(ontologyToVisit); | ||
| 165 | for (OWLAnnotation anno : ontologyToVisit.getAnnotations()) { | ||
| 166 | anno.accept(this); | ||
| 167 | } | ||
| 168 | for (OWLAxiom a : ontologyToVisit.getAxioms()) { | ||
| 169 | a.accept(this); | ||
| 170 | } | ||
| 171 | } | ||
| 172 | |||
| 173 | |||
| 174 | @Override | ||
| 175 | public void visit(OWLAsymmetricObjectPropertyAxiom axiom) { | ||
| 176 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 177 | process(axiom); | ||
| 178 | axiom.getProperty().accept(this); | ||
| 179 | } | ||
| 180 | |||
| 181 | |||
| 182 | @Override | ||
| 183 | public void visit(OWLClassAssertionAxiom axiom) { | ||
| 184 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 185 | process(axiom); | ||
| 186 | axiom.getIndividual().accept(this); | ||
| 187 | axiom.getClassExpression().accept(this); | ||
| 188 | } | ||
| 189 | |||
| 190 | |||
| 191 | @Override | ||
| 192 | public void visit(OWLDataPropertyAssertionAxiom axiom) { | ||
| 193 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 194 | process(axiom); | ||
| 195 | axiom.getSubject().accept(this); | ||
| 196 | axiom.getProperty().accept(this); | ||
| 197 | axiom.getObject().accept(this); | ||
| 198 | } | ||
| 199 | |||
| 200 | |||
| 201 | @Override | ||
| 202 | public void visit(OWLDataPropertyDomainAxiom axiom) { | ||
| 203 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 204 | process(axiom); | ||
| 205 | axiom.getDomain().accept(this); | ||
| 206 | axiom.getProperty().accept(this); | ||
| 207 | } | ||
| 208 | |||
| 209 | |||
| 210 | @Override | ||
| 211 | public void visit(OWLDataPropertyRangeAxiom axiom) { | ||
| 212 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 213 | process(axiom); | ||
| 214 | axiom.getRange().accept(this); | ||
| 215 | axiom.getProperty().accept(this); | ||
| 216 | } | ||
| 217 | |||
| 218 | |||
| 219 | @Override | ||
| 220 | public void visit(OWLSubDataPropertyOfAxiom axiom) { | ||
| 221 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 222 | process(axiom); | ||
| 223 | axiom.getSubProperty().accept(this); | ||
| 224 | axiom.getSuperProperty().accept(this); | ||
| 225 | } | ||
| 226 | |||
| 227 | |||
| 228 | @Override | ||
| 229 | public void visit(OWLDeclarationAxiom axiom) { | ||
| 230 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 231 | process(axiom); | ||
| 232 | axiom.getEntity().accept(this); | ||
| 233 | } | ||
| 234 | |||
| 235 | |||
| 236 | @Override | ||
| 237 | public void visit(OWLDifferentIndividualsAxiom axiom) { | ||
| 238 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 239 | process(axiom); | ||
| 240 | for (OWLIndividual ind : axiom.getIndividuals()) { | ||
| 241 | ind.accept(this); | ||
| 242 | } | ||
| 243 | } | ||
| 244 | |||
| 245 | |||
| 246 | @Override | ||
| 247 | public void visit(OWLDisjointClassesAxiom axiom) { | ||
| 248 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 249 | process(axiom); | ||
| 250 | for (OWLClassExpression desc : axiom.getClassExpressions()) { | ||
| 251 | desc.accept(this); | ||
| 252 | } | ||
| 253 | } | ||
| 254 | |||
| 255 | |||
| 256 | @Override | ||
| 257 | public void visit(OWLDisjointDataPropertiesAxiom axiom) { | ||
| 258 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 259 | process(axiom); | ||
| 260 | for (OWLDataPropertyExpression prop : axiom.getProperties()) { | ||
| 261 | prop.accept(this); | ||
| 262 | } | ||
| 263 | } | ||
| 264 | |||
| 265 | |||
| 266 | @Override | ||
| 267 | public void visit(OWLDisjointObjectPropertiesAxiom axiom) { | ||
| 268 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 269 | process(axiom); | ||
| 270 | for (OWLObjectPropertyExpression prop : axiom.getProperties()) { | ||
| 271 | prop.accept(this); | ||
| 272 | } | ||
| 273 | } | ||
| 274 | |||
| 275 | |||
| 276 | @Override | ||
| 277 | public void visit(OWLDisjointUnionAxiom axiom) { | ||
| 278 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 279 | process(axiom); | ||
| 280 | axiom.getOWLClass().accept(this); | ||
| 281 | for (OWLClassExpression desc : axiom.getClassExpressions()) { | ||
| 282 | desc.accept(this); | ||
| 283 | } | ||
| 284 | } | ||
| 285 | |||
| 286 | |||
| 287 | @Override | ||
| 288 | public void visit(OWLAnnotationAssertionAxiom axiom) { | ||
| 289 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 290 | process(axiom); | ||
| 291 | axiom.getSubject().accept(this); | ||
| 292 | axiom.getAnnotation().accept(this); | ||
| 293 | } | ||
| 294 | |||
| 295 | @Override | ||
| 296 | public void visit(OWLAnnotationPropertyDomainAxiom axiom) { | ||
| 297 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 298 | process(axiom); | ||
| 299 | axiom.getProperty().accept(this); | ||
| 300 | axiom.getDomain().accept(this); | ||
| 301 | } | ||
| 302 | |||
| 303 | @Override | ||
| 304 | public void visit(OWLAnnotationPropertyRangeAxiom axiom) { | ||
| 305 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 306 | process(axiom); | ||
| 307 | axiom.getProperty().accept(this); | ||
| 308 | axiom.getRange().accept(this); | ||
| 309 | } | ||
| 310 | |||
| 311 | @Override | ||
| 312 | public void visit(OWLSubAnnotationPropertyOfAxiom axiom) { | ||
| 313 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 314 | process(axiom); | ||
| 315 | axiom.getSubProperty().accept(this); | ||
| 316 | axiom.getSuperProperty().accept(this); | ||
| 317 | } | ||
| 318 | |||
| 319 | @Override | ||
| 320 | public void visit(OWLAnnotation node) { | ||
| 321 | process(node); | ||
| 322 | annotation = node; | ||
| 323 | node.getProperty().accept(this); | ||
| 324 | node.getValue().accept(this); | ||
| 325 | } | ||
| 326 | |||
| 327 | @Override | ||
| 328 | public void visit(OWLEquivalentClassesAxiom axiom) { | ||
| 329 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 330 | process(axiom); | ||
| 331 | for (OWLClassExpression desc : axiom.getClassExpressions()) { | ||
| 332 | desc.accept(this); | ||
| 333 | } | ||
| 334 | } | ||
| 335 | |||
| 336 | |||
| 337 | @Override | ||
| 338 | public void visit(OWLEquivalentDataPropertiesAxiom axiom) { | ||
| 339 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 340 | process(axiom); | ||
| 341 | for (OWLDataPropertyExpression prop : axiom.getProperties()) { | ||
| 342 | prop.accept(this); | ||
| 343 | } | ||
| 344 | } | ||
| 345 | |||
| 346 | |||
| 347 | @Override | ||
| 348 | public void visit(OWLEquivalentObjectPropertiesAxiom axiom) { | ||
| 349 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 350 | process(axiom); | ||
| 351 | for (OWLObjectPropertyExpression prop : axiom.getProperties()) { | ||
| 352 | prop.accept(this); | ||
| 353 | } | ||
| 354 | } | ||
| 355 | |||
| 356 | |||
| 357 | @Override | ||
| 358 | public void visit(OWLFunctionalDataPropertyAxiom axiom) { | ||
| 359 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 360 | process(axiom); | ||
| 361 | axiom.getProperty().accept(this); | ||
| 362 | } | ||
| 363 | |||
| 364 | |||
| 365 | @Override | ||
| 366 | public void visit(OWLFunctionalObjectPropertyAxiom axiom) { | ||
| 367 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 368 | process(axiom); | ||
| 369 | axiom.getProperty().accept(this); | ||
| 370 | } | ||
| 371 | |||
| 372 | @Override | ||
| 373 | public void visit(OWLInverseFunctionalObjectPropertyAxiom axiom) { | ||
| 374 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 375 | process(axiom); | ||
| 376 | axiom.getProperty().accept(this); | ||
| 377 | } | ||
| 378 | |||
| 379 | |||
| 380 | @Override | ||
| 381 | public void visit(OWLInverseObjectPropertiesAxiom axiom) { | ||
| 382 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 383 | process(axiom); | ||
| 384 | axiom.getFirstProperty().accept(this); | ||
| 385 | axiom.getSecondProperty().accept(this); | ||
| 386 | } | ||
| 387 | |||
| 388 | |||
| 389 | @Override | ||
| 390 | public void visit(OWLIrreflexiveObjectPropertyAxiom axiom) { | ||
| 391 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 392 | process(axiom); | ||
| 393 | axiom.getProperty().accept(this); | ||
| 394 | } | ||
| 395 | |||
| 396 | |||
| 397 | @Override | ||
| 398 | public void visit(OWLNegativeDataPropertyAssertionAxiom axiom) { | ||
| 399 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 400 | process(axiom); | ||
| 401 | axiom.getSubject().accept(this); | ||
| 402 | axiom.getProperty().accept(this); | ||
| 403 | axiom.getObject().accept(this); | ||
| 404 | } | ||
| 405 | |||
| 406 | |||
| 407 | @Override | ||
| 408 | public void visit(OWLNegativeObjectPropertyAssertionAxiom axiom) { | ||
| 409 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 410 | process(axiom); | ||
| 411 | axiom.getSubject().accept(this); | ||
| 412 | axiom.getProperty().accept(this); | ||
| 413 | axiom.getObject().accept(this); | ||
| 414 | } | ||
| 415 | |||
| 416 | |||
| 417 | @Override | ||
| 418 | public void visit(OWLObjectPropertyAssertionAxiom axiom) { | ||
| 419 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 420 | process(axiom); | ||
| 421 | axiom.getSubject().accept(this); | ||
| 422 | axiom.getProperty().accept(this); | ||
| 423 | axiom.getObject().accept(this); | ||
| 424 | } | ||
| 425 | |||
| 426 | |||
| 427 | @Override | ||
| 428 | public void visit(OWLSubPropertyChainOfAxiom axiom) { | ||
| 429 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 430 | process(axiom); | ||
| 431 | for (OWLObjectPropertyExpression prop : axiom.getPropertyChain()) { | ||
| 432 | prop.accept(this); | ||
| 433 | } | ||
| 434 | axiom.getSuperProperty().accept(this); | ||
| 435 | } | ||
| 436 | |||
| 437 | |||
| 438 | @Override | ||
| 439 | public void visit(OWLObjectPropertyDomainAxiom axiom) { | ||
| 440 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 441 | process(axiom); | ||
| 442 | axiom.getDomain().accept(this); | ||
| 443 | axiom.getProperty().accept(this); | ||
| 444 | } | ||
| 445 | |||
| 446 | |||
| 447 | @Override | ||
| 448 | public void visit(OWLObjectPropertyRangeAxiom axiom) { | ||
| 449 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 450 | process(axiom); | ||
| 451 | axiom.getProperty().accept(this); | ||
| 452 | axiom.getRange().accept(this); | ||
| 453 | } | ||
| 454 | |||
| 455 | |||
| 456 | @Override | ||
| 457 | public void visit(OWLSubObjectPropertyOfAxiom axiom) { | ||
| 458 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 459 | process(axiom); | ||
| 460 | axiom.getSubProperty().accept(this); | ||
| 461 | axiom.getSuperProperty().accept(this); | ||
| 462 | } | ||
| 463 | |||
| 464 | |||
| 465 | @Override | ||
| 466 | public void visit(OWLReflexiveObjectPropertyAxiom axiom) { | ||
| 467 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 468 | process(axiom); | ||
| 469 | axiom.getProperty().accept(this); | ||
| 470 | } | ||
| 471 | |||
| 472 | |||
| 473 | @Override | ||
| 474 | public void visit(OWLSameIndividualAxiom axiom) { | ||
| 475 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 476 | process(axiom); | ||
| 477 | for (OWLIndividual ind : axiom.getIndividuals()) { | ||
| 478 | ind.accept(this); | ||
| 479 | } | ||
| 480 | } | ||
| 481 | |||
| 482 | |||
| 483 | @Override | ||
| 484 | public void visit(OWLSubClassOfAxiom axiom) { | ||
| 485 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 486 | process(axiom); | ||
| 487 | // -ve polarity | ||
| 488 | axiom.getSubClass().accept(this); | ||
| 489 | // +ve polarity | ||
| 490 | axiom.getSuperClass().accept(this); | ||
| 491 | } | ||
| 492 | |||
| 493 | |||
| 494 | @Override | ||
| 495 | public void visit(OWLSymmetricObjectPropertyAxiom axiom) { | ||
| 496 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 497 | process(axiom); | ||
| 498 | axiom.getProperty().accept(this); | ||
| 499 | } | ||
| 500 | |||
| 501 | |||
| 502 | @Override | ||
| 503 | public void visit(OWLTransitiveObjectPropertyAxiom axiom) { | ||
| 504 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 505 | process(axiom); | ||
| 506 | axiom.getProperty().accept(this); | ||
| 507 | } | ||
| 508 | |||
| 509 | |||
| 510 | @Override | ||
| 511 | public void visit(SWRLRule rule) { | ||
| 512 | MyOWLOntologyWalker.this.ax = rule; | ||
| 513 | process(rule); | ||
| 514 | for (SWRLAtom at : rule.getBody()) { | ||
| 515 | at.accept(this); | ||
| 516 | } | ||
| 517 | for (SWRLAtom at : rule.getHead()) { | ||
| 518 | at.accept(this); | ||
| 519 | } | ||
| 520 | } | ||
| 521 | |||
| 522 | @Override | ||
| 523 | public void visit(OWLHasKeyAxiom axiom) { | ||
| 524 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 525 | process(axiom); | ||
| 526 | axiom.getClassExpression().accept(this); | ||
| 527 | for (OWLObjectPropertyExpression prop : axiom.getObjectPropertyExpressions()) { | ||
| 528 | prop.accept(this); | ||
| 529 | } | ||
| 530 | for (OWLDataPropertyExpression prop : axiom.getDataPropertyExpressions()) { | ||
| 531 | prop.accept(this); | ||
| 532 | } | ||
| 533 | } | ||
| 534 | |||
| 535 | @Override | ||
| 536 | public void visit(OWLClass desc) { | ||
| 537 | pushClassExpression(desc); | ||
| 538 | process(desc); | ||
| 539 | desc.getIRI().accept(this); | ||
| 540 | popClassExpression(); | ||
| 541 | } | ||
| 542 | |||
| 543 | |||
| 544 | @Override | ||
| 545 | public void visit(OWLDataAllValuesFrom desc) { | ||
| 546 | pushClassExpression(desc); | ||
| 547 | process(desc); | ||
| 548 | desc.getProperty().accept(this); | ||
| 549 | desc.getFiller().accept(this); | ||
| 550 | popClassExpression(); | ||
| 551 | } | ||
| 552 | |||
| 553 | |||
| 554 | @Override | ||
| 555 | public void visit(OWLDataExactCardinality desc) { | ||
| 556 | pushClassExpression(desc); | ||
| 557 | process(desc); | ||
| 558 | desc.getProperty().accept(this); | ||
| 559 | desc.getFiller().accept(this); | ||
| 560 | popClassExpression(); | ||
| 561 | } | ||
| 562 | |||
| 563 | |||
| 564 | @Override | ||
| 565 | public void visit(OWLDataMaxCardinality desc) { | ||
| 566 | pushClassExpression(desc); | ||
| 567 | process(desc); | ||
| 568 | desc.getProperty().accept(this); | ||
| 569 | desc.getFiller().accept(this); | ||
| 570 | popClassExpression(); | ||
| 571 | } | ||
| 572 | |||
| 573 | |||
| 574 | @Override | ||
| 575 | public void visit(OWLDataMinCardinality desc) { | ||
| 576 | pushClassExpression(desc); | ||
| 577 | process(desc); | ||
| 578 | desc.getProperty().accept(this); | ||
| 579 | desc.getFiller().accept(this); | ||
| 580 | popClassExpression(); | ||
| 581 | } | ||
| 582 | |||
| 583 | |||
| 584 | @Override | ||
| 585 | public void visit(OWLDataSomeValuesFrom desc) { | ||
| 586 | pushClassExpression(desc); | ||
| 587 | process(desc); | ||
| 588 | desc.getProperty().accept(this); | ||
| 589 | desc.getFiller().accept(this); | ||
| 590 | popClassExpression(); | ||
| 591 | } | ||
| 592 | |||
| 593 | |||
| 594 | @Override | ||
| 595 | public void visit(OWLDataHasValue desc) { | ||
| 596 | pushClassExpression(desc); | ||
| 597 | process(desc); | ||
| 598 | desc.getProperty().accept(this); | ||
| 599 | desc.getValue().accept(this); | ||
| 600 | popClassExpression(); | ||
| 601 | } | ||
| 602 | |||
| 603 | |||
| 604 | @Override | ||
| 605 | public void visit(OWLObjectAllValuesFrom desc) { | ||
| 606 | pushClassExpression(desc); | ||
| 607 | process(desc); | ||
| 608 | desc.getProperty().accept(this); | ||
| 609 | desc.getFiller().accept(this); | ||
| 610 | popClassExpression(); | ||
| 611 | } | ||
| 612 | |||
| 613 | |||
| 614 | @Override | ||
| 615 | public void visit(OWLObjectComplementOf desc) { | ||
| 616 | pushClassExpression(desc); | ||
| 617 | process(desc); | ||
| 618 | desc.getOperand().accept(this); | ||
| 619 | popClassExpression(); | ||
| 620 | } | ||
| 621 | |||
| 622 | |||
| 623 | @Override | ||
| 624 | public void visit(OWLObjectExactCardinality desc) { | ||
| 625 | pushClassExpression(desc); | ||
| 626 | process(desc); | ||
| 627 | desc.getProperty().accept(this); | ||
| 628 | desc.getFiller().accept(this); | ||
| 629 | popClassExpression(); | ||
| 630 | } | ||
| 631 | |||
| 632 | |||
| 633 | @Override | ||
| 634 | public void visit(OWLObjectIntersectionOf desc) { | ||
| 635 | pushClassExpression(desc); | ||
| 636 | process(desc); | ||
| 637 | |||
| 638 | for (OWLClassExpression op : desc.getOperands()) { | ||
| 639 | op.accept(this); | ||
| 640 | } | ||
| 641 | popClassExpression(); | ||
| 642 | } | ||
| 643 | |||
| 644 | |||
| 645 | @Override | ||
| 646 | public void visit(OWLObjectMaxCardinality desc) { | ||
| 647 | pushClassExpression(desc); | ||
| 648 | process(desc); | ||
| 649 | desc.getProperty().accept(this); | ||
| 650 | desc.getFiller().accept(this); | ||
| 651 | popClassExpression(); | ||
| 652 | } | ||
| 653 | |||
| 654 | |||
| 655 | @Override | ||
| 656 | public void visit(OWLObjectMinCardinality desc) { | ||
| 657 | pushClassExpression(desc); | ||
| 658 | process(desc); | ||
| 659 | desc.getProperty().accept(this); | ||
| 660 | desc.getFiller().accept(this); | ||
| 661 | popClassExpression(); | ||
| 662 | } | ||
| 663 | |||
| 664 | |||
| 665 | @Override | ||
| 666 | public void visit(OWLObjectOneOf desc) { | ||
| 667 | pushClassExpression(desc); | ||
| 668 | process(desc); | ||
| 669 | for (OWLIndividual ind : desc.getIndividuals()) { | ||
| 670 | ind.accept(this); | ||
| 671 | } | ||
| 672 | popClassExpression(); | ||
| 673 | } | ||
| 674 | |||
| 675 | |||
| 676 | @Override | ||
| 677 | public void visit(OWLObjectHasSelf desc) { | ||
| 678 | pushClassExpression(desc); | ||
| 679 | process(desc); | ||
| 680 | desc.getProperty().accept(this); | ||
| 681 | popClassExpression(); | ||
| 682 | } | ||
| 683 | |||
| 684 | |||
| 685 | @Override | ||
| 686 | public void visit(OWLObjectSomeValuesFrom desc) { | ||
| 687 | pushClassExpression(desc); | ||
| 688 | process(desc); | ||
| 689 | desc.getProperty().accept(this); | ||
| 690 | desc.getFiller().accept(this); | ||
| 691 | popClassExpression(); | ||
| 692 | } | ||
| 693 | |||
| 694 | |||
| 695 | @Override | ||
| 696 | public void visit(OWLObjectUnionOf desc) { | ||
| 697 | pushClassExpression(desc); | ||
| 698 | process(desc); | ||
| 699 | for (OWLClassExpression op : desc.getOperands()) { | ||
| 700 | op.accept(this); | ||
| 701 | } | ||
| 702 | popClassExpression(); | ||
| 703 | } | ||
| 704 | |||
| 705 | |||
| 706 | @Override | ||
| 707 | public void visit(OWLObjectHasValue desc) { | ||
| 708 | pushClassExpression(desc); | ||
| 709 | process(desc); | ||
| 710 | desc.getProperty().accept(this); | ||
| 711 | desc.getValue().accept(this); | ||
| 712 | popClassExpression(); | ||
| 713 | } | ||
| 714 | |||
| 715 | |||
| 716 | @Override | ||
| 717 | public void visit(OWLDataComplementOf node) { | ||
| 718 | pushDataRange(node); | ||
| 719 | process(node); | ||
| 720 | node.getDataRange().accept(this); | ||
| 721 | popDataRange(); | ||
| 722 | } | ||
| 723 | |||
| 724 | |||
| 725 | @Override | ||
| 726 | public void visit(OWLDataOneOf node) { | ||
| 727 | pushDataRange(node); | ||
| 728 | process(node); | ||
| 729 | for (OWLLiteral con : node.getValues()) { | ||
| 730 | con.accept(this); | ||
| 731 | } | ||
| 732 | popDataRange(); | ||
| 733 | } | ||
| 734 | |||
| 735 | @Override | ||
| 736 | public void visit(OWLDataIntersectionOf node) { | ||
| 737 | pushDataRange(node); | ||
| 738 | process(node); | ||
| 739 | for (OWLDataRange rng : node.getOperands()) { | ||
| 740 | rng.accept(this); | ||
| 741 | } | ||
| 742 | popDataRange(); | ||
| 743 | } | ||
| 744 | |||
| 745 | @Override | ||
| 746 | public void visit(OWLDataUnionOf node) { | ||
| 747 | pushDataRange(node); | ||
| 748 | process(node); | ||
| 749 | for (OWLDataRange rng : node.getOperands()) { | ||
| 750 | rng.accept(this); | ||
| 751 | } | ||
| 752 | popDataRange(); | ||
| 753 | } | ||
| 754 | |||
| 755 | @Override | ||
| 756 | public void visit(OWLFacetRestriction node) { | ||
| 757 | process(node); | ||
| 758 | node.getFacetValue().accept(this); | ||
| 759 | } | ||
| 760 | |||
| 761 | |||
| 762 | @Override | ||
| 763 | public void visit(OWLDatatypeRestriction node) { | ||
| 764 | pushDataRange(node); | ||
| 765 | process(node); | ||
| 766 | node.getDatatype().accept(this); | ||
| 767 | for (OWLFacetRestriction fr : node.getFacetRestrictions()) { | ||
| 768 | fr.accept(this); | ||
| 769 | } | ||
| 770 | popDataRange(); | ||
| 771 | } | ||
| 772 | |||
| 773 | |||
| 774 | @Override | ||
| 775 | public void visit(OWLDatatype node) { | ||
| 776 | pushDataRange(node); | ||
| 777 | process(node); | ||
| 778 | popDataRange(); | ||
| 779 | } | ||
| 780 | |||
| 781 | @Override | ||
| 782 | public void visit(OWLLiteral node) { | ||
| 783 | process(node); | ||
| 784 | node.getDatatype().accept(this); | ||
| 785 | popDataRange(); | ||
| 786 | } | ||
| 787 | |||
| 788 | @Override | ||
| 789 | public void visit(OWLAnnotationProperty property) { | ||
| 790 | process(property); | ||
| 791 | property.getIRI().accept(this); | ||
| 792 | } | ||
| 793 | |||
| 794 | @Override | ||
| 795 | public void visit(OWLDataProperty property) { | ||
| 796 | process(property); | ||
| 797 | property.getIRI().accept(this); | ||
| 798 | } | ||
| 799 | |||
| 800 | |||
| 801 | @Override | ||
| 802 | public void visit(OWLObjectProperty property) { | ||
| 803 | process(property); | ||
| 804 | property.getIRI().accept(this); | ||
| 805 | } | ||
| 806 | |||
| 807 | |||
| 808 | @Override | ||
| 809 | public void visit(OWLObjectInverseOf property) { | ||
| 810 | process(property); | ||
| 811 | property.getInverse().accept(this); | ||
| 812 | } | ||
| 813 | |||
| 814 | |||
| 815 | @Override | ||
| 816 | public void visit(OWLNamedIndividual individual) { | ||
| 817 | process(individual); | ||
| 818 | individual.getIRI().accept(this); | ||
| 819 | } | ||
| 820 | |||
| 821 | @Override | ||
| 822 | public void visit(OWLAnonymousIndividual individual) { | ||
| 823 | process(individual); | ||
| 824 | } | ||
| 825 | |||
| 826 | @Override | ||
| 827 | public void visit(SWRLLiteralArgument node) { | ||
| 828 | process(node); | ||
| 829 | node.getLiteral().accept(this); | ||
| 830 | } | ||
| 831 | |||
| 832 | |||
| 833 | @Override | ||
| 834 | public void visit(SWRLVariable node) { | ||
| 835 | process(node); | ||
| 836 | } | ||
| 837 | |||
| 838 | |||
| 839 | @Override | ||
| 840 | public void visit(SWRLIndividualArgument node) { | ||
| 841 | process(node); | ||
| 842 | node.getIndividual().accept(this); | ||
| 843 | } | ||
| 844 | |||
| 845 | |||
| 846 | @Override | ||
| 847 | public void visit(SWRLBuiltInAtom node) { | ||
| 848 | process(node); | ||
| 849 | for (SWRLDArgument at : node.getArguments()) { | ||
| 850 | at.accept(this); | ||
| 851 | } | ||
| 852 | } | ||
| 853 | |||
| 854 | |||
| 855 | @Override | ||
| 856 | public void visit(SWRLClassAtom node) { | ||
| 857 | process(node); | ||
| 858 | node.getArgument().accept(this); | ||
| 859 | node.getPredicate().accept(this); | ||
| 860 | } | ||
| 861 | |||
| 862 | |||
| 863 | @Override | ||
| 864 | public void visit(SWRLDataRangeAtom node) { | ||
| 865 | process(node); | ||
| 866 | node.getArgument().accept(this); | ||
| 867 | node.getPredicate().accept(this); | ||
| 868 | } | ||
| 869 | |||
| 870 | |||
| 871 | @Override | ||
| 872 | public void visit(SWRLDataPropertyAtom node) { | ||
| 873 | process(node); | ||
| 874 | node.getPredicate().accept(this); | ||
| 875 | node.getFirstArgument().accept(this); | ||
| 876 | node.getSecondArgument().accept(this); | ||
| 877 | } | ||
| 878 | |||
| 879 | |||
| 880 | @Override | ||
| 881 | public void visit(SWRLDifferentIndividualsAtom node) { | ||
| 882 | process(node); | ||
| 883 | node.getFirstArgument().accept(this); | ||
| 884 | node.getSecondArgument().accept(this); | ||
| 885 | } | ||
| 886 | |||
| 887 | |||
| 888 | @Override | ||
| 889 | public void visit(SWRLObjectPropertyAtom node) { | ||
| 890 | process(node); | ||
| 891 | node.getPredicate().accept(this); | ||
| 892 | node.getFirstArgument().accept(this); | ||
| 893 | node.getSecondArgument().accept(this); | ||
| 894 | } | ||
| 895 | |||
| 896 | |||
| 897 | @Override | ||
| 898 | public void visit(SWRLSameIndividualAtom node) { | ||
| 899 | process(node); | ||
| 900 | node.getFirstArgument().accept(this); | ||
| 901 | node.getSecondArgument().accept(this); | ||
| 902 | } | ||
| 903 | |||
| 904 | |||
| 905 | @Override | ||
| 906 | public void visit(OWLDatatypeDefinitionAxiom axiom) { | ||
| 907 | MyOWLOntologyWalker.this.ax = axiom; | ||
| 908 | process(axiom); | ||
| 909 | axiom.getDatatype().accept(this); | ||
| 910 | axiom.getDataRange().accept(this); | ||
| 911 | } | ||
| 912 | } | ||
| 913 | } | ||
| 914 | |||
