public Map<String, OWLIndividual> returnSitesInOntology() { // map that contains the correspondance between the names of the sites // and their OWLIndividual representations. Map<String, OWLIndividual> returnMap = new HashMap<>(); List<OWLIndividual> returnList = new ArrayList<>(); OWLAnnotationProperty hasNameAnnotationProperty = OWLFactory.getOWLAnnotationProperty(":individualName", topIxPrefixManager); OWLClassExpression tempSiteClassExpression = OWLFactory.getOWLClass(":Site", topIxPrefixManager); for (OWLClassAssertionAxiom tempClassAssAx : topIxOnt.getClassAssertionAxioms(tempSiteClassExpression)) { returnList.add(tempClassAssAx.getIndividual()); Set<OWLAnnotationAssertionAxiom> tempSiteAnnotationsSet = topIxOnt.getAnnotationAssertionAxioms( tempClassAssAx.getIndividual().asOWLNamedIndividual().getIRI()); for (OWLAnnotationAssertionAxiom tempAnnotationAssertionAxiom : tempSiteAnnotationsSet) { if (tempAnnotationAssertionAxiom.getProperty().equals(hasNameAnnotationProperty)) { String tempString = tempAnnotationAssertionAxiom.getValue().toString(); logger.info(tempString); tempString = tempString.substring(tempString.indexOf('"') + 1, tempString.indexOf('^') - 1); logger.info(tempString); logger.info(tempClassAssAx.getIndividual().toString()); returnMap.put(tempString, tempClassAssAx.getIndividual()); } } } return returnMap; }
public void visit(OWLClassAssertionAxiom axiom) { addChildParent(axiom.getIndividual(), axiom.getClassExpression(), axiom); axiom.getClassExpression().accept(this); }