On 02/09/2012 08:37, Yoga Indra Pamungkas wrote:
Well, I have problem to make dynamic RDF.type. The RDF.type should get dynamic 
from anotation by user.

This is my static RDF.type code :


Resource thesis = model.createResource(thesisURI)
                 .addProperty(RDF.type, 
semantic.OntologyKomputasi.mechanicalTurk)
                 .addProperty(DC.creator, creator)
                 .addProperty(semantic.OntologyKomputasi.anotasiOleh, 
anotasiOleh);

So I try to make it dynamic by creating parameter thesisType, but when I run 
it, it doesn't want to create RDF.type property.
semantic.OntologyKomputasi is my ontology java code generated from jena 
schemagen, and semantic.OntologyKomputasi.mechanicalTurk is class in the 
ontology.


String thesisType = "semantic.OntologyKomputasi.mechanicalTurk";

That string is the *name* of your java object, it is neither the object itself nor the URI of the corresponding resource.

Resource thesis = model.createResource(thesisURI)
                 .addProperty(RDF.type, thesisType)

You just need some way (such as a hash table) to map from your input parameter (whatever that is) to either the java Resource object created by schemagen or to the URI itself.

If you want to pass URI strings around then you can use createResource again:

   String thesisTypeURI = "http//ontology/MechanicalTurk";

   Resource thesisType = model.createResource( thesisTypeURI );
   Resource thesis = model.createResource(thesisURI)
                    .addProperty(RDF.type, thesisType)


Dave

Reply via email to