Thanks, that worked.
On Thu, Sep 3, 2015 at 2:23 PM, Dave Reynolds <dave.e.reyno...@gmail.com> wrote: > On 03/09/15 11:46, Martynas Jusevičius wrote: >> >> Hey list, >> >> I was implementing a OO-like inheritance for annotation properties >> when I realized I can probably express it as custom Jena rules. I want >> to push the properties down the subclass chains and preferably >> materialize them. Currently my code looks like this: >> >> String rules = "[inheritance: (?class ?p ?o), (?p rdf:type >> owl:AnnotationProperty), (?subClass rdfs:subClassOf ?class), >> noValue(?subClass ?p) -> (?subClass ?p ?o) ]"; >> Reasoner reasoner = new >> GenericRuleReasoner(Rule.parseRules(rules)); >> reasoner.setDerivationLogging(true); >> reasoner.setParameter(ReasonerVocabulary.PROPtraceOn, >> Boolean.TRUE); >> OntModel ontModel = >> OntDocumentManager.getInstance().getOntology(ontologyURI, >> OntModelSpec.OWL_MEM); >> reasoner.bindSchema(ontModel); >> ontModel.prepare(); >> >> This does not seem to work however - subclasses without annotations do >> not seem to inherit them from superclasses. Could the rule be wrong? >> Should I be constructing the OntModel with a custom OntModelSpec >> instead of bindSchema()? > > > The latter. The bindSchema call isn't side-effecting, what it does is return > a new reasoner that now "knows" about the ontology data. It changes neither > the original reasoner nor the model you feed in. > > You want something more like: > > OntModelSpec spec = new OntModelSpec(OntModelSpec.OWL_MEM); > spec.setReasoner(reasoner); > OntModel ontModel = ModelFactory.createOntologyModel(spec, ...); > > Dave