Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating Java Classes from Ontology

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.

like image 851
Animesh Avatar asked Aug 04 '10 14:08

Animesh


3 Answers

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.

like image 65
amynbe Avatar answered Nov 04 '22 04:11

amynbe


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.

like image 1
Paul Rubel Avatar answered Nov 04 '22 05:11

Paul Rubel


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.

like image 1
Animesh Avatar answered Nov 04 '22 04:11

Animesh