/** * @return the collection of IRI mappers. This allows for iteration and * modification of the list. */ @Nonnull @Override public PriorityCollection<OWLOntologyIRIMapper> getIRIMappers() { return delegate.getIRIMappers(); }
/** * {@inheritDoc} */ @Override public void setIgnoreImports(final boolean ignoreImports) { _ignoreImports = ignoreImports; _manager.getIRIMappers().clear(); if (ignoreImports) _manager.getIRIMappers().add(_iriMapper); }
/** * {@inheritDoc} */ @Override public void setIgnoreImports(final boolean ignoreImports) { _ignoreImports = ignoreImports; _manager.getIRIMappers().clear(); if (ignoreImports) _manager.getIRIMappers().add(_iriMapper); }
/** * {@inheritDoc} */ @Override public void setIgnoreImports(final boolean ignoreImports) { _ignoreImports = ignoreImports; _manager.getIRIMappers().clear(); if (ignoreImports) _manager.getIRIMappers().add(_iriMapper); }
private void handleCommonBaseMappers(URI physicalURI) { String baseURIStr = ""; String uriParts[] = physicalURI.toString().split("/"); for (int i=0; i<uriParts.length-1; i++){ baseURIStr += uriParts[i] + "/"; } URI baseURI = URI.create(baseURIStr); if (baseURI != null){ if (baseMapper.get(baseURI) == null){ final BaseURIMapper mapper = new BaseURIMapper(baseURI); baseMapper.put(baseURI, mapper); mngr.getIRIMappers().add(mapper); } } }
private OWLOntology createFreshProjectOntology(OWLOntologyManager manager) throws OWLOntologyCreationException, OWLOntologyStorageException { logger.info("Creating a fresh project with an Id of {}", projectId); File parentDirectory = rootOntologyDocument.getParentFile(); parentDirectory.mkdirs(); IRI ontologyIRI = createUniqueOntologyIRI(); IRI documentIRI = IRI.create(rootOntologyDocument); SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI); manager.getIRIMappers().add(mapper); OWLOntology ontology = manager.createOntology(ontologyIRI); manager.getIRIMappers().remove(mapper); writeNewProject(manager, ontology); return ontology; }
public OWLOntology createNewOntology(OWLOntologyID ontologyID, URI physicalURI) throws OWLOntologyCreationException { if(physicalURI != null && ontologyID.getDefaultDocumentIRI().isPresent()) { manager .getIRIMappers() .add(new SimpleIRIMapper(ontologyID.getDefaultDocumentIRI().get(), IRI.create(physicalURI))); } OWLOntology ont = manager.createOntology(ontologyID); setActiveOntology(ont); if(physicalURI != null) { try { File containingDirectory = new File(physicalURI).getParentFile(); if(containingDirectory.exists()) { getOntologyCatalogManager().addFolder(containingDirectory); } } catch(IllegalArgumentException iae) { logger.info("Cannot generate ontology catalog for ontology at {}. {}", physicalURI, iae.getMessage()); } } fireEvent(EventType.ONTOLOGY_CREATED); return ont; }
public OWLOntology createNewOntology(OWLOntologyID ontologyID, URI physicalURI) throws OWLOntologyCreationException { if (physicalURI != null && ontologyID.getDefaultDocumentIRI().isPresent()) { manager.getIRIMappers().add(new SimpleIRIMapper(ontologyID.getDefaultDocumentIRI().get(), IRI.create(physicalURI))); } OWLOntology ont = manager.createOntology(ontologyID); setActiveOntology(ont); if (physicalURI != null) { try { File containingDirectory = new File(physicalURI).getParentFile(); if (containingDirectory.exists()) { getOntologyCatalogManager().addFolder(containingDirectory); } } catch (IllegalArgumentException iae) { logger.warn("Cannot generate ontology catalog for ontology at " + physicalURI); } } fireEvent(EventType.ONTOLOGY_CREATED); return ont; }
public OWLAPIOntologyCollector(String ontologyIRI, String physicalIRI){ this.ontologyIRI = IRI.create(ontologyIRI); this.physicalIRI = IRI.create(new File(physicalIRI)); SimpleIRIMapper mapper = new SimpleIRIMapper(this.ontologyIRI, this.physicalIRI); this.manager.getIRIMappers().add(mapper); try{ this.currentOntology = manager.createOntology(this.ontologyIRI); }catch(OWLOntologyCreationException e){ logger.error("FATAL failed to create Ontology " + this.ontologyIRI); e.printStackTrace(); } this.factory = manager.getOWLDataFactory(); }
@Test public void shouldAddAxiom() throws Exception { OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); IRI ontologyIRI = IRI.create("http://www.co-ode.org/ontologies/testont.owl"); IRI documentIRI = IRI.create("file:/tmp/MyOnt.owl"); SimpleIRIMapper mapper = new SimpleIRIMapper(ontologyIRI, documentIRI); manager.getIRIMappers().add(mapper); OWLOntology ontology = manager.createOntology(ontologyIRI); OWLDataFactory factory = manager.getOWLDataFactory(); OWLClass clsA = factory.getOWLClass(IRI.create(ontologyIRI + "#A")); OWLClass clsB = factory.getOWLClass(IRI.create(ontologyIRI + "#B")); OWLAxiom axiom = factory.getOWLSubClassOfAxiom(clsA, clsB); AddAxiom addAxiom = new AddAxiom(ontology, axiom); manager.applyChange(addAxiom); manager.saveOntology(ontology); }
private void createDebuggingOntology() { if (debuggingOntology != null) { man.removeOntology(verifyNotNull(debuggingOntology)); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); man.getIRIMappers().add(mapper); try { debuggingOntology = man.createOntology(iri); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } man.getIRIMappers().remove(mapper); List<AddAxiom> changes = new ArrayList<>(); debuggingAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); temporaryAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); // Ensure the ontology contains the signature of the class which is // being debugged OWLAxiom ax = df.getOWLSubClassOfAxiom(verifyNotNull(currentClass), df.getOWLThing()); changes.add(new AddAxiom(getDebuggingOntology(), ax)); man.applyChanges(changes); }
private void createDebuggingOntology() { if (debuggingOntology != null) { man.removeOntology(verifyNotNull(debuggingOntology)); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); man.getIRIMappers().add(mapper); try { debuggingOntology = man.createOntology(iri); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } man.getIRIMappers().remove(mapper); List<AddAxiom> changes = new ArrayList<>(); debuggingAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); temporaryAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); // Ensure the ontology contains the signature of the class which is // being debugged OWLAxiom ax = df.getOWLSubClassOfAxiom(verifyNotNull(currentClass), df.getOWLThing()); changes.add(new AddAxiom(getDebuggingOntology(), ax)); man.applyChanges(changes); }
private void createDebuggingOntology() { if (debuggingOntology != null) { man.removeOntology(verifyNotNull(debuggingOntology)); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); man.getIRIMappers().add(mapper); try { debuggingOntology = man.createOntology(iri); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } man.getIRIMappers().remove(mapper); List<AddAxiom> changes = new ArrayList<>(); debuggingAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); temporaryAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); // Ensure the ontology contains the signature of the class which is // being debugged OWLAxiom ax = df.getOWLSubClassOfAxiom(verifyNotNull(currentClass), df.getOWLThing()); changes.add(new AddAxiom(getDebuggingOntology(), ax)); man.applyChanges(changes); }
private void createDebuggingOntology() { if (debuggingOntology != null) { man.removeOntology(verifyNotNull(debuggingOntology)); } IRI iri = createIRI(); SimpleIRIMapper mapper = new SimpleIRIMapper(iri, iri); man.getIRIMappers().add(mapper); try { debuggingOntology = man.createOntology(iri); } catch (OWLOntologyCreationException e) { throw new OWLRuntimeException(e); } man.getIRIMappers().remove(mapper); List<AddAxiom> changes = new ArrayList<>(); debuggingAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); temporaryAxioms.forEach(ax -> changes.add(new AddAxiom(getDebuggingOntology(), ax))); // Ensure the ontology contains the signature of the class which is // being debugged OWLAxiom ax = df.getOWLSubClassOfAxiom(verifyNotNull(currentClass), df.getOWLThing()); changes.add(new AddAxiom(getDebuggingOntology(), ax)); man.applyChanges(changes); }
private void addImportMapping(OWLOntology ontology, IRI importLocation, IRI physicalLocation) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); manager.getIRIMappers().add(new SimpleIRIMapper(importLocation, physicalLocation)); IRI importersDocumentLocation = manager.getOntologyDocumentIRI(ontology); if (UIUtil.isLocalFile(importersDocumentLocation.toURI())) { File f = new File(importersDocumentLocation.toURI()); XMLCatalog catalog = editorKit.getModelManager().addRootFolder(f.getParentFile()); URI physicalUri = CatalogUtilities.relativize(physicalLocation.toURI(), catalog); catalog.addEntry(0, new UriEntry("Imports Wizard Entry", catalog, importLocation.toURI().toString(), physicalUri, null)); try { CatalogUtilities.save(catalog, OntologyCatalogManager.getCatalogFile(f.getParentFile())); } catch (IOException e) { logger.warn("An error occurred whilst saving the catalog file: {}", e); } } }
private void addImportMapping(OWLOntology ontology, IRI importLocation, IRI physicalLocation) { OWLOntologyManager manager = ontology.getOWLOntologyManager(); manager.getIRIMappers().add(new SimpleIRIMapper(importLocation, physicalLocation)); IRI importersDocumentLocation = manager.getOntologyDocumentIRI(ontology); if (UIUtil.isLocalFile(importersDocumentLocation.toURI())) { File f = new File(importersDocumentLocation.toURI()); XMLCatalog catalog = editorKit.getModelManager().addRootFolder(f.getParentFile()); URI physicalUri = CatalogUtilities.relativize(physicalLocation.toURI(), catalog); catalog.addEntry(0, new UriEntry("Imports Wizard Entry", catalog, importLocation.toURI().toString(), physicalUri, null)); try { CatalogUtilities.save(catalog, OntologyCatalogManager.getCatalogFile(f.getParentFile())); } catch (IOException e) { logger.warn("An error occurred whilst saving the catalog file: {}", e); } } }
private static void addSWRLAPIOntologies(@NonNull OWLOntology ontology) { List<SimpleIRIMapper> iriMappers = new ArrayList<>(); iriMappers .add(new SimpleIRIMapper(IRI.create("http://www.w3.org/2003/11/swrl#"), resourcePath2IRI("owl/swrl.owl"))); iriMappers .add(new SimpleIRIMapper(IRI.create("http://www.w3.org/2003/11/swrlb#"), resourcePath2IRI("owl/swrlb.owl"))); iriMappers.add(new SimpleIRIMapper(IRI.create("http://swrl.stanford.edu/ontologies/3.3/swrla.owl"), resourcePath2IRI("owl/swrla.owl"))); iriMappers.add(new SimpleIRIMapper(IRI.create("http://swrl.stanford.edu/ontologies/built-ins/3.4/swrlm.owl"), resourcePath2IRI("owl/swrlm.owl"))); iriMappers.add(new SimpleIRIMapper(IRI.create("http://swrl.stanford.edu/ontologies/built-ins/3.3/swrlx.owl"), resourcePath2IRI("owl/swrlx.owl"))); iriMappers.add(new SimpleIRIMapper(IRI.create("http://swrl.stanford.edu/ontologies/built-ins/3.3/temporal.owl"), resourcePath2IRI("owl/temporal.owl"))); iriMappers.add(new SimpleIRIMapper(IRI.create("http://sqwrl.stanford.edu/ontologies/built-ins/3.4/sqwrl.owl"), resourcePath2IRI("owl/sqwrl.owl"))); for (SimpleIRIMapper iriMapper : iriMappers) ontology.getOWLOntologyManager().getIRIMappers().add(iriMapper); }
@Override public OWLOntology parseConclusionOntology(SerializationFormat format) throws OntologyParseException { try { final OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); manager.setOntologyLoaderConfiguration(manager.getOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT)); manager.getIRIMappers().clear(); ImportsHelper.loadImports(manager, this, format); OWLOntology o = parsedConclusion.get(format); if (o == null) { final String l = getConclusionOntology(format); if (l == null) { return null; } final StringDocumentSource source = new StringDocumentSource(l); o = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(source); parsedConclusion.put(format, o); } return o; } catch (final OWLOntologyCreationException e) { throw new OntologyParseException(e); } }
@Override public OWLOntology parseConclusionOntology(SerializationFormat format) throws OntologyParseException { try { final OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); manager.setOntologyLoaderConfiguration(manager.getOntologyLoaderConfiguration().setMissingImportHandlingStrategy(MissingImportHandlingStrategy.SILENT)); manager.getIRIMappers().clear(); ImportsHelper.loadImports(manager, this, format); OWLOntology o = parsedConclusion.get(format); if (o == null) { final String l = getConclusionOntology(format); if (l == null) { return null; } final StringDocumentSource source = new StringDocumentSource(l); o = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(source); parsedConclusion.put(format, o); } return o; } catch (final OWLOntologyCreationException e) { throw new OntologyParseException(e); } }
@Override public void setInputOntology(final String inputFileURI) { _manager.clearOntologies(); OWLOntology ont = null; try { _manager.getIRIMappers().add(_mapper); ont = _manager.loadOntology(IRI.create(inputFileURI)); _reasoner = OpenlletReasonerFactory.getInstance().createReasoner(ont); } catch (final OWLException e) { throw new OpenError(e); } finally { if (ont != null) _manager.removeOntology(ont); } }