Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

doubt or suggestion

$
0
0
Hi,

I'm using schemagen in a "weird" project. The fact is that, in some point
of my algorithm, I get a String with the URI of the Resource of my
ontology.

When you are working with Jena-libs, you can do something like:

OntClass paper = base.getOntClass( NS + "Paper" );Individual p1 =
base.createIndividual( NS + "paper1", paper );

But, if you are working with schemagen plugin, you have defined the
OntClass with the resource you are looking for, but you cannot access to
the OntModel as long as this field is private so getOntClass is not allowed
in these point.

The only solution I have found has been to use reflection like that:

Field field = MyOntology.class.getDeclaredField(type); // type is a string
OntClass classType = (OntClass) field.get(null);
model.createIndividual(MyOntology.NS + id, classType);

Of course, I think is not a nice solution.

Have you another (best) solution for this usecase?

Why the model is defined as private in the generated class (or why not
there isn't its getter)?

Thanks in advance and congrats for you valuable work,
David Torres

Viewing all articles
Browse latest Browse all 5648

Trending Articles