private void addMatchingChildren(OWLClass source, OWLClass target, StringBuffer sb) { Set<OWLClassExpression> targetChildren = target.getSubClasses(diffs.getTargetOntology()); for (OWLClassExpression sourceChild : source.getSubClasses(diffs.getSourceOntology())) { OWLClass targetChild = (OWLClass) diffs.getEntityMap().get(sourceChild); if (targetChild != null && targetChildren.contains(targetChild)) { sb.append("Source entity has child\n\t"); sb.append(renderer.renderSourceObject((OWLClass) sourceChild)); sb.append("\nwhich maps to the following child of the target entity\n\t"); sb.append(renderer.renderTargetObject(targetChild)); sb.append('\n'); } } }
private boolean searchForMatches(OWLClass sourceClass, OWLClass potentialMatchingClass, Set<OWLClass> desiredTargetSubClasses) { int count = 0; for (OWLClassExpression targetSubclass : potentialMatchingClass.getSubClasses(diffMap.getTargetOntology())) { if (log.isLoggable(Level.INFO)) { log.info("\t" + targetSubclass); } if (desiredTargetSubClasses.contains(targetSubclass)) { if (log.isLoggable(Level.INFO)) { log.info("\tgood subclass"); } if (++count >= requiredSubclasses) { if (log.isLoggable(Level.INFO)) { log.info("match added"); } newMatches.put(sourceClass, potentialMatchingClass); return true; } } else { if (log.isLoggable(Level.INFO)) { log.info("\tbad subclass"); } } } return false; }
public Set<OWLClass> getSubClasses(OWLClass c, DifferencePosition position) { Set<OWLClass> subClasses = new HashSet<OWLClass>(); for (OWLClassExpression ce : c.getSubClasses(position.getOntology(diffs))) { if (!ce.isAnonymous()) { subClasses.add(ce.asOWLClass()); } } return subClasses; }
public Collection<Class> getSubClassOf() { return convertC(cl().getSubClasses(onto)); }
public Collection<OWLClass> getSubClasses(OWLClass owlClass) { if (topLevelClasses == null) { initializeInferredSubclasses(); } if (owlClass.equals(factory.getOWLThing())) { return Collections.unmodifiableCollection(topLevelClasses); } else { Set<OWLClass> subClasses = new TreeSet<OWLClass>(); for (OWLClassExpression ce : owlClass.getSubClasses(ontology)) { if (!ce.isAnonymous()) { subClasses.add(ce.asOWLClass()); } } Set<OWLClass> inferredSubclasses = inferredSubclassMap.get(owlClass); if (inferredSubclasses != null) { subClasses.addAll(inferredSubclasses); } return subClasses; } }
private ArrayList<String> getTabbedAssertedClassList(String rootClassName, int indent) { ArrayList<String> subClassNames = new ArrayList<String>(); IRI rootClassURI = IRI.create(ontology.getOntologyID() + "#" + rootClassName); OWLClass rootClass = manager.getOWLDataFactory().getOWLClass(rootClassURI); if (rootClass != null) { Set<OWLClassExpression> subClassSet; subClassSet = rootClass.getSubClasses(ontology); final String tabString = " "; for (OWLClassExpression des : subClassSet) { String currentIndent = ""; for (int i = 0; i < indent; i++) { currentIndent = currentIndent + tabString; } subClassNames.add(currentIndent + des.toString()); Set<OWLClassExpression> subClassSubset = des.asOWLClass().getSubClasses(ontology); if (subClassSubset.size() != 0) { ArrayList<String> subClassChildrenNames = new ArrayList<String>(); subClassChildrenNames = getTabbedAssertedClassList(des.toString(), indent + 1); subClassNames.addAll(subClassChildrenNames); } } } return subClassNames; }
public Integer recomputeMetric() { Set<OWLClass> processed = new HashSet<OWLClass>(); Set<OWLClass> clses = new HashSet<OWLClass>(); NamedConjunctChecker checker = new NamedConjunctChecker(); for (OWLOntology ont : getOntologies()) { for (OWLClass cls : ont.getClassesInSignature()) { if (processed.contains(cls)) { continue; } processed.add(cls); int count = 0; for (OWLClassExpression sup : cls.getSubClasses(getOntologies())) { if (checker.hasNamedConjunct(sup)) { count++; } if (count > 1) { clses.add(cls); break; } } } } return clses.size(); }
private static void addIndividuals(OWLOntology ontology, OWLClass cls, Set<OWLIndividual> individuals, Set<OWLClass> includedClasses) { if (!includedClasses.contains(cls)) { includedClasses.add(cls); individuals.addAll(cls.getIndividuals(ontology.getImportsClosure())); for (OWLClassExpression subCls : cls.getSubClasses(ontology.getImportsClosure())) { if (!subCls.isAnonymous()) { addIndividuals(ontology, subCls.asOWLClass(), individuals, includedClasses); } } } }
private void searchForMatches(OWLClass sourceClass, Set<OWLClass> possibleTargetSuperclasses, Set<OWLClass> possibleTargetSubclasses) { for (OWLClass possibleTargetSuperClass : possibleTargetSuperclasses) { for (OWLClassExpression possibleTargetClass : possibleTargetSuperClass.getSubClasses(diffMap.getTargetOntology())) { if (!possibleTargetClass.isAnonymous() && searchForMatches(sourceClass, possibleTargetClass.asOWLClass(), possibleTargetSubclasses)){ return; } } } }
@Override public synchronized Collection<IConcept> getChildren() { Set<IConcept> concepts = new HashSet<>(); synchronized (_owl) { Set<OWLClassExpression> set = _owl.getSubClasses(_manager.manager .getOntologies()); for (OWLClassExpression s : set) { if (!(s.isAnonymous() || s.isOWLNothing() || s.isOWLThing())) concepts.add(new Concept(s.asOWLClass(), _manager, _manager .getConceptSpace(s.asOWLClass().getIRI()))); } if (set.isEmpty() && _owl.isOWLThing()) { for (IOntology onto : _manager.ontologies.values()) { concepts.addAll(onto.getConcepts()); } } } return concepts; }
public Collection<DeviceClassMetadata> getAllDeviceClasses() { IRI controllableURI = IRI.create(this.ontologyWithDOGONT.getOntologyID().getOntologyIRI().toString() + "#Controllable"); OWLClass controllableClass = this.ontManager.getOWLDataFactory().getOWLClass(controllableURI); SubClassesVisitor descendantsVisitor = new SubClassesVisitor(ontology, controllableClass); controllableClass.accept(descendantsVisitor); Set<OWLClass> descendants = descendantsVisitor.getClasses(); ArrayList<DeviceClassMetadata> devices = new ArrayList<>(); for (OWLClass d : descendants) { String name = d.getIRI().toString(); if (!name.equalsIgnoreCase(NOTHING)) { if (d.getSubClasses(ontology).isEmpty()) { devices.add(this.getDeviceClassById(d.getIRI().toString())); } } } return devices; }
System.out.println("Disjoint: "+rendering.render(c1e)); c1eqclasses = c1.getSubClasses(localOntology); for(OWLClassExpression c1e : c1eqclasses) System.out.println("Subclass: "+rendering.render(c1e));
public Collection<GatewayClassMetadata> getAllGatewayClasses() { IRI gatewaysSuperclassURI = IRI.create(this.ontologyWithDOGONT.getOntologyID().getOntologyIRI().toString() + "#" + GATEWAYS_SUPERCLASS_ID); OWLClass gwSprClass = this.ontManager.getOWLDataFactory().getOWLClass(gatewaysSuperclassURI); ClassHierarchyVisitor descendantsVisitor = new SubClassesVisitor(ontology, gwSprClass); gwSprClass.accept(descendantsVisitor); Set<OWLClass> subClasses = descendantsVisitor.getClasses(); ArrayList<GatewayClassMetadata> result = new ArrayList<GatewayClassMetadata>(); for (OWLClass c : subClasses) { String name = c.getIRI().toString(); if (!name.equalsIgnoreCase(NOTHING)) { if (c.getSubClasses(ontology).isEmpty()) { result.add(new GatewayClassMetadata(c.getIRI().toString())); } } } return result; } }