Hello Ian, Thank you for your answer and simple example, and apologies for this late reply. What I am actually doing is that I have an SDBStore that is connected to a MySQL DB, the code uses SDBFactory to connect to a named model in the SDBStore and returns a Model object, like that: Model model = SDBFactory.connectNamedModel(store, modelName). Having obtained the Model object I call FileManager.get().readModel(model, sourceURL) to read a model from a file or URI. The URIs the code is reading into the model are URIs at the schema level (RDFS or OWL). For the purposes of my application I would like to perform some simple form of reasoning over such a Model object, so I though to create an OntoModel over my existing Model that will allow me to do so, correct me if my understanding is wrong. The other way I could do this is to create an OntoModel from the start, I am not sure, can I do that? Also, is there any other way to obtain an OntResource or OntClass object and do some reasoning over the model that I have?
----- Original Message ----- From: Ian Dickinson <[email protected]> To: [email protected] Cc: Sent: Wednesday, 3 October 2012, 23:29 Subject: Re: Get OntoModel from SDB store Named Graph 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
