private void apply(EntityBasedDiff diff) { IRI iriOfNewlyCreatedClass = null; String code = null; MatchedAxiom splitAxiomWithBadDescription = null; MatchedAxiom splitFrom = null; for (MatchedAxiom match : diff.getAxiomMatches()) { if (match.getDescription().equals(MatchedAxiom.AXIOM_ADDED) && isSplitFromAnnotationAssertion(match.getTargetAxiom())) { splitAxiomWithBadDescription = match; splitFrom = new MatchedAxiom(null, match.getTargetAxiom(), SPLIT); iriOfNewlyCreatedClass = (IRI) ((OWLAnnotationAssertionAxiom) match.getTargetAxiom()).getSubject(); code = ((OWLLiteral) ((OWLAnnotationAssertionAxiom) match.getTargetAxiom()).getValue()) .getLiteral(); break; } } if (splitFrom != null) { changes.removeMatch(splitAxiomWithBadDescription); changes.addMatch(splitFrom); handleNewSplitAxioms(iriOfNewlyCreatedClass, code, diff); } }
private void handleNewSplitAxioms( OWLClass newlyCreatedClass, OWLClass classThatWasSplit, EntityBasedDiff diff) { OWLOntology sourceOntology = diffMap.getSourceOntology(); Map<OWLEntity, IRI> newTargetToSplitSource = Collections.singletonMap((OWLEntity) newlyCreatedClass, classThatWasSplit.getIRI()); OWLObjectDuplicator duplicator = new OWLObjectDuplicator(newTargetToSplitSource, diffMap.getOWLDataFactory()); Set<OWLClassExpression> inferredParents = getInferredParents(sourceOntology, classThatWasSplit); for (MatchedAxiom match : new ArrayList<MatchedAxiom>(diff.getAxiomMatches())) { if (match.getDescription().equals(MatchedAxiom.AXIOM_ADDED) && cameFromSourceOntology( (OWLAxiom) duplicator.duplicateObject(match.getTargetAxiom()), sourceOntology, classThatWasSplit, inferredParents)) { MatchedAxiom modifiedBySplit = new MatchedAxiom(null, match.getTargetAxiom(), COPIED_FROM_SPLIT); changes.removeMatch(match); changes.addMatch(modifiedBySplit); } } }