Hi Paul,
On 02/10/12 13:24, Paul Taylor wrote:
I have an SDB Store which has several Named Graphs, and I would like
to get an OntoModel for a specific named graph model from the SDB
Store. To achieve this I do the following steps (Assume connection to
the store):
(1) Model baseModel = SDBFactory.connectNamedModel(store,
modelName); (2) OntModelSpec modelSpec = new
OntModelSpec(OntModelSpec.OWL_MEM); (3) OntModel ontModel =
ModelFactory.createOntologyModel(modelSpec, baseModel);
Do I miss something here? because from the log files it seems that
the FileMangaer.readModel() method is called that retrieves each
ontology URI from the web.
I'm not quite sure what you're doing, because the fragment above does
not read any models. I *assume* that what you're doing is calling
ontModel.read() with some file: or http: URL. The default behaviour of
OntModel when reading an OWL document which contains owl:imports
statements is to also load those imports as a sub-model of the OntModel.
The responsibility for locating the model to be loaded is delegated to
the imports model getter from the OntModelSpec. What I think you're
asking for is that somehow, the model getter should know that the base
model of the OntModel is attached to an SDB store, and that the SDB
store contains named graphs whose graph labels *happen* to be the same
as the imported URI to be loaded, and in that case the model getter
should use the SDB named graph model instead of creating a fresh model
to load the import into.
I hope you can see that that's not a general pattern, and so we don't
and won't support that as a default option in OntModel. However, all is
not lost: you can add your own model getter to the model spec so that it
can find models however you like. In you case, you'd need to define an
implementation of ModelGetter that looks in your SDB model for a named
graph. You then add that locator to the default file manager instance.
This may sound slightly involved, but I created a simplified example:
https://gist.github.com/3830267
The example uses TDB rather than SDB, since the setup is easier. However
the principles are the same.
Ian