You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Chris Tomlinson <ch...@gmail.com> on 2020/04/22 23:21:59 UTC

OntDocumentManager and related questions

Hello,

We’re having some difficulties using the OntDocumentManager properly. I’ve put together a test app <https://pastebin.com/CUebj548> that exercises several usages.

I am running it in eclipse with references to the jena libs from 3.15-SNAPSHOT <https://github.com/apache/jena> which I built locally via

>     mvn clean install -Pdev

other than this, the test app is standalone. The

> 	private static final String OUT = <local directory path for output ttl files>;
> 	private static final String DS = <dataset URL for putting and fetching models/graphs>;


need to be set properly as indicated.

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?


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?


3) Finally, contrary the javadocs:

>     om.loadImports();

does not lead to loading the imports when:

>      odm.setProcessImports(true or false);

Why?


I’m sure I’ve mucked up something but I don’t see it.

Thanks for help on this,
Chris




Re: OntDocumentManager and related questions

Posted by Chris Tomlinson <ch...@gmail.com>.
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 <ch...@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
> 
> 
>