コード例 #1
0
  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;
  }
コード例 #2
0
  public void retrieveSubObjectPropertyAxioms() {
    // this method is to perform a dual operation; it shall retrieve all the declarative object
    // properties categories' annotations,
    // thus filling the objPropCategories Set, while parallelly will, for each category entry
    // retrieve the object properties themselves
    // and adding their entries in the objPropEntries Set.
    Set<OWLSubObjectPropertyOfAxiom> tmpSet;
    OWLObjectPropertyExpression tempDeclarativePropertyClass =
        OWLFactory.getOWLObjectProperty(":DeclarativeProperty", topIxPrefixManager);
    tmpSet =
        topIxOnt.getObjectSubPropertyAxiomsForSuperProperty(
            tempDeclarativePropertyClass); // OWLFactory.getOWLObjectProperty(IRI.create("http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl#DeclarativeProperty")));
    Set<OWLSubObjectPropertyOfAxiom> tmpSet2;

    Set<OWLAnnotationAssertionAxiom> tmpAnnSet1;
    Set<OWLAnnotationAssertionAxiom> tmpAnnSet2;
    // to become class variables.

    for (OWLSubObjectPropertyOfAxiom sopAx : tmpSet) {
      String tmpS = sopAx.getSubProperty().toString();
      // categories...
      tmpAnnSet1 =
          topIxOnt.getAnnotationAssertionAxioms(
              IRI.create(
                  tmpS.substring(
                      1, tmpS.indexOf('>')))); // this set only contains one annotation per entry
      for (OWLAnnotationAssertionAxiom aaAx : tmpAnnSet1) {
        String currentObjPropCatName =
            aaAx.getValue().toString().substring(1, aaAx.getValue().toString().indexOf('^') - 1);

        tmpSet2 =
            topIxOnt.getObjectSubPropertyAxiomsForSuperProperty(
                OWLFactory.getOWLObjectProperty(IRI.create(tmpS.substring(1, tmpS.length() - 1))));
        for (OWLSubObjectPropertyOfAxiom sopAx2 : tmpSet2) {
          String tmpS2 = sopAx2.getSubProperty().toString();
          tmpAnnSet2 =
              topIxOnt.getAnnotationAssertionAxioms(
                  IRI.create(tmpS2.substring(1, tmpS2.length() - 1)));

          for (OWLAnnotationAssertionAxiom aaAx2 : tmpAnnSet2) {
            String currentObjPropEntryName =
                aaAx2
                    .getValue()
                    .toString()
                    .substring(1, aaAx2.getValue().toString().indexOf('^') - 1);
            propEntryNameToPropCatName.put(currentObjPropEntryName, currentObjPropCatName);
            propEntryNametoPropEntryIRI.put(
                currentObjPropEntryName, tmpS2.substring(1, tmpS2.length() - 1));
          }
        }
      }
    }
  }
コード例 #3
0
  public void retrieveRoomsMap() {
    // this method retrieves the rooms to be insserted in the two rooms lists.
    // it deposits the retrieved data in a map where the key is the room name (String) and the value
    // is the corresponding entity IRI.
    // the above data structure will be used in passing the entity IRIs in the jess working memory
    // when constructing the facts
    // when the respective room name (String) is selected in the rooms list combo box.

    for (OWLSubClassOfAxiom scoAx :
        topIxOnt.getSubClassAxiomsForSuperClass(
            OWLFactory.getOWLClass(
                IRI.create(
                    "http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl#Room")))) {
      String tmpS = scoAx.getSubClass().toString();

      Set<OWLAnnotationAssertionAxiom> tmpAnnSet =
          topIxOnt.getAnnotationAssertionAxioms(
              IRI.create(tmpS.substring(tmpS.indexOf('<') + 1, tmpS.indexOf('>'))));
      for (OWLAnnotationAssertionAxiom aaAx : tmpAnnSet) {
        if (aaAx.getProperty()
            .toString()
            .equals(
                "<http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl#classID>")) {
          roomToIRI.put(
              aaAx.getValue().toString().substring(1, aaAx.getValue().toString().indexOf('^') - 1),
              tmpS.substring(tmpS.indexOf('<') + 1, tmpS.indexOf('>')));
        }
      }
    }
  }
コード例 #4
0
 //////////////////////////////
 // PROPERTY ASSERTION METHODS//
 //////////////////////////////
 public boolean assertPropertyInstance(
     String comboBoxObjectPropertyEntry, String room1Hash, String room2Hash) {
   OWLObjectProperty objProp =
       OWLFactory.getOWLObjectProperty(
           IRI.create(propEntryNametoPropEntryIRI.get(comboBoxObjectPropertyEntry)));
   OWLIndividual room1Individual =
       OWLFactory.getOWLNamedIndividual(':' + room1Hash, topIxPrefixManager);
   OWLIndividual room2Individual =
       OWLFactory.getOWLNamedIndividual(':' + room2Hash, topIxPrefixManager);
   manager.addAxiom(
       topIxOnt,
       OWLFactory.getOWLObjectPropertyAssertionAxiom(objProp, room1Individual, room2Individual));
   return true;
 }
コード例 #5
0
  // 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);
        }
      }
    }
  }
コード例 #6
0
  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;
  }