コード例 #1
0
  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);
    }
  }
コード例 #2
0
 private OWLClass getClassThatWasSplit(String code) {
   if (code == null) {
     return null;
   }
   Collection<OWLEntity> possiblySplitEntities = mapper.getTargetEntities(code);
   OWLClass classThatWasSplit = null;
   for (OWLEntity possiblySplityEntity : possiblySplitEntities) {
     if (possiblySplityEntity instanceof OWLClass) {
       if (classThatWasSplit != null) {
         return null;
       } else {
         classThatWasSplit = (OWLClass) possiblySplityEntity;
         EntityBasedDiff classThatWasSplitDiff = changes.getTargetDiffMap().get(classThatWasSplit);
         if (classThatWasSplitDiff != null) {
           classThatWasSplit =
               (OWLClass)
                   classThatWasSplitDiff
                       .getSourceEntity(); // if it was created we do really want null
         }
       }
     }
   }
   return classThatWasSplit;
 }
コード例 #3
0
 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);
     }
   }
 }