Creating Java Classes from Ontology
Asked Answered
T

4

10

I have an ontology file (in RDF) which expresses the entities in the app that I am writing. I am using Jena, and can access the Concepts and create/access the resources by directly manipulating triples.

To make things easier, I created a set of Java classes, one for each type of resource in my ontology, keeping in mind their inheritances, and properties. E.g.

public class Agent{
}

and

public class Person extends Agent{
  private String name;
}

If the ontology contains two types of resources, Agent and Person, with the latter being a subclass of the former.

I realized that the process of creating these classes (and the methods to extract them) are very monotonous. If I was writing an application on databases, I would have used a config file for Hibernate and let it take care of the details.

My question is: Is there a tool available that will take an ontology (in an RDF file) as input, and create a set of Java files representing the Concepts in the ontology, as in the example above? (or if Jena itself can do this, and I am missing something)

Thanks.

Tarantella answered 4/8, 2010 at 14:40 Comment(1)
I think they have to be interfaces because an instance can have the types FlyingThing, Animal, Black, etc. Problem with that is it wouldn't be able to deal with inherited property values.Reservist
T
1

While going through the links provided above, I chanced upon the Trispresso Project, which provides a nice summary of the relevant tools and their features, including multiple inheritance and code generation. Thought it would make a good answer to my own question.

Tarantella answered 6/8, 2010 at 8:0 Comment(0)
A
2

There are tools such as Bouml and Andromda with which you may generate Java from XMI UML serialization.

Furthermore, work has been done towards integrating UML with RDF: http://infolab.stanford.edu/~melnik/rdf/uml/.

So I guess you could find a way to transform your RDF to XMI then to generate Java from XMI, given you first map your initial RDF schema to RDF/UML.

Also I just found this paper: Automatic Mapping of OWL Ontologies into Java which I did not read so I cannot comment.

Abecedary answered 10/8, 2010 at 10:31 Comment(0)
C
1

Protege supports RDF import and java export. I've used it in the past for getting ontology data into java programs and it's worked reasonably.

Ceolaceorl answered 4/8, 2010 at 15:7 Comment(1)
Thanks. I assume you mean using the BeanGenerator plugin at sharon.cselt.it/projects/jade/doc/tutorials/beangenerator/… . I will try it.Tarantella
T
1

While going through the links provided above, I chanced upon the Trispresso Project, which provides a nice summary of the relevant tools and their features, including multiple inheritance and code generation. Thought it would make a good answer to my own question.

Tarantella answered 6/8, 2010 at 8:0 Comment(0)
P
0

Did u checked JRDF? There are other code generation tools available too.. Check here.

Pyrology answered 4/8, 2010 at 14:56 Comment(1)
Thanks. From the JRDF page "Future features may include: An RDF to Java object API (similar to Hibernate or Sesame's Elmo)," So I think this is not yet supported. Will check out RDFReactor, Kazuki, and Owl2Java from the other page.Tarantella

© 2022 - 2024 — McMap. All rights reserved.