コード例 #1
0
 public boolean assertDataPropertyInstance(String ind, String prop, int value) {
   OWLDataProperty dataProp =
       OWLFactory.getOWLDataProperty(
           IRI.create(topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + prop));
   OWLDataPropertyAssertionAxiom tmpAx =
       OWLFactory.getOWLDataPropertyAssertionAxiom(
           dataProp,
           OWLFactory.getOWLNamedIndividual(
               IRI.create(topIxOnt.getOntologyID().getOntologyIRI().toString() + '#' + ind)),
           OWLFactory.getOWLLiteral(value));
   manager.addAxiom(topIxOnt, tmpAx);
   return true;
 }
コード例 #2
0
  public boolean storeSolutions(String siteNameHash) {
    for (OwlSolution tempSolution : solutionsList) {
      // assert Solution individual and assert Site->hasSolution
      OWLClassExpression solutionClassExpression =
          OWLFactory.getOWLClass(":Solution", topIxPrefixManager);
      String tempSolutionID =
          String.format(siteNameHash + "_S_%1$02d", tempSolution.getSolutionID().intValue());
      OWLIndividual tempSolutionIndividual =
          OWLFactory.getOWLNamedIndividual(":" + tempSolutionID, topIxPrefixManager);
      OWLClassAssertionAxiom tempClassAssertionAxiom =
          OWLFactory.getOWLClassAssertionAxiom(solutionClassExpression, tempSolutionIndividual);
      manager.addAxiom(topIxOnt, tempClassAssertionAxiom);

      OWLObjectProperty tempSolutionObjectProperty =
          OWLFactory.getOWLObjectProperty(":hasSolution", topIxPrefixManager);
      OWLIndividual tempSiteIndividual =
          OWLFactory.getOWLNamedIndividual(":" + siteNameHash, topIxPrefixManager);
      OWLObjectPropertyAssertionAxiom tempObjPropAssAxiom =
          OWLFactory.getOWLObjectPropertyAssertionAxiom(
              tempSolutionObjectProperty, tempSiteIndividual, tempSolutionIndividual);
      manager.addAxiom(topIxOnt, tempObjPropAssAxiom);

      // assert SolvedHouse individuals and assert Solution->hasSolvedHouse objProperty. also assert
      // the DATA PROPERTIES for each solvedHouse indvidual
      for (OwlSolvedHouse tempSolvedHouse : tempSolution.getSolvedHouses()) {
        // logger.info("373");
        // logger.info(tempSolution.getSolvedHouses().toString());
        OWLClassExpression solvedHouseClassExpression =
            OWLFactory.getOWLClass(":SolvedHouse", topIxPrefixManager);
        OWLIndividual tempSolvedHouseIndividual =
            OWLFactory.getOWLNamedIndividual(
                ":" + tempSolutionID + "_SH_" + tempSolvedHouse.getSolvedHouseHash(),
                topIxPrefixManager);
        OWLClassAssertionAxiom tempClassAssAx =
            OWLFactory.getOWLClassAssertionAxiom(
                solvedHouseClassExpression, tempSolvedHouseIndividual);
        manager.addAxiom(topIxOnt, tempClassAssAx);

        OWLObjectProperty tempSolvedHouseObjectProperty =
            OWLFactory.getOWLObjectProperty(":hasSolvedHouse", topIxPrefixManager);
        OWLObjectPropertyAssertionAxiom tempHouseObjPropAssAx =
            OWLFactory.getOWLObjectPropertyAssertionAxiom(
                tempSolvedHouseObjectProperty, tempSolutionIndividual, tempSolvedHouseIndividual);
        manager.addAxiom(topIxOnt, tempHouseObjPropAssAx);

        OWLDataProperty tempDataProperty;
        OWLDataPropertyAssertionAxiom tempDataPropertyAssertionAxiom;

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasLiteral", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty,
                tempSolvedHouseIndividual,
                tempSolvedHouse.getSolvedHouseLiteral());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasL", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty,
                tempSolvedHouseIndividual,
                tempSolvedHouse.getSolvedHouseLength());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasW", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedHouseIndividual, tempSolvedHouse.getSolvedHouseWidth());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedHouseIndividual, tempSolvedHouse.getSolvedHouseX());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedHouseIndividual, tempSolvedHouse.getSolvedHouseY());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);
        // logger.info("asserts the house");
        // logger.info(tempSolvedHouse.getSolvedHouseLiteral());
      }

      // assert SolvedRoom individuals and assert Solution->hasSolvedRoom objProperty. also assert
      // the DATA PROPERTIES for each solvedRoom indvidual
      for (OwlSolvedRoom tempSolvedRoom : tempSolution.getSolvedRooms()) {
        OWLClassExpression solvedRoomClassExpression =
            OWLFactory.getOWLClass(":SolvedRoom", topIxPrefixManager);
        OWLIndividual tempSolvedRoomIndividual =
            OWLFactory.getOWLNamedIndividual(
                ":" + tempSolutionID + "_SR_" + tempSolvedRoom.getSolvedRoomHash(),
                topIxPrefixManager);
        OWLClassAssertionAxiom tempClassAssAx =
            OWLFactory.getOWLClassAssertionAxiom(
                solvedRoomClassExpression, tempSolvedRoomIndividual);
        manager.addAxiom(topIxOnt, tempClassAssAx);

        OWLObjectProperty tempSolvedRoomObjectProperty =
            OWLFactory.getOWLObjectProperty(":hasSolvedRoom", topIxPrefixManager);
        OWLObjectPropertyAssertionAxiom tempRoomObjPropAssAx =
            OWLFactory.getOWLObjectPropertyAssertionAxiom(
                tempSolvedRoomObjectProperty, tempSolutionIndividual, tempSolvedRoomIndividual);
        manager.addAxiom(topIxOnt, tempRoomObjPropAssAx);

        OWLDataProperty tempDataProperty;
        OWLDataPropertyAssertionAxiom tempDataPropertyAssertionAxiom;

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasLiteral", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomLiteral());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasL", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomLength());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasW", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomWidth());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasH", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomHeight());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomX());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomY());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);

        tempDataProperty = OWLFactory.getOWLDataProperty(":hasZ", topIxPrefixManager);
        tempDataPropertyAssertionAxiom =
            OWLFactory.getOWLDataPropertyAssertionAxiom(
                tempDataProperty, tempSolvedRoomIndividual, tempSolvedRoom.getSolvedRoomZ());
        manager.addAxiom(topIxOnt, tempDataPropertyAssertionAxiom);
      }
    }
    return true;
  }