@Override public Ontology getOntology(String uri) { return inner.getOntology(uri); }
private org.apache.jena.ontology.Ontology getOntology(String ontologyURI, OntModel ontModel) { // Something non-ideal happens here. There are places in the code that // call getOntology() but don't pass the URI of the ontology resource // itself. Instead, they pass the namespace that would appear // in a PREFIX declaration. For example, we might have an ontology with // the namespace http://example.org/ontology# . // A class in this namespace might have the URI // http://example.org/ontology#SomeClass . The ontology resource // itself, however, may have the URI http://example.org/ontology // (no final hash mark). To support assumptions in the code, // this method calls adjustOntologyURI to remove a trailing hash // mark if an ontology resource is not found at the specified URI. try { ontModel.enterCriticalSection(Lock.READ); org.apache.jena.ontology.Ontology o = ontModel.getOntology( ontologyURI); if (o != null) { return o; } else { return ontModel.getOntology( adjustOntologyURI(ontologyURI)); } } finally { ontModel.leaveCriticalSection(); } }
/** * Sets the ontology version data. * * @param doc the Solr input document * @param ontModel the ontology model * @throws IOException if failed to communicate with Solr server while indexing ontology * @throws SolrServerException if failed to index ontology */ private void setVersion(@Nonnull final SolrInputDocument doc, @Nonnull final OntModel ontModel) throws IOException, SolrServerException { final String version = ontModel.getOntology(getBaseOntologyUri()).getVersionInfo(); if (StringUtils.isNotBlank(version)) { doc.addField(ID_FIELD_NAME, HEADER_INFO_LABEL); doc.addField(VERSION_FIELD_NAME, version); this.externalServicesAccess.getReplacementSolrConnection(this).add(doc); doc.clear(); } }
public void testGetOntology() { OntModel m = ModelFactory.createOntologyModel(); Resource r = m.getResource( NS + "r" ); m.add( r, RDF.type, r ); Resource s = m.createOntology( NS + "s" ); assertEquals( "Result of get s", s, m.getOntology( NS + "s" ) ); assertNull( "result of get q", m.getOntology( NS+"q") ); assertNull( "result of get r", m.getOntology( NS+"r")); }
public void testGetOntology() { OntModel m = ModelFactory.createOntologyModel(); Resource r = m.getResource( NS + "r" ); m.add( r, RDF.type, r ); Resource s = m.createOntology( NS + "s" ); assertEquals( "Result of get s", s, m.getOntology( NS + "s" ) ); assertNull( "result of get q", m.getOntology( NS+"q") ); assertNull( "result of get r", m.getOntology( NS+"r")); }
public void deleteOntology(Ontology ontology, OntModel ontModel) { ontModel.enterCriticalSection(Lock.WRITE); try { org.apache.jena.ontology.Ontology o = getOntology(ontology.getURI(),ontModel); if (o == null) { o = ontModel.getOntology(adjustOntologyURI(ontology.getURI())); } if (o != null) { o.remove(); } } finally { ontModel.leaveCriticalSection(); } }