/** * Refills the section with rows. This method will be called by the system and should be directly * called. */ protected void refill(OWLOntology ontology) { added.clear(); for (OWLObjectPropertyAssertionAxiom ax : ontology.getObjectPropertyAssertionAxioms(getRootObject())) { addRow( new OWLObjectPropertyAssertionAxiomFrameSectionRow( getOWLEditorKit(), this, ontology, getRootObject(), ax)); added.add(ax); } }
public Set<OWLAxiom> write(OWLIndividual individual) { Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); axioms.addAll(writeEntityStart(INDIVIDUAL, individual)); if (!isFiltered(AxiomType.CLASS_ASSERTION)) { for (OWLOntology ontology : getOntologies()) { SectionMap expressions = new SectionMap(); for (OWLClassAssertionAxiom ax : ontology.getClassAssertionAxioms(individual)) { if (isDisplayed(ax)) { expressions.add(ax.getClassExpression(), ax); axioms.add(ax); } } writeSection(TYPES, expressions, ",", true, ontology); } } for (OWLOntology ontology : getOntologies()) { List<OWLPropertyAssertionAxiom<?, ?>> assertions = new ArrayList<OWLPropertyAssertionAxiom<?, ?>>(); assertions.addAll(ontology.getObjectPropertyAssertionAxioms(individual)); assertions.addAll(ontology.getNegativeObjectPropertyAssertionAxioms(individual)); assertions.addAll(ontology.getDataPropertyAssertionAxioms(individual)); assertions.addAll(ontology.getNegativeDataPropertyAssertionAxioms(individual)); if (!assertions.isEmpty()) { fireSectionRenderingPrepared(FACTS.toString()); writeSection(FACTS); writeSpace(); writeOntologiesList(ontology); incrementTab(1); writeNewLine(); fireSectionRenderingStarted(FACTS.toString()); for (Iterator<OWLPropertyAssertionAxiom<?, ?>> it = assertions.iterator(); it.hasNext(); ) { OWLPropertyAssertionAxiom<?, ?> ax = it.next(); fireSectionItemPrepared(FACTS.toString()); Set<OWLAnnotation> annos = ax.getAnnotations(); if (!annos.isEmpty()) { writeAnnotations(annos); pushTab(getIndent() + 1); } if (ax instanceof OWLNegativeDataPropertyAssertionAxiom || ax instanceof OWLNegativeObjectPropertyAssertionAxiom) { write(NOT); writeSpace(); } ax.getProperty().accept(this); writeSpace(); writeSpace(); ax.getObject().accept(this); if (!annos.isEmpty()) { popTab(); } fireSectionItemFinished(FACTS.toString()); if (it.hasNext()) { write(","); writeNewLine(); } } popTab(); writeNewLine(); writeNewLine(); } } if (!isFiltered(AxiomType.SAME_INDIVIDUAL)) { for (OWLOntology ontology : getOntologies()) { Set<OWLIndividual> inds = new TreeSet<OWLIndividual>(); for (OWLSameIndividualAxiom ax : ontology.getSameIndividualAxioms(individual)) { if (isDisplayed(ax)) { inds.addAll(ax.getIndividuals()); axioms.add(ax); } } inds.remove(individual); writeSection(SAME_AS, inds, ",", true, ontology); } } if (!isFiltered(AxiomType.DIFFERENT_INDIVIDUALS)) { for (OWLOntology ontology : getOntologies()) { Set<OWLIndividual> inds = new TreeSet<OWLIndividual>(); Set<OWLDifferentIndividualsAxiom> nary = new TreeSet<OWLDifferentIndividualsAxiom>(); for (OWLDifferentIndividualsAxiom ax : ontology.getDifferentIndividualAxioms(individual)) { if (ax.getIndividuals().size() == 2 && isDisplayed(ax)) { inds.addAll(ax.getIndividuals()); axioms.add(ax); } else { nary.add(ax); } } inds.remove(individual); writeSection(DIFFERENT_FROM, inds, ",", true, ontology); if (renderExtensions) { for (OWLDifferentIndividualsAxiom ax : nary) { writeSection(DIFFERENT_INDIVIDUALS, ax.getIndividuals(), ", ", false, ontology); } } } } writeEntitySectionEnd(INDIVIDUAL.toString()); return axioms; }
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; }