Reputation: 4160
I've created an ontology using Protege and would now like to add individuals with Jena.
Let's say there is a class SpecialThing
that has a property hasData
. Now I'd like to programmatically add a new SpecialThing
. That's my code so far, but the created individual is only an instance of Thing
. So what do I have to add here? Using model.createResource
I can only specify the URI of the resource to be created.
String ns = "http://example.org";
Resource res = model.createResource(ns + "/NewThing");
Property prop = model.getProperty(ns + "#hasData");
res.addProperty(prop, "something");
Upvotes: 2
Views: 2663
Reputation: 2181
You can specify the type of the resource as a second argument to the createResource() method. Take a look at ModelCon.createResource()
Upvotes: 2