/** * @param ontology ontology to check * @return true if the ontology is contained */ @Override public boolean contains(OWLOntology ontology) { return delegate.contains(ontology); }
@Override public boolean contains(OWLOntologyID id) { return delegate.contains(id); }
@Override public boolean hasOntology(OWLOntologyID id) { return store.contains(id); }
@Override public boolean contains(IRI ontologyIRI) { return delegate.contains(ontologyIRI); }
public Set<OWLOntology> getDirtyOntologies() { Set<OWLOntology> ontologies = new HashSet<>(); for(OWLOntologyID ontId : new ArrayList<>(dirtyOntologies)) { if(manager.contains(ontId)) { ontologies.add(manager.getOntology(ontId)); } else { dirtyOntologies.remove(ontId); } } return ontologies; }
public Set<OWLOntology> getDirtyOntologies() { Set<OWLOntology> ontologies = new HashSet<>(); for (OWLOntologyID ontId : new ArrayList<>(dirtyOntologies)) { if (manager.contains(ontId)) { ontologies.add(manager.getOntology(ontId)); } else { dirtyOntologies.remove(ontId); } } return ontologies; }
@Override public boolean hasOntology(String key) { return store.contains(IRI.create(key)); }
/** * Save all of the ontologies that are editable and that have been modified. * <p/> * This method should not be used as the behaviour is not clear. The save(OWLOntology) method should be used * instead. */ @Deprecated public void save() throws OWLOntologyStorageException { HashSet<OWLOntology> ontologiesToSave = new HashSet<>(); for(OWLOntologyID ontId : dirtyOntologies) { if(manager.contains(ontId)) { ontologiesToSave.add(manager.getOntology(ontId)); } else { dirtyOntologies.remove(ontId); } } for(OWLOntology ontology : ontologiesToSave) { save(ontology); } }
/** * Save all of the ontologies that are editable and that have been modified. * <p/> * This method should not be used as the behaviour is not clear. The save(OWLOntology) method should be used * instead. */ @Deprecated public void save() throws OWLOntologyStorageException { HashSet<OWLOntology> ontologiesToSave = new HashSet<>(); for (OWLOntologyID ontId : dirtyOntologies) { if (manager.contains(ontId)) { ontologiesToSave.add(manager.getOntology(ontId)); } else { dirtyOntologies.remove(ontId); } } for (OWLOntology ontology : ontologiesToSave) { save(ontology); } }
public boolean removeOntology(OWLOntology ont) { if(ont.equals(activeOntology)) { logger.debug("Request received to remove an ontology that is the active ontology. Cannot remove the active ontology. Ignoring request."); return false; } if(manager.contains(ont.getOntologyID()) && manager.getOntologies().size() == 1) { logger.debug("Request received to remove the one and only ontology that is open. This is not allowed. Ignoring request."); return false; } activeOntologies.remove(ont); dirtyOntologies.remove(ont.getOntologyID()); manager.removeOntology(ont); setActiveOntology(activeOntology, true); return true; }
public boolean removeOntology(OWLOntology ont) { if (ont.equals(activeOntology)) { logger.debug("Request received to remove an ontology that is the active ontology. Cannot remove the active ontology. Ignoring request."); return false; } if (manager.contains(ont.getOntologyID()) && manager.getOntologies().size() == 1) { logger.debug("Request received to remove the one and only ontology that is open. This is not allowed. Ignoring request."); return false; } activeOntologies.remove(ont); dirtyOntologies.remove(ont.getOntologyID()); manager.removeOntology(ont); setActiveOntology(activeOntology, true); return true; }
/** * If ontology is reloaded then we should clear current status. e.g. unload * ontology, reasoner, structures, etc... If incremental reasoning then the * ontology may not be reloaded. */ protected void clearStatus() { this.classified = notYetClassified; this.pendingChanges_root_ontology.clear(); // Unload working copy of the ontology if (manager.contains(IRI.create(iri_str_working_ontology))) { manager.removeOntology(ontology); this.ontology = null; } // Unload hermit and lreasoner ontologies unloadOntologyFragmentsFromManager(); this.owl2reasoner = null; this.lReasoner = null; if (this.lSignature != null) { this.lSignature.clear(); } if (this.lModuleAxioms != null) { this.lModuleAxioms.clear(); } if (this.compSignature != null) { this.compSignature.clear(); } }
/** * Unload from manager the subontologies given to hermit and lreasoner * Dispose reasoners as well */ protected void unloadOntologyFragmentsFromManager() { // Dispose them if not null disposeUsedReasoners(); if (manager.contains(IRI.create(iri_compmodule_ontology))) { manager.removeOntology(compmodule_onto); compmodule_onto = null; } if (manager.contains(IRI.create(iri_lmodule_ontology))) { manager.removeOntology(lmodule_onto); lmodule_onto = null; } }
/** * We also unload the merged ontlogy from classification */ protected void unloadOntologyFragmentsFromManager(){ super.unloadOntologyFragmentsFromManager(); if (mergedReasoner!=null){ mergedReasoner.dispose(); } if (manager.contains(IRI.create(iri_merged_class_ontology))){ manager.removeOntology(merged_class_ontology); merged_class_ontology = null; } }
@Nonnull @Override public OWLOntologyManager getOntologyManagerForRevision(@Nonnull RevisionNumber revision) { try { OWLOntologyManager manager = WebProtegeOWLManager.createOWLOntologyManager(); final OWLOntologyID singletonOntologyId = new OWLOntologyID(); for (Revision rev : revisionStore.getRevisions()) { if (rev.getRevisionNumber().compareTo(revision) <= 0) { for (OWLOntologyChangeRecord record : rev) { // Anonymous ontologies are not handled nicely at all. OWLOntologyChangeRecord normalisedChangeRecord = normaliseChangeRecord(record, singletonOntologyId); OWLOntologyID ontologyId = normalisedChangeRecord.getOntologyID(); if (!manager.contains(ontologyId)) { manager.createOntology(ontologyId); } OWLOntologyChange change = normalisedChangeRecord.createOntologyChange(manager); manager.applyChange(change); } } } if (manager.getOntologies().isEmpty()) { // No revisions exported. Just create an empty ontology manager.createOntology(); } return manager; } catch (OWLOntologyCreationException e) { throw new RuntimeException("Problem creating ontology: " + e); } }
if (moveType == MoveType.COPY || moveType == MoveType.MOVE){ OWLOntologyManager man = editorKit.getModelManager().getOWLOntologyManager(); if(targetOntologyID != null && man.contains(getTargetOntologyID())) { targetOntology = man.getOntology(getTargetOntologyID()); if(targetOntologyID != null && editorKit.getOWLModelManager().getOWLOntologyManager().contains(targetOntologyID)) { JOptionPane.showMessageDialog(getOwner(), "Axioms successfully " + moveType.getCompletedName(), "Finished", JOptionPane.INFORMATION_MESSAGE);
public void ontologiesChanged(List<? extends OWLOntologyChange> changes) throws OWLException { if( !getRootOntology().getOWLOntologyManager().contains( getRootOntology().getOntologyID() ) ) { return; } Set<OWLOntology> ontologies = getRootOntology().getImportsClosure(); for( OWLOntologyChange change : changes ) { if( !change.isAxiomChange() || !ontologies.contains( change.getOntology() ) ) { continue; } resetRealization(); OWLAxiom axiom = change.getAxiom(); if( change instanceof AddAxiom ) { extractor.addAxiom( axiom ); } else if( change instanceof RemoveAxiom ) { extractor.deleteAxiom( axiom ); } else { throw new UnsupportedOperationException( "Unrecognized axiom change: " + change ); } } }
public static void loadImports(final OWLOntologyManager manager, final OwlApiCase t, final SerializationFormat format) throws OWLOntologyCreationException { for (final IRI iri : t.getImportedOntologies()) { if (!manager.contains(iri)) { final String str = t.getImportedOntology(iri, format); if (str == null) { final String msg = format("Imported ontology (%s) not provided in " + format + " syntax for testcase (%s)", iri, t.getIdentifier()); _logger.warning(msg); throw new OWLOntologyCreationException(msg); } else { final StringDocumentSource source = new StringDocumentSource(str, iri); try { manager.loadOntologyFromOntologyDocument(source); } catch (final OWLOntologyCreationException e) { _logger.warning(format("Failed to parse imported ontology for testcase (%s)", t.getIdentifier())); throw e; } } } } }
public static void loadImports(final OWLOntologyManager manager, final OwlApiCase t, final SerializationFormat format) throws OWLOntologyCreationException { for (final IRI iri : t.getImportedOntologies()) { if (!manager.contains(iri)) { final String str = t.getImportedOntology(iri, format); if (str == null) { final String msg = format("Imported ontology (%s) not provided in " + format + " syntax for testcase (%s)", iri, t.getIdentifier()); _logger.warning(msg); throw new OWLOntologyCreationException(msg); } else { final StringDocumentSource source = new StringDocumentSource(str, iri); try { manager.loadOntologyFromOntologyDocument(source); } catch (final OWLOntologyCreationException e) { _logger.warning(format("Failed to parse imported ontology for testcase (%s)", t.getIdentifier())); throw e; } } } } }
public List<OWLOntologyChange> getChanges() throws OWLOntologyCreationException { OWLOntology targetOntology = null; if (addToTargetOntology){ OWLOntologyManager man = editorKit.getModelManager().getOWLOntologyManager(); if(man.contains(getTargetOntologyID())) { targetOntology = man.getOntology(getTargetOntologyID()); } else { targetOntology = editorKit.getModelManager().createNewOntology(getTargetOntologyID(), ontologyPhysicalLocationPage.getLocationURL()); editorKit.getModelManager().getOWLOntologyManager().setOntologyFormat(targetOntology, ontologyFormatPage.getFormat()); } } List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); Set<OWLAxiom> axiomsToBeMoved = getAxiomsToBeMoved(); for(OWLAxiom ax : axiomsToBeMoved) { for (OWLOntology ont : getSourceOntologies()) { if (ont.containsAxiom(ax)) { if(deleteFromOriginalOntology) { changes.add(new RemoveAxiom(ont, ax)); } if(targetOntology != null){ changes.add(new AddAxiom(targetOntology, ax)); } } } } return changes; }