简体   繁体   中英

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. Eg

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.

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.

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM