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('>')));
        }
      }
    }
  }
  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));
          }
        }
      }
    }
  }
 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;
 }
  ////////////////////////////////
  // 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;
  }
  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 void loadOntology() {
    try {
      /*
       * --apaitoymena vimata gia th dhmioyrgia mapped ontologias:
       * 1.dhmioyrgoyme ena toBeMappedIRI me skopo toy thn antistoixish me
       * to local File. 2.dhmioyrgoyme ena File me th dieythynsh ths
       * ontologias sto topiko apothikeytiko meso. 3.dhmioyrgoyme enan
       * SimpleIRIMapper kai ton prosthetoyme mesw toy manager. o
       * SimpleIRIMapper syndeei to toBeMappedIRI poy dwsame arxika, me
       * thn fysikh topothesia ths ontologias sto topiko apothikeytiko
       * meso. 4.dhmioyrgoyme ena ontologyIRI me akrivws thn idia arxiki
       * timh me to toBeMappedIRI to opoio tha einai to IRI ths ontologias
       * mas 5.dhmioyrgoyme thn ontologia mas xrhsimopoiwntas to
       * manager.loadOntology(ontologyIRI);
       */
      String sep = File.separator;

      manager = OWLManager.createOWLOntologyManager();
      toBeMappedIRI =
          IRI.create(
              "http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl");
      // ontFile = new File("../src/ontologyresources/ptyxiaki_v0.8.owl");
      ontFile = new File("src/ontologyresources/ptyxiaki_v0.8.owl");
      // in case of alternative location on load time when the application is jar'ed!
      if (!ontFile.canRead()) {
        ontFile = new File("ontologyresources/ptyxiaki_v0.8.owl");
      }
      manager.addIRIMapper(new SimpleIRIMapper(toBeMappedIRI, IRI.create(ontFile)));
      ontologyIRI =
          IRI.create(
              "http://www.semanticweb.org/ontologies/ptyxiaki_v0.6/2011/5/Ontology1308067064597.owl");
      topIxOnt = manager.loadOntology(ontologyIRI);
      OWLFactory = manager.getOWLDataFactory();
      topIxFormat = manager.getOntologyFormat(topIxOnt);
      topIxPrefixManager =
          new DefaultPrefixManager(topIxOnt.getOntologyID().getOntologyIRI().toString() + '#');

      System.out.println("loaded ontology: " + this.topIxOnt);
      System.out.println("from: " + this.manager.getOntologyDocumentIRI(this.topIxOnt));

    } catch (OWLException oex) {
      logger.info(oex.getMessage());
    }
  }
 // asserts a hasHouse property instance between a house and its corresponding
 // site
 public boolean assertHasHousePropertyInstance(String houseEntryHash, String siteNameHash) {
   OWLObjectProperty objProp =
       OWLFactory.getOWLObjectProperty(
           IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasHouse"));
   OWLIndividual houseIndividual =
       OWLFactory.getOWLNamedIndividual(':' + houseEntryHash, topIxPrefixManager);
   OWLIndividual siteIndividual =
       OWLFactory.getOWLNamedIndividual(':' + siteNameHash, topIxPrefixManager);
   manager.addAxiom(
       topIxOnt,
       OWLFactory.getOWLObjectPropertyAssertionAxiom(objProp, siteIndividual, houseIndividual));
   return true;
 }
 //////////////////////////////
 // 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;
 }
 public boolean assertHasRoomPropertyInstance(
     String houseIndividualHash, String roomIndividualHash) {
   OWLObjectProperty tempOWLbjectProperty =
       OWLFactory.getOWLObjectProperty(
           IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasRoom"));
   OWLIndividual houseIndividual =
       OWLFactory.getOWLNamedIndividual(':' + houseIndividualHash, topIxPrefixManager);
   OWLIndividual roomIndividual =
       OWLFactory.getOWLNamedIndividual(':' + roomIndividualHash, topIxPrefixManager);
   manager.addAxiom(
       topIxOnt,
       OWLFactory.getOWLObjectPropertyAssertionAxiom(
           tempOWLbjectProperty, houseIndividual, roomIndividual));
   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;
  }
  public boolean retrieveSolutions(String siteNameHash) {
    // use the siteNameHash to access a certain Site individual in the ontology
    // retrieve each Solution individual of this site and use it to re-initialise the Solutions List
    OwlSolution tempSolution;
    OwlSolvedHouse tempSolvedHouse;
    OwlSolvedRoom tempSolvedRoom;

    // first clear the Solution List contents...
    this.solutionsList.clear();

    OWLIndividual tempSiteIndividual =
        OWLFactory.getOWLNamedIndividual(":" + siteNameHash, topIxPrefixManager);
    OWLClassExpression tempSolutionClassExpression =
        OWLFactory.getOWLClass(":Solution", topIxPrefixManager);
    Set<OWLObjectPropertyAssertionAxiom> tempSitePropertyAxioms =
        topIxOnt.getObjectPropertyAssertionAxioms(tempSiteIndividual);

    Set<OWLIndividual> tempSolutionIndividuals =
        new HashSet<>(); // Solution individuals for this particular site. will be filled below...
    Set<OWLIndividual> tempSolvedHouseIndividuals = new HashSet<>();
    Set<OWLIndividual> tempSolvedRoomIndividuals = new HashSet<>();

    // populate the tempSolutionIndividuals Set<OWLIndividual>
    // with the Solution individuals that are solutions of the current Site
    // this block runs through the set of all the object property axioms
    // that have this site as their subject
    // and filters out the ones that are of type "hasSolution"
    for (OWLObjectPropertyAssertionAxiom tempObjPropAssAx : tempSitePropertyAxioms) {
      OWLObjectProperty tempHasSolutionObjectProperty =
          OWLFactory.getOWLObjectProperty(
              IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasSolution"));
      if (tempObjPropAssAx.getProperty() == tempHasSolutionObjectProperty) {
        tempSolutionIndividuals.add(tempObjPropAssAx.getObject());
      }
    }
    // retrieving the site dimensions for this solution set
    // (the site remains the same throughout the plethos of solutions).
    int tempSiteLength = 0;
    int tempSiteWidth = 0;
    OWLDataProperty siteHasLengthProp = OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager);
    OWLDataProperty siteHasWidthProp = OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager);
    Set<OWLDataPropertyAssertionAxiom> tempSiteDataProperties = new HashSet<>();

    tempSiteDataProperties = topIxOnt.getDataPropertyAssertionAxioms(tempSiteIndividual);

    for (OWLDataPropertyAssertionAxiom tempSiteDataProperty : tempSiteDataProperties) {
      if (tempSiteDataProperty.getProperty() == siteHasLengthProp) {
        tempSiteLength = tempSiteDataProperty.getObject().parseInteger();
      }
      if (tempSiteDataProperty.getProperty() == siteHasWidthProp) {
        tempSiteWidth = tempSiteDataProperty.getObject().parseInteger();
      }
    }

    logger.info(tempSolutionIndividuals.size());

    // running every solution individual for/of that particular site in order
    // to extract the solvedHouse's and the solvedRoom's
    // via the hasSolvedHouse and hasSolvedRoom properties.
    int solutionCounter = 0;
    for (OWLIndividual tempSolutionIndividual : tempSolutionIndividuals) {
      tempSolution = new OwlSolution();
      tempSolution.setSolutionID(new Integer(++solutionCounter));

      tempSolution.setSiteLength(new Integer(tempSiteLength));
      tempSolution.setSiteWidth(new Integer(tempSiteWidth));

      // clearing the contents of these two structuresin order to accommodate the solved entities of
      // the next solution.
      tempSolvedHouseIndividuals.clear();
      tempSolvedRoomIndividuals.clear();

      for (OWLObjectPropertyAssertionAxiom tempObjPropAssAx :
          topIxOnt.getObjectPropertyAssertionAxioms(tempSolutionIndividual)) {
        OWLObjectProperty tempHasSolvedHouseObjectProperty =
            OWLFactory.getOWLObjectProperty(
                IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasSolvedHouse"));
        OWLObjectProperty tempHasSolvedRoomObjectProperty =
            OWLFactory.getOWLObjectProperty(
                IRI.create(topIxOnt.getOntologyID().getOntologyIRI() + "#hasSolvedRoom"));
        if (tempObjPropAssAx.getProperty() == tempHasSolvedHouseObjectProperty) {
          tempSolvedHouseIndividuals.add(tempObjPropAssAx.getObject());
        } else if (tempObjPropAssAx.getProperty() == tempHasSolvedRoomObjectProperty) {
          tempSolvedRoomIndividuals.add(tempObjPropAssAx.getObject());
        }
      }

      for (OWLIndividual tempSolvedHouseIndividual : tempSolvedHouseIndividuals) {
        tempSolvedHouse = new OwlSolvedHouse();
        for (OWLDataPropertyAssertionAxiom tempDatPropAssAx :
            topIxOnt.getDataPropertyAssertionAxioms(tempSolvedHouseIndividual)) {
          if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasL", topIxPrefixManager))) {
            // logger.info(tempDatPropAssAx.getObject().parseInteger());
            tempSolvedHouse.setSolvedHouseLength(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasW", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseWidth(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseX(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseY(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasLiteral", topIxPrefixManager))) {
            tempSolvedHouse.setSolvedHouseLiteral(tempDatPropAssAx.getObject().getLiteral());
          }
        }
        // logger.info(tempSolvedHouse.getSolvedHouseX()+" "+tempSolvedHouse.getSolvedHouseY());
        tempSolution.getSolvedHouses().add(tempSolvedHouse);
      }

      for (OWLIndividual tempSolvedRoomIndividual : tempSolvedRoomIndividuals) {
        tempSolvedRoom = new OwlSolvedRoom();
        for (OWLDataPropertyAssertionAxiom tempDatPropAssAx :
            topIxOnt.getDataPropertyAssertionAxioms(tempSolvedRoomIndividual)) {
          if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasL", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomLength(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasW", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomWidth(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasH", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomHeight(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasX", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomX(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasY", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomY(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasZ", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomZ(tempDatPropAssAx.getObject().parseInteger());
          } else if (tempDatPropAssAx.getProperty()
              == (OWLFactory.getOWLDataProperty(":hasLiteral", topIxPrefixManager))) {
            tempSolvedRoom.setSolvedRoomLiteral(tempDatPropAssAx.getObject().getLiteral());
          }
        }
        tempSolution.getSolvedRooms().add(tempSolvedRoom);
      }
      this.solutionsList.add(tempSolution);
    }

    return true;
  }