Search code examples
jenaontologyowlprotege

object property values for individuals in Jena


I have created an ontology using Protégé. Using Jena, I am creating an individual and assigning values for its properties. Datatype properties can be created using getOntProperty(String uri), but using the same method I cannot create object properties. Which method can be used to create object properties and add values for an object property?


Solution

  • getOntProperty(String) is an OntModel method for creating or retrieving properties from an ontology, not for making property assertions about Individuals. For datatype properties, you should probably be using getDatatypeProperty(String) instead. For object properties, you should use getObjectProperty(String). All of these methods are described in the documentation. Once you have a property, you can use the methods that an Individual inherits from Resource to add properties values. In particular, you'd want the addProperty and addLiteral methods.