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; }
//////////////////////////////// // INDIVIDUAL ASSERTION METHODS// //////////////////////////////// public boolean assertSiteIndividual(String siteNameHash, String siteNameAnnotation) { OWLClassExpression tmpCE = OWLFactory.getOWLClass(":Site", topIxPrefixManager); OWLIndividual tmpInd = OWLFactory.getOWLNamedIndividual(':' + siteNameHash, topIxPrefixManager); manager.addAxiom(topIxOnt, OWLFactory.getOWLClassAssertionAxiom(tmpCE, tmpInd)); manager.addAxiom( topIxOnt, OWLFactory.getOWLAnnotationAssertionAxiom( OWLFactory.getOWLAnnotationProperty( IRI.create( topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + "individualName")), IRI.create(topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + siteNameHash), OWLFactory.getOWLLiteral(siteNameAnnotation))); return true; }
// this method retrieves all the geometric properties that have been // pre-designated as "house setable" or "room setable", // that is, if a geometric property is available for houses, it has been // annotated as "houseSetable", for rooms, "roomSetable" and for both it // has been designated with both annotations. public void retrieveGeometricPropertiesMaps() { OWLDataProperty geometricProperty = OWLFactory.getOWLDataProperty(":GeometricProperty", topIxPrefixManager); OWLAnnotationProperty propertyID = OWLFactory.getOWLAnnotationProperty(":propertyID", topIxPrefixManager); logger.info(propertyID); OWLAnnotationProperty houseSetable = OWLFactory.getOWLAnnotationProperty(":houseSetable", topIxPrefixManager); OWLAnnotationProperty roomSetable = OWLFactory.getOWLAnnotationProperty(":roomSetable", topIxPrefixManager); Set<OWLSubDataPropertyOfAxiom> tempGeometricDataPropertiesSet = topIxOnt.getDataSubPropertyAxiomsForSuperProperty(geometricProperty); for (OWLSubDataPropertyOfAxiom tempGeomPropAxiom : tempGeometricDataPropertiesSet) { OWLDataProperty tempDataProperty = tempGeomPropAxiom.getSubProperty().asOWLDataProperty(); // the following two local vars will become an entry for geometricPropertiesMap String tempString = tempDataProperty.getAnnotations(topIxOnt, propertyID).toString(); tempString = tempString.substring(tempString.indexOf('"') + 1, tempString.indexOf("^") - 1); IRI tempIRI = tempGeomPropAxiom.getSubProperty().asOWLDataProperty().getIRI(); geometricPropertiesMap.put(tempString, tempIRI); // the following code decides whether the above entry should also be contained // in the houseSetableGeometricPropertiesMap Set<OWLAnnotation> tempDataPropAnnotationSet = tempDataProperty.getAnnotations(topIxOnt); for (OWLAnnotation tempDataPropAnnotation : tempDataPropAnnotationSet) { if (tempDataPropAnnotation.getProperty() == houseSetable && tempDataPropAnnotation.getValue().toString().equals("\"true\"^^xsd:boolean")) { houseSetableGeometricPropertiesMap.put(tempString, tempIRI); } if (tempDataPropAnnotation.getProperty() == roomSetable && tempDataPropAnnotation.getValue().toString().equals("\"true\"^^xsd:boolean")) { roomSetableGeometricPropertiesMap.put(tempString, tempIRI); } } } }
public boolean assertHouseIndividual(String houseEntryHash, String houseEntryAnnotation) { OWLClassExpression tempClassExpression = OWLFactory.getOWLClass(":House", topIxPrefixManager); OWLIndividual tempIndividual = OWLFactory.getOWLNamedIndividual(':' + houseEntryHash, topIxPrefixManager); manager.addAxiom( topIxOnt, OWLFactory.getOWLClassAssertionAxiom(tempClassExpression, tempIndividual)); manager.addAxiom( topIxOnt, OWLFactory.getOWLAnnotationAssertionAxiom( OWLFactory.getOWLAnnotationProperty( IRI.create( topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + "individualName")), IRI.create(topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + houseEntryHash), OWLFactory.getOWLLiteral(houseEntryAnnotation))); return true; }
public boolean assertRoomIndividual( String roomName, String roomIndividualHash, String roomIndividualAnnotation) { OWLClassExpression tempClassExpression = OWLFactory.getOWLClass( IRI.create( roomToIRI.get( roomName))); // retrieves the Room Class IRI fron the roomToIRI map, using // roomID as a key. OWLIndividual tempIndividual = OWLFactory.getOWLNamedIndividual(':' + roomIndividualHash, topIxPrefixManager); manager.addAxiom( topIxOnt, OWLFactory.getOWLClassAssertionAxiom(tempClassExpression, tempIndividual)); manager.addAxiom( topIxOnt, OWLFactory.getOWLAnnotationAssertionAxiom( OWLFactory.getOWLAnnotationProperty( IRI.create( topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + "individualName")), IRI.create( topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + roomIndividualHash), OWLFactory.getOWLLiteral(String.format(roomIndividualAnnotation)))); return true; }