/** * Gets the set of imports declarations for this ontology. The set returned represents the set * of IRIs that correspond to the set of IRIs in an ontology's directlyImportsDocuments (see * Section 3 in the OWL 2 structural specification). * * @return The set of imports declarations that correspond to the set of ontology document IRIs * that are directly imported by this ontology. The set that is returned is a copy - it * will not be updated if the ontology changes. It is therefore safe to apply changes to * this ontology while iterating over this set. * @deprecated use the stream method */ @Deprecated default Set<OWLImportsDeclaration> getImportsDeclarations() { return asSet(importsDeclarations()); }
/** * Gets the set of imports declarations for this ontology. The set returned represents the set * of IRIs that correspond to the set of IRIs in an ontology's directlyImportsDocuments (see * Section 3 in the OWL 2 structural specification). * * @return The set of imports declarations that correspond to the set of ontology document IRIs * that are directly imported by this ontology. The set that is returned is a copy - it * will not be updated if the ontology changes. It is therefore safe to apply changes to * this ontology while iterating over this set. * @deprecated use the stream method */ @Deprecated default Set<OWLImportsDeclaration> getImportsDeclarations() { return asSet(importsDeclarations()); }
/** * Gets the set of imports declarations for this ontology. The set returned represents the set * of IRIs that correspond to the set of IRIs in an ontology's directlyImportsDocuments (see * Section 3 in the OWL 2 structural specification). * * @return The set of imports declarations that correspond to the set of ontology document IRIs * that are directly imported by this ontology. The set that is returned is a copy - it * will not be updated if the ontology changes. It is therefore safe to apply changes to * this ontology while iterating over this set. * @deprecated use the stream method */ @Deprecated default Set<OWLImportsDeclaration> getImportsDeclarations() { return asSet(importsDeclarations()); }
@Override public Stream<OWLOntology> directImports(OWLOntology ontology) { readLock.lock(); try { if (!contains(ontology)) { throw new UnknownOWLOntologyException(ontology.getOntologyID()); } return ontology.importsDeclarations().map(this::getImportedOntology) .filter(Objects::nonNull); } finally { readLock.unlock(); } }
@Override public Stream<OWLOntology> directImports(OWLOntology ontology) { readLock.lock(); try { if (!contains(ontology)) { throw new UnknownOWLOntologyException(ontology.getOntologyID()); } return ontology.importsDeclarations().map(this::getImportedOntology) .filter(Objects::nonNull); } finally { readLock.unlock(); } }
@Override public Stream<OWLOntology> directImports(OWLOntology ontology) { readLock.lock(); try { if (!contains(ontology)) { throw new UnknownOWLOntologyException(ontology.getOntologyID()); } return ontology.importsDeclarations().map(this::getImportedOntology) .filter(Objects::nonNull); } finally { readLock.unlock(); } }
@Override public Stream<OWLOntology> directImports(OWLOntology ontology) { readLock.lock(); try { if (!contains(ontology)) { throw new UnknownOWLOntologyException(ontology.getOntologyID()); } return ontology.importsDeclarations().map(this::getImportedOntology) .filter(Objects::nonNull); } finally { readLock.unlock(); } }
private void addImportsDeclarationsToOntologyHeader(OWLOntology ontology) { ontology.importsDeclarations() .forEach(decl -> addTriple(ontology, OWL_IMPORTS.getIRI(), decl.getIRI())); }
private void addImportsDeclarationsToOntologyHeader(OWLOntology ontology) { ontology.importsDeclarations() .forEach(decl -> addTriple(ontology, OWL_IMPORTS.getIRI(), decl.getIRI())); }
private void addImportsDeclarationsToOntologyHeader(OWLOntology ontology) { ontology.importsDeclarations() .forEach(decl -> addTriple(ontology, OWL_IMPORTS.getIRI(), decl.getIRI())); }
private void addImportsDeclarationsToOntologyHeader(OWLOntology ontology) { ontology.importsDeclarations() .forEach(decl -> addTriple(ontology, OWL_IMPORTS.getIRI(), decl.getIRI())); }
/** * Changes the URI of the specified ontology to the new URI. * * @param ontology The ontology whose URI is to be changed. * @param newIRI the new IRI * @return A list of changes, which when applied will change the URI of the specified ontology, * and also update the imports declarations in any ontologies which import the specified * ontology. */ public List<OWLOntologyChange> getChanges(OWLOntology ontology, IRI newIRI) { List<OWLOntologyChange> changes = new ArrayList<>(); changes.add(new SetOntologyID(ontology, new OWLOntologyID(optional(newIRI), ontology.getOntologyID().getVersionIRI()))); OWLImportsDeclaration owlImport = owlOntologyManager.getOWLDataFactory().getOWLImportsDeclaration(newIRI); IRI ontIRI = ontology.getOntologyID().getOntologyIRI().orElse(null); owlOntologyManager.ontologies().forEach(ont -> ont.importsDeclarations() .filter(decl -> decl.getIRI().equals(ontIRI)).forEach(decl -> { changes.add(new RemoveImport(ont, decl)); changes.add(new AddImport(ont, owlImport)); })); return changes; } }
/** * Changes the URI of the specified ontology to the new URI. * * @param ontology The ontology whose URI is to be changed. * @param newIRI the new IRI * @return A list of changes, which when applied will change the URI of the specified ontology, * and also update the imports declarations in any ontologies which import the specified * ontology. */ public List<OWLOntologyChange> getChanges(OWLOntology ontology, IRI newIRI) { List<OWLOntologyChange> changes = new ArrayList<>(); changes.add(new SetOntologyID(ontology, new OWLOntologyID(optional(newIRI), ontology.getOntologyID().getVersionIRI()))); OWLImportsDeclaration owlImport = owlOntologyManager.getOWLDataFactory().getOWLImportsDeclaration(newIRI); IRI ontIRI = ontology.getOntologyID().getOntologyIRI().orElse(null); owlOntologyManager.ontologies().forEach(ont -> ont.importsDeclarations() .filter(decl -> decl.getIRI().equals(ontIRI)).forEach(decl -> { changes.add(new RemoveImport(ont, decl)); changes.add(new AddImport(ont, owlImport)); })); return changes; } }
/** * Changes the URI of the specified ontology to the new URI. * * @param ontology The ontology whose URI is to be changed. * @param newIRI the new IRI * @return A list of changes, which when applied will change the URI of the specified ontology, * and also update the imports declarations in any ontologies which import the specified * ontology. */ public List<OWLOntologyChange> getChanges(OWLOntology ontology, IRI newIRI) { List<OWLOntologyChange> changes = new ArrayList<>(); changes.add(new SetOntologyID(ontology, new OWLOntologyID(optional(newIRI), ontology.getOntologyID().getVersionIRI()))); OWLImportsDeclaration owlImport = owlOntologyManager.getOWLDataFactory().getOWLImportsDeclaration(newIRI); IRI ontIRI = ontology.getOntologyID().getOntologyIRI().orElse(null); owlOntologyManager.ontologies().forEach(ont -> ont.importsDeclarations() .filter(decl -> decl.getIRI().equals(ontIRI)).forEach(decl -> { changes.add(new RemoveImport(ont, decl)); changes.add(new AddImport(ont, owlImport)); })); return changes; } }
protected void handleImportingRDFGraphRatherThanOntology(OWLImportsDeclaration id, OWLOntologyManager man, @Nullable OWLOntology io) { if (io != null) { OWLDocumentFormat importedOntologyFormat = io.getFormat(); if (importedOntologyFormat instanceof AbstractRDFPrefixDocumentFormat && io.isAnonymous() && consumer.getConfiguration() .getMissingOntologyHeaderStrategy() == INCLUDE_GRAPH) { // We should have just included the triples rather // than imported them. So, // we remove the imports statement, add the axioms // from the imported ontology to // out importing ontology and remove the imported // ontology. // WHO EVER THOUGHT THAT THIS WAS A GOOD IDEA? man.applyChange(new RemoveImport(consumer.getOntology(), id)); io.importsDeclarations().forEach(d -> addImport(man, d)); io.annotations().forEach(ann -> addOntAnn(man, ann)); io.axioms().forEach(this::add); man.removeOntology(io); } } } }
protected void handleImportingRDFGraphRatherThanOntology(OWLImportsDeclaration id, OWLOntologyManager man, @Nullable OWLOntology io) { if (io != null) { OWLDocumentFormat importedOntologyFormat = io.getFormat(); if (importedOntologyFormat instanceof AbstractRDFPrefixDocumentFormat && io.isAnonymous() && consumer.getConfiguration() .getMissingOntologyHeaderStrategy() == INCLUDE_GRAPH) { // We should have just included the triples rather // than imported them. So, // we remove the imports statement, add the axioms // from the imported ontology to // out importing ontology and remove the imported // ontology. // WHO EVER THOUGHT THAT THIS WAS A GOOD IDEA? man.applyChange(new RemoveImport(consumer.getOntology(), id)); io.importsDeclarations().forEach(d -> addImport(man, d)); io.annotations().forEach(ann -> addOntAnn(man, ann)); io.axioms().forEach(this::add); man.removeOntology(io); } } } }
protected void handleImportingRDFGraphRatherThanOntology(OWLImportsDeclaration id, OWLOntologyManager man, @Nullable OWLOntology io) { if (io != null) { OWLDocumentFormat importedOntologyFormat = io.getFormat(); if (importedOntologyFormat instanceof AbstractRDFPrefixDocumentFormat && io.isAnonymous() && consumer.getConfiguration() .getMissingOntologyHeaderStrategy() == INCLUDE_GRAPH) { // We should have just included the triples rather // than imported them. So, // we remove the imports statement, add the axioms // from the imported ontology to // out importing ontology and remove the imported // ontology. // WHO EVER THOUGHT THAT THIS WAS A GOOD IDEA? man.applyChange(new RemoveImport(consumer.getOntology(), id)); io.importsDeclarations().forEach(d -> addImport(man, d)); io.annotations().forEach(ann -> addOntAnn(man, ann)); io.axioms().forEach(this::add); man.removeOntology(io); } } } }
protected void handleImportingRDFGraphRatherThanOntology(OWLImportsDeclaration id, OWLOntologyManager man, @Nullable OWLOntology io) { if (io != null) { OWLDocumentFormat importedOntologyFormat = io.getFormat(); if (importedOntologyFormat instanceof AbstractRDFPrefixDocumentFormat && io.isAnonymous() && consumer.getConfiguration() .getMissingOntologyHeaderStrategy() == INCLUDE_GRAPH) { // We should have just included the triples rather // than imported them. So, // we remove the imports statement, add the axioms // from the imported ontology to // out importing ontology and remove the imported // ontology. // WHO EVER THOUGHT THAT THIS WAS A GOOD IDEA? man.applyChange(new RemoveImport(consumer.getOntology(), id)); io.importsDeclarations().forEach(d -> addImport(man, d)); io.annotations().forEach(ann -> addOntAnn(man, ann)); io.axioms().forEach(this::add); man.removeOntology(io); } } } }
/** * Write ontology header. */ public void writeOntologyHeader() { event = new RendererEvent(this, o); fireFrameRenderingPrepared(ONTOLOGY.toString()); write(ONTOLOGY.toString()); write(":"); writeSpace(); if (!o.isAnonymous()) { int indent = getIndent(); writeFullURI(o.getOntologyID().getOntologyIRI().get().toString()); writeNewLine(); pushTab(indent); Optional<IRI> versionIRI = o.getOntologyID().getVersionIRI(); if (versionIRI.isPresent()) { writeFullURI(versionIRI.get().toString()); } popTab(); } fireFrameRenderingStarted(ONTOLOGY.toString()); writeNewLine(); o.importsDeclarations().sorted().forEach(this::writeImports); writeNewLine(); writeSection(ANNOTATIONS, o.annotations().iterator(), ",", true); fireFrameRenderingFinished(ONTOLOGY.toString()); }
@Override public void visit(OWLOntology ontology) { header(); write("<h1>").write(ontology.getOntologyID().toString()).write("</h1>\n"); write("<div><div class='box'>\n"); ontology.importsDeclarations() .forEach(d -> write("Imports: ").write(d.getIRI()).write("\n")); write("<h2>Classes</h2>\n").writeCollection(ontology.classesInSignature()); write("</div>\n<div class='box'>\n<h2>Properties</h2>\n") .writeCollection(ontology.objectPropertiesInSignature()) .writeCollection(ontology.dataPropertiesInSignature()); write("</div>\n<div class='box'>\n<h2>Individuals</h2>\n") .writeCollection(ontology.individualsInSignature()) .write("</div>"); write("<div><div class='box'><h2>Axioms</h2>\n"); writeListStart(); ontology.axioms().forEach(ax -> { writeListItemStart(); ax.accept(this); writeListEnd(); }); writeListEnd(); write("</div>"); footer(); }