public void visit(OWLDisjointClassesAxiom axiom) { Set<OWLClassExpression> added = new HashSet<OWLClassExpression>(); for (OWLClassExpression descA : axiom.getClassExpressions()) { for (OWLClassExpression descB : axiom.getClassExpressions()) { if (!descA.equals(descB) && !added.contains(descA) && !added.contains(descB)) { addChildParent(descA, descB, axiom); added.add(descA); added.add(descB); descA.accept(this); descB.accept(this); } } } }
public void actionPerformed(ActionEvent actionEvent) { List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); int axiomsRemoved = 0; int axiomsAdded = 0; int numberOfDisjoints = 0; for (OWLOntology ont : getOWLModelManager().getActiveOntologies()) { // act on each ontology in turn CliqueFinder<OWLClassExpression> merger = new CliqueFinder<OWLClassExpression>(); Set<OWLDisjointClassesAxiom> oldAxioms = ont.getAxioms(AxiomType.DISJOINT_CLASSES); numberOfDisjoints += oldAxioms.size(); for (OWLDisjointClassesAxiom ax : oldAxioms) { merger.add(ax.getClassExpressions()); } for (Set<OWLClassExpression> newAxioms : merger.getResults()) { OWLDisjointClassesAxiom newAxiom = getOWLModelManager().getOWLDataFactory().getOWLDisjointClassesAxiom(newAxioms); if (oldAxioms.contains(newAxiom)) { oldAxioms.remove(newAxiom); } else { changes.add(new AddAxiom(ont, newAxiom)); axiomsAdded++; } } for (OWLDisjointClassesAxiom oldAxiom : oldAxioms) { changes.add(new RemoveAxiom(ont, oldAxiom)); axiomsRemoved++; } } getOWLModelManager().applyChanges(changes); logger.info( axiomsRemoved + " (of " + numberOfDisjoints + " total) disjoint class axioms replaced with " + axiomsAdded); }