@Override public OWLOntology getImportedOntology(OWLImportsDeclaration declaration) { return delegate.getImportedOntology(declaration); }
private String getMismatchedImportMessage() { StringBuilder sb = new StringBuilder(); sb.append("<html><body>"); sb.append("The imports URI:<br>"); sb.append("<font color=\"blue\">"); sb.append(decl.getIRI()); sb.append("</font>"); sb.append("<br>"); sb.append("does not match the URI of the ontology that has been imported:<br>"); sb.append("<font color=\"blue\">"); OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? sb.append(ont == null ? "(Not loaded)" : ont.getOntologyID().getDefaultDocumentIRI().get()); sb.append("</font><br><br>"); sb.append("Do you want to fix the mismatch by modifying the imports statement?"); sb.append("</body></html>"); return sb.toString(); }
private String getMismatchedImportMessage() { StringBuilder sb = new StringBuilder(); sb.append("<html><body>"); sb.append("The imports URI:<br>"); sb.append("<font color=\"blue\">"); sb.append(decl.getURI()); sb.append("</font>"); sb.append("<br>"); sb.append("does not match the URI of the ontology that has been imported:<br>"); sb.append("<font color=\"blue\">"); OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? sb.append(ont == null ? "(Not loaded)" : ont.getOntologyID().getDefaultDocumentIRI()); sb.append("</font><br><br>"); sb.append("Do you want to fix the mismatch by modifying the imports statement?"); sb.append("</body></html>"); return sb.toString(); }
private String getMismatchedImportMessage() { StringBuilder sb = new StringBuilder(); sb.append("<html><body>"); sb.append("The imports URI:<br>"); sb.append("<font color=\"blue\">"); sb.append(decl.getIRI()); sb.append("</font>"); sb.append("<br>"); sb.append("does not match the URI of the ontology that has been imported:<br>"); sb.append("<font color=\"blue\">"); OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? sb.append(ont == null ? "(Not loaded)" : ont.getOntologyID().getDefaultDocumentIRI().get()); sb.append("</font><br><br>"); sb.append("Do you want to fix the mismatch by modifying the imports statement?"); sb.append("</body></html>"); return sb.toString(); }
private String getMismatchedImportMessage() { StringBuilder sb = new StringBuilder(); sb.append("<html><body>"); sb.append("The imports URI:<br>"); sb.append("<font color=\"blue\">"); sb.append(decl.getURI()); sb.append("</font>"); sb.append("<br>"); sb.append("does not match the URI of the ontology that has been imported:<br>"); sb.append("<font color=\"blue\">"); OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? sb.append(ont == null ? "(Not loaded)" : ont.getOntologyID().getDefaultDocumentIRI()); sb.append("</font><br><br>"); sb.append("Do you want to fix the mismatch by modifying the imports statement?"); sb.append("</body></html>"); return sb.toString(); }
public List<MListButton> getAdditionalButtons() { OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); if(ont == null) { return Collections.emptyList(); } Optional<IRI> defaultDocumentIRI = ont.getOntologyID().getDefaultDocumentIRI(); if (Optional.of(decl.getIRI()).equals(defaultDocumentIRI)) { return Collections.emptyList(); } return Collections.singletonList(fixImportsButton); }
public List<MListButton> getAdditionalButtons() { OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); if(ont == null) { return Collections.emptyList(); } Optional<IRI> defaultDocumentIRI = ont.getOntologyID().getDefaultDocumentIRI(); if (Optional.of(decl.getIRI()).equals(defaultDocumentIRI)) { return Collections.emptyList(); } return Collections.singletonList(fixImportsButton); }
private static void adjustImports(OWLOntology ontology, List<OWLOntologyChange> changes, OWLOntologyLoaderConfiguration configuration) throws UnloadableImportException { OWLOntologyManager manager = ontology.getOWLOntologyManager(); Set<OWLImportsDeclaration> finalDeclaredImports = ontology.getImportsDeclarations(); Set<OWLImportsDeclaration> missingImports = new TreeSet<OWLImportsDeclaration>(); for (OWLOntologyChange change : changes) { if (change instanceof AddImport) { OWLImportsDeclaration importDecl = ((AddImport) change).getImportDeclaration(); if (finalDeclaredImports.contains(importDecl) && manager.getImportedOntology(importDecl) == null) { missingImports.add(importDecl); } } } for (OWLImportsDeclaration missingImport : missingImports) { manager.makeLoadImportRequest(missingImport, configuration); } }
public List<MListButton> getAdditionalButtons() { OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? if (ont != null && !decl.getIRI().equals(ont.getOntologyID().getDefaultDocumentIRI())) { return Collections.singletonList(fixImportsButton); } return Collections.EMPTY_LIST; }
public List<MListButton> getAdditionalButtons() { OWLOntology ont = eKit.getOWLModelManager().getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? if (ont != null && !decl.getIRI().equals(ont.getOntologyID().getDefaultDocumentIRI())) { return Collections.singletonList(fixImportsButton); } return Collections.EMPTY_LIST; }
private void handleImportsFix() { int ret = JOptionPane.showConfirmDialog(eKit.getWorkspace(), getMismatchedImportMessage(), "Mismatched import", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if(ret == JOptionPane.YES_OPTION) { List<OWLOntologyChange> changes = new ArrayList<>(); changes.add(new RemoveImport(ont, decl)); final OWLModelManager mngr = eKit.getOWLModelManager(); OWLOntology impOnt = mngr.getOWLOntologyManager().getImportedOntology(decl); if (impOnt != null) { Optional<IRI> defaultDocumentIRI = impOnt.getOntologyID().getDefaultDocumentIRI(); if (defaultDocumentIRI.isPresent()) { changes.add(new AddImport(ont, mngr.getOWLDataFactory().getOWLImportsDeclaration(defaultDocumentIRI.get()))); mngr.applyChanges(changes); } } } }
private void handleImportsFix() { int ret = JOptionPane.showConfirmDialog(eKit.getWorkspace(), getMismatchedImportMessage(), "Mismatched import", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if(ret == JOptionPane.YES_OPTION) { List<OWLOntologyChange> changes = new ArrayList<>(); changes.add(new RemoveImport(ont, decl)); final OWLModelManager mngr = eKit.getOWLModelManager(); OWLOntology impOnt = mngr.getOWLOntologyManager().getImportedOntology(decl); if (impOnt != null) { Optional<IRI> defaultDocumentIRI = impOnt.getOntologyID().getDefaultDocumentIRI(); if (defaultDocumentIRI.isPresent()) { changes.add(new AddImport(ont, mngr.getOWLDataFactory().getOWLImportsDeclaration(defaultDocumentIRI.get()))); mngr.applyChanges(changes); } } } }
private void handleImportsFix() { int ret = JOptionPane.showConfirmDialog(eKit.getWorkspace(), getMismatchedImportMessage(), "Mismatched import", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if(ret == JOptionPane.YES_OPTION) { List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); changes.add(new RemoveImport(ont, decl)); final OWLModelManager mngr = eKit.getOWLModelManager(); OWLOntology impOnt = mngr.getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? changes.add(new AddImport(ont, mngr.getOWLDataFactory().getOWLImportsDeclaration(impOnt.getOntologyID().getDefaultDocumentIRI()))); mngr.applyChanges(changes); } }
private void handleImportsFix() { int ret = JOptionPane.showConfirmDialog(eKit.getWorkspace(), getMismatchedImportMessage(), "Mismatched import", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); if(ret == JOptionPane.YES_OPTION) { List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(); changes.add(new RemoveImport(ont, decl)); final OWLModelManager mngr = eKit.getOWLModelManager(); OWLOntology impOnt = mngr.getOWLOntologyManager().getImportedOntology(decl); // @@TODO what about anonymous ontologies? changes.add(new AddImport(ont, mngr.getOWLDataFactory().getOWLImportsDeclaration(impOnt.getOntologyID().getDefaultDocumentIRI()))); mngr.applyChanges(changes); } }
protected OWLOntologyID handleOntology(OWLOntology ont, Set<AddImport> imports, Set<AddOntologyAnnotation> ontologyAnnotations) { OWLOntologyID ontologyID; ManchesterOWLSyntaxOntologyHeader header = parseOntologyHeader(false); for (OWLImportsDeclaration decl : header.getImportsDeclarations()) { assert decl != null; imports.add(new AddImport(ont, decl)); ont.getOWLOntologyManager().makeLoadImportRequest(decl, getOntologyLoaderConfiguration()); OWLOntology imported = ont.getOWLOntologyManager().getImportedOntology(decl); if (imported != null) { imported.axioms(AxiomType.DECLARATION).forEach(this::processDeclaredEntities); } } for (OWLAnnotation anno : header.getAnnotations()) { ontologyAnnotations.add(new AddOntologyAnnotation(ont, anno)); } ontologyID = header.getOntologyID(); return ontologyID; }
void addOntologyStructure(OWLOntologyManager manager, OWLOntology ontology) { long parent = graph.createNode(OwlApiUtils.getIri(ontology)); graph.addLabel(parent, OwlLabels.OWL_ONTOLOGY); for (OWLImportsDeclaration importDeclaration : ontology.getImportsDeclarations()) { OWLOntology childOnt = manager.getImportedOntology(importDeclaration); if (null == childOnt) { // TODO: Why is childOnt sometimes null (when importing rdf)? continue; } long child = graph.createNode(OwlApiUtils.getIri(childOnt)); graph.addLabel(parent, OwlLabels.OWL_ONTOLOGY); if (graph.getRelationship(child, parent, OwlRelationships.RDFS_IS_DEFINED_BY).isPresent()) { continue; } graph.createRelationship(child, parent, OwlRelationships.RDFS_IS_DEFINED_BY); addOntologyStructure(manager, childOnt); } }
@Override public void handleTriple(IRI s, IRI p, IRI o) { consume(s, p, o); consumer.addOntology(s); consumer.addOntology(o); OWLImportsDeclaration id = df.getOWLImportsDeclaration(o); consumer.addImport(id); if (!consumer.getConfiguration().isIgnoredImport(o)) { OWLOntologyManager man = consumer.getOWLOntologyManager(); man.makeLoadImportRequest(id, consumer.getConfiguration()); handleImportingRDFGraphRatherThanOntology(id, man, man.getImportedOntology(id)); consumer.importsClosureChanged(); } }
@Override public void handleTriple(IRI s, IRI p, IRI o) { consume(s, p, o); consumer.addOntology(s); consumer.addOntology(o); OWLImportsDeclaration id = df.getOWLImportsDeclaration(o); consumer.addImport(id); if (!consumer.getConfiguration().isIgnoredImport(o)) { OWLOntologyManager man = consumer.getOWLOntologyManager(); man.makeLoadImportRequest(id, consumer.getConfiguration()); handleImportingRDFGraphRatherThanOntology(id, man, man.getImportedOntology(id)); consumer.importsClosureChanged(); } }
@Override public void handleTriple(IRI s, IRI p, IRI o) { consume(s, p, o); consumer.addOntology(s); consumer.addOntology(o); OWLImportsDeclaration id = df.getOWLImportsDeclaration(o); consumer.addImport(id); if (!consumer.getConfiguration().isIgnoredImport(o)) { OWLOntologyManager man = consumer.getOWLOntologyManager(); man.makeLoadImportRequest(id, consumer.getConfiguration()); handleImportingRDFGraphRatherThanOntology(id, man, man.getImportedOntology(id)); consumer.importsClosureChanged(); } }
@Override public void handleTriple(IRI s, IRI p, IRI o) { consume(s, p, o); consumer.addOntology(s); consumer.addOntology(o); OWLImportsDeclaration id = df.getOWLImportsDeclaration(o); consumer.addImport(id); if (!consumer.getConfiguration().isIgnoredImport(o)) { OWLOntologyManager man = consumer.getOWLOntologyManager(); man.makeLoadImportRequest(id, consumer.getConfiguration()); handleImportingRDFGraphRatherThanOntology(id, man, man.getImportedOntology(id)); consumer.importsClosureChanged(); } }