I think I now understand a little better about OntDocumentManager and 
OntModels. I stared at Jena code, documentation 
<https://jena.apache.org/documentation/ontology/> and more test code. Maybe the 
following will be helpful to someone else.

> On Apr 22, 2020, at 6:21 PM, Chris Tomlinson <chris.j.tomlin...@gmail.com> 
> wrote:
> 
> ...
> 
> There are several things that don’t seem to work as expected from the docs:
> 
> 1) The code:
> 
>>     OntModel om = odm.getOntology(ontUri, oms); 
> 
> returns a model w/ just the contents of the file located via baseURI:
> 
>>     http://purl.bdrc.io/shapes/core/PersonShapes/ 
>> <http://purl.bdrc.io/shapes/core/PersonShapes/>
> from the ont-policy.rdf 
> <https://raw.githubusercontent.com/buda-base/editor-templates/master/ont-policy.rdf>,
>  regardless of the setting:
> 
>>      odm.setProcessImports(true or false);
> 
> The javadocs indicate that if true the imports should be processed by 
> getOntology, but this isn’t happening at this point?

Key point here was I overlooked:

>     write() on an ontology model will only write the statements from the base 
> model.

so even though the imports were processed, om.write(...) was misleading me in 
that it only writes om.getBaseModel() so I wasn’t seeing the imported content.

The call om.writeAll(…) produces the desired result as the documentation 
<https://jena.apache.org/documentation/ontology/> indicates. Another case of 
failing to rtfm on my part.

The OntModel contains a baseModel resulting from loading the top-level document 
and a collection of subModels one for the baseModel and an OntModel for each of 
the imported documents.



> 2) However, when
> 
>>      String graphName = BDG+graphLocalName;
>>         fuConn.put(graphName, om);
> 
> 
> Then the graph is stored on Fuseki with the given graphName and if
> 
>>      odm.setProcessImports(true);
> 
> 
> then the imported triples appear in the graph on Fuseki even though they 
> don’t appear to be present in local OntModel, om, in the app.
> 
> It’s almost like the fuConn.put() causes the imports to be loaded on-the-fly.
> 
> Why is this?

The crux is that fuConn.put(…) performs om.getGraph() which returns a graph 
that contains all the content of the baseModel and the subModels. So what’s 
transferred to fuseki has all the imported content which does look mysterious 
when compared to the document resulting from om.write(…) versus om.writeAll(…).



> 3) Finally, contrary the javadocs:
> 
>>     om.loadImports();
> 
> does not lead to loading the imports when:
> 
>>      odm.setProcessImports(true or false);
> 
> Why?

Same error as number 1).


Hopefully this is some value to others,
Chris


> I’m sure I’ve mucked up something but I don’t see it.
> 
> Thanks for help on this,
> Chris
> 
> 
> 

Reply via email to