/** * Removes a knowledge source with the given URL (independant of its type). * @param url URL of the OWL file or SPARQL Endpoint. * @return True if a knowledge source was deleted, false otherwise. */ public boolean removeKnowledgeSource(String url) { Iterator<AbstractKnowledgeSource> it = knowledgeSources.iterator(); while(it.hasNext()) { AbstractKnowledgeSource source = it.next(); if((source instanceof OWLFile && ((OWLFile)source).getURL().toString().equals(url)) || (source instanceof SparqlKnowledgeSource && ((SparqlKnowledgeSource)source).getURL().toString().equals(url)) ) { it.remove(); return true; } } return false; }
@Override public OWLOntology createOWLOntology(OWLOntologyManager manager) { try { return manager.loadOntologyFromOntologyDocument(IRI.create(getURL().toURI())); } catch (OWLOntologyCreationException | URISyntaxException e) { throw new RuntimeException(e); } }
private void loadModel(){ model = ModelFactory.createDefaultModel(); for (KnowledgeSource ks : reasoner.getSources()) { if(ks instanceof OWLFile){ try { model.read(((OWLFile) ks).getURL().openStream(), null); } catch (IOException e) { e.printStackTrace(); } } else if(ks instanceof OWLAPIOntology){ ByteArrayInputStream bais = new ByteArrayInputStream(((OWLAPIOntology) ks).getConverter().convert(((OWLAPIOntology) ks).getOntology())); model.read(bais, null); try { bais.close(); } catch (IOException e) { e.printStackTrace(); } } } }
private void loadModel(){ model = ModelFactory.createDefaultModel(); for (KnowledgeSource ks : reasoner.getSources()) { if(ks instanceof OWLFile){ try { model.read(((OWLFile) ks).getURL().openStream(), null); } catch (IOException e) { e.printStackTrace(); } } else if(ks instanceof OWLAPIOntology){ ByteArrayInputStream bais = new ByteArrayInputStream(((OWLAPIOntology) ks).getConverter().convert(((OWLAPIOntology) ks).getOntology())); model.read(bais, null); try { bais.close(); } catch (IOException e) { e.printStackTrace(); } } } }
} else { OWLFile owl_file = (OWLFile) abstract_ks; Model model = RDFDataMgr.loadModel(owl_file.getURL().getFile()); logger.debug(sparql_debug, "file reasoning: " + ((owl_file.getReasoning() == null || owl_file.getReasoning().getReasonerFactory() == null) ? "(none)" : owl_file.getReasoning().getReasonerFactory().getURI()));