简体   繁体   English

从Ontology创建Java类

[英]Creating Java Classes from Ontology

I have an ontology file (in RDF) which expresses the entities in the app that I am writing. 我有一个本体文件(在RDF中),它表示我正在编写的应用程序中的实体。 I am using Jena, and can access the Concepts and create/access the resources by directly manipulating triples. 我正在使用Jena,可以通过直接操作三元组来访问Concepts并创建/访问资源。

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. 为了简化操作,我创建了一组Java类,一个用于我的本体中每种类型的资源,同时记住它们的继承和属性。 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. 如果本体包含两种类型的资源, AgentPerson ,后者是前者的子类。

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. 如果我在数据库上编写应用程序,我会使用Hibernate的配置文件,并让它处理细节。

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? 我的问题是:是否有可用的工具将本体(在RDF文件中)作为输入,并创建一组表示本体中的概念的Java文件,如上例所示? (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. 有一些工具,如BoumlAndromda ,您可以使用它们从XMI UML序列化生成Java。

Furthermore, work has been done towards integrating UML with RDF: http://infolab.stanford.edu/~melnik/rdf/uml/ . 此外,已经开展了将UML与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. 所以我猜你可以找到一种方法将RDF转换为XMI然后从XMI生成Java,假设您首先将初始RDF模式映射到RDF / UML。

Also I just found this paper: Automatic Mapping of OWL Ontologies into Java which I did not read so I cannot comment. 我还发现了这篇论文: 将OWL本体自动映射到Java中 ,我没有读过,所以我无法评论。

Protege supports RDF import and java export. Protege支持RDF导入和java导出。 I've used it in the past for getting ontology data into java programs and it's worked reasonably. 我过去曾用它来将本体数据导入java程序,并且它的工作合理。

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. 在浏览上面提供的链接时,我偶然发现了Trispresso项目 ,它提供了相关工具及其功能的精彩摘要,包括多重继承和代码生成。 Thought it would make a good answer to my own question. 认为它会对我自己的问题做出很好的回答。

Did u checked JRDF ? 你检查过JRDF吗? There are other code generation tools available too.. Check here . 还有其他代码生成工具可用..请点击此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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