Hi, On Mon, 2011-08-29 at 10:31 +0200, Martin Weitzel wrote:
> I want to test within my InfModel, how modified (deleted, added) Statements > (via > Jena Java API) are dealt with by the Reasoner. > > The Model is initiated by: > infModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); > > Then, individuals are added like: > final OntClass classOfferedHandlingCondition = infModel.getResource( > nsImotrisOntology + "#OfferedHandlingCondition").as(OntClass.class); > > final Individual individualOfferedService = > classOfferedServices.createIndividual(nsImotrisOntology + "#OfferedService_" > + > offeredService.id); > > This works fine _before_ reasoning. However, after Reasoning, the OntClass > cast > fails with: > > Cannot convert node > http://www.igd-r.fraunhofer.de/IMOTRIS/Ontologies/imotris.owl#OfferedServiceto > OntClass: it does not have rdf:type owl:Class or equivalent. > > But the rdf:type is definitely there: I am printing the related statements > with > listStatements() right before the cast. > > [Console Output:] - > ( > http://www.igd-r.fraunhofer.de/IMOTRIS/Ontologies/imotris.owl#OfferedService > rdf:type owl:Class) > > If I disable the reasoner within exact the same setup, the cast works fine. > > The Reasoner is configured as follows: > > final GenericRuleReasoner reasoner = new > GenericRuleReasoner(Rule.rulesFromURL(owlResourceReasonerRulesLayer > .getFile().toURI().toURL().toExternalForm())); > infModel = ModelFactory.createInfModel(reasoner, infModel); > And the Rules are shown here: http://pastebin.com/i96sM1W3 > > > So: Why is the OntClass cast impossible after reasoning? I would appreciate > any > hints! This is nothing to do with reasoning. We would need a complete minimal example to work out exactly what is going on but I suspect you are just getting the two models (the OntModel and the non-Ont-InfModel) mixed up since you assign them both to the same java variable. Depending on when you create the OntClasses and Individuals they will be pointing to one or other model and it would be easy to be printing from one but implicitly querying from the other. The easy way to get both inference and and OntModel API is to clone your own copy of the relevant OneModel spec: OntModelSpec myspec = new OntModelSpec(OntModelSpec.OWL_MEM); myspec.setReasoner(reasoner); infModel = ModelFactory.createOntologyModel(myspec); Dave
