public OWLClassExpression minimizeClone(OWLClassExpression ce){ OWLObjectDuplicator objectDuplicator = new OWLObjectDuplicator(df); OWLClassExpression clone = objectDuplicator.duplicateObject(ce); return clone.accept(this); }
@Override public OWLClass visit(OWLClass ce) { return df.getOWLClass(getIRI(ce)); }
/** * Returns a clone of the given class expression. * @param ce the class expression * @return a class expression clone */ public static OWLClassExpression clone(OWLClassExpression ce) { return duplicator.duplicateObject(ce); }
public OWLClassExpressionMinimizer(OWLDataFactory dataFactory, AbstractReasonerComponent reasoner) { this.df = dataFactory; this.reasoner = reasoner; objectDuplicator = new OWLObjectDuplicator(dataFactory); }
@Override public OWLDataAllValuesFrom visit(OWLDataAllValuesFrom ce) { if (ce.getFiller() instanceof OWLDataOneOf) { return df.getOWLDataAllValuesFrom(ce.getProperty(), process(ce.getProperty(), (OWLDataOneOf) ce .getFiller())); } return super.visit(ce); }
/** * Creates an object duplicator that duplicates objects using the specified data factory and uri * replacement map. * * @param m The manager providing data factory and config to be used for the duplication. * @param iriReplacementMap The map to use for the replacement of URIs. Any uris the appear in * the map will be replaced as objects are duplicated. This can be used to "rename" * entities. */ public OWLObjectDuplicator(OWLOntologyManager m, Map<IRI, IRI> iriReplacementMap) { this(remap(iriReplacementMap, m.getOWLDataFactory()), m); }
@Override public OWLObjectIntersectionOf visit(OWLObjectIntersectionOf ce) { return df.getOWLObjectIntersectionOf(list(ce.operands())); }
private OWLAxiom rewriteAxiom(OWLAxiom axiom) { return duplicator.duplicateObject(axiom); }
/** * @param entity2IRIMap map of IRIs to rename * @return list of changes */ public List<OWLOntologyChange> changeIRI(Map<OWLEntity, IRI> entity2IRIMap) { List<OWLOntologyChange> changes = new ArrayList<>(); OWLObjectDuplicator duplicator = new OWLObjectDuplicator(entity2IRIMap, m); for (OWLOntology ont : ontologies) { entity2IRIMap.keySet().forEach( e -> fillListWithTransformChanges(changes, getAxioms(ont, e), ont, duplicator)); } return changes; } }
@Override public OWLDataSomeValuesFrom visit(OWLDataSomeValuesFrom ce) { if (ce.getFiller() instanceof OWLDataOneOf) { return df.getOWLDataSomeValuesFrom(ce.getProperty(), process(ce.getProperty(), (OWLDataOneOf) ce .getFiller())); } return super.visit(ce); }
/** * Creates an object duplicator that duplicates objects using the specified data factory and uri * replacement map. * * @param m The manager providing data factory and config to be used for the duplication. * @param iriReplacementMap The map to use for the replacement of URIs. Any uris the appear in * the map will be replaced as objects are duplicated. This can be used to "rename" * entities. */ public OWLObjectDuplicator(OWLOntologyManager m, Map<IRI, IRI> iriReplacementMap) { this(remap(iriReplacementMap, m.getOWLDataFactory()), m); }
@Override public OWLDataIntersectionOf visit(OWLDataIntersectionOf node) { return df.getOWLDataIntersectionOf(list(node.operands())); }
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); } } }
private OWLAxiom rewriteAxiom(OWLAxiom axiom) { return duplicator.duplicateObject(axiom); }