/** * Determines if a change is applicable. A change may not be applicable for a number of reasons. * * @param change The change to be tested. * @return {@code true} if the change is applicable, otherwise, {@code false}. */ private boolean isChangeApplicable(OWLOntologyChange change) { OWLOntologyLoaderConfiguration ontologyConfig = ontologyConfigurationsByOntologyID.get(change.getOntology().getOntologyID()); if (ontologyConfig != null && !ontologyConfig.isLoadAnnotationAxioms() && change.isAddAxiom() && change.getAxiom() instanceof OWLAnnotationAxiom) { return false; } return true; }
@Override protected boolean isResettingChange(OWLOntologyChange change) { if (!change.isAxiomChange()) { return false; } return change.getAxiom() instanceof SWRLRule; }
private void handleOntologyChanges(List<? extends OWLOntologyChange> changes) { for (OWLOntologyChange change : changes) { change.accept(new OWLOntologyChangeVisitorAdapter() { @Override public void visit(SetOntologyID change) { updateView(); } }); } }
/** * Determines if the change will remove an axiom from an ontology. * * @return {@code true} if the change is a RemoveAxiom change and it will remove an axiom from * an ontology, {@code false} otherwise. */ public boolean isRemoveAxiom() { return isAxiomChange() && !isAddAxiom(); }
private List<OWLAxiomChange> filterIrrelevantChanges(List<? extends OWLOntologyChange> changes) { List<OWLAxiomChange> filteredChanges = new ArrayList<>(); for (OWLOntologyChange change : changes) { // only listen for changes on the appropriate ontologies if (ontologies.contains(change.getOntology())) { if (change.isAxiomChange()) { filteredChanges.add((OWLAxiomChange) change); } } } return filteredChanges; }
@Override public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { for (OWLOntologyChange change : changes) { if (!change.isAxiomChange() || !contains(ontology.importsClosure(), change.getOntology())) { continue; } OWLAxiom axiom = change.getAxiom(); if (change.isAddAxiom()) { addAxiom(axiom); } else if (change.isRemoveAxiom()) { removeAxiom(axiom); } else { throw new UnsupportedOperationException("Unrecognized axiom change: " + change); } } } }
/** * Constructs an exception which describes the attempted change. * @param change The change. */ public ImmutableOWLOntologyChangeException(OWLOntologyChange change) { super(change, "Cannot apply changes to immutable ontology: " + change.getOntology()); }
public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { getHistoryManager().logChanges(changes); boolean refreshActiveOntology = false; for (OWLOntologyChange change : changes) { dirtyOntologies.add(change.getOntology()); if (change.isImportChange()){ refreshActiveOntology = true; } } if (refreshActiveOntology){ setActiveOntology(getActiveOntology(), true); } }
public static boolean overlappingChange(OWLOntologyChange change1, OWLOntologyChange change2) { if (change1.getOntology().equals(change2.getOntology())) { OverlapVisitor visitor = new OverlapVisitor(change1); change2.accept(visitor); return visitor.isOverlapping(); } return false; }
/** * A convenience method that creates an {@code OWLOntologyChangeRecord} by * deriving data from an {@link OWLOntologyChange} object. * * @param change The {@link OWLOntologyChange} object. * @return instance of OntologychangeRecord */ public static OWLOntologyChangeRecord createFromOWLOntologyChange(OWLOntologyChange change) { checkNotNull(change, "change must not be null"); OWLOntologyID ontologyId = change.getOntology().getOntologyID(); OWLOntologyChangeData data = change.getChangeData(); return new OWLOntologyChangeRecord(ontologyId, data); }
@Override public void ontologiesChanged( @Nonnull List<? extends OWLOntologyChange> changes) { entities.clear(); for (OWLOntologyChange change : changes) { if (change.isAxiomChange()) { entities.addAll(asList(((OWLAxiomChange) change).signature())); } } ontologiesChanged(); }
private void checkForImportsChange(OWLOntologyChange change) { if (change.isImportChange()) { resetImportsClosureCache(); if(change instanceof AddImport) { // Do we contain the import already? for(OWLOntologyID id : ontologiesByID.keySet()) { OWLImportsDeclaration addImportDeclaration = ((AddImport) change).getImportDeclaration(); if(id.getDefaultDocumentIRI() != null && id.getDefaultDocumentIRI().equals(addImportDeclaration.getIRI())) { // Yes we do ontologyIDsByImportsDeclaration.put(addImportDeclaration, id); } } } else { // Remove the mapping from declaration to ontology ontologyIDsByImportsDeclaration.remove(((RemoveImport) change).getImportDeclaration()); } } }
@Override public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { for (OWLOntologyChange change : changes) { if (!change.isAxiomChange() || !contains(ontology.importsClosure(), change.getOntology())) { continue; } OWLAxiom axiom = change.getAxiom(); if (change.isAddAxiom()) { addAxiom(axiom); } else if (change.isRemoveAxiom()) { removeAxiom(axiom); } else { throw new UnsupportedOperationException("Unrecognized axiom change: " + change); } } } }
public static Set<OWLOntology> getChangedOntologies(List<OWLOntologyChange> changes) { Set<OWLOntology> ontologies = new HashSet<OWLOntology>(); for (OWLOntologyChange change : changes) { ontologies.add(change.getOntology()); } return ontologies; }
private List<OWLAxiomChange> filterIrrelevantChanges(List<? extends OWLOntologyChange> changes) { List<OWLAxiomChange> filteredChanges = new ArrayList<>(); for (OWLOntologyChange change : changes) { // only listen for changes on the appropriate ontologies if (ontologies.contains(change.getOntology())) { if (change.isAxiomChange()) { filteredChanges.add((OWLAxiomChange) change); } } } return filteredChanges; }
public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { getHistoryManager().logChanges(changes); boolean refreshActiveOntology = false; for (OWLOntologyChange change : changes) { if (change instanceof SetOntologyID) { SetOntologyID ontologyIDChange = (SetOntologyID) change; dirtyOntologies.remove(ontologyIDChange.getOriginalOntologyID()); } dirtyOntologies.add(change.getOntology().getOntologyID()); if (change.isImportChange()) { refreshActiveOntology = true; } } if (refreshActiveOntology) { setActiveOntology(getActiveOntology(), true); } }
/** * Determines if the change will remove an axiom from an ontology. * * @return {@code true} if the change is a RemoveAxiom change and it will remove an axiom from * an ontology, {@code false} otherwise. */ public boolean isRemoveAxiom() { return isAxiomChange() && !isAddAxiom(); }
/** * A convenience method that creates an {@code OWLOntologyChangeRecord} by * deriving data from an {@link OWLOntologyChange} object. * * @param change The {@link OWLOntologyChange} object. * @return instance of OntologychangeRecord */ public static OWLOntologyChangeRecord createFromOWLOntologyChange(OWLOntologyChange change) { checkNotNull(change, "change must not be null"); OWLOntologyID ontologyId = change.getOntology().getOntologyID(); OWLOntologyChangeData data = change.getChangeData(); return new OWLOntologyChangeRecord(ontologyId, data); }
@Override protected boolean isMetricInvalidated(List<? extends OWLOntologyChange> changes) { for (OWLOntologyChange chg : changes) { if (chg.isAxiomChange() && chg.getAxiom() instanceof OWLSubClassOfAxiom) { return true; } } return false; } }
@Override public void ontologiesChanged(List<? extends OWLOntologyChange> changes) { for (OWLOntologyChange change : changes) { if (!change.isAxiomChange() || !contains(ontology.importsClosure(), change.getOntology())) { continue; } OWLAxiom axiom = change.getAxiom(); if (change.isAddAxiom()) { addAxiom(axiom); } else if (change.isRemoveAxiom()) { removeAxiom(axiom); } else { throw new UnsupportedOperationException("Unrecognized axiom change: " + change); } } } }