Generate code from OWL

2 views
Skip to first unread message

Sabino Pariente Juarez

unread,
Mar 31, 2015, 7:15:47 PM3/31/15
to sta...@clarkparsia.com
Dear all,

I'm working with an ontology that contains a large number of classes  and properties and I want to develop a CRUD system using Stardog-Spring.
Nevertheless, it necessary to have Beans (java classes), which represent the OWL classes, which will persist data from a html form to a Stardog database like happens in a relational database.
Do it is very hard, So my question is whether in Stardog, there are any way to generate java code (or Beans) from an OWL file to handle persistence as does JPA (Java Persistence API)


regards

Conrad Leonard

unread,
Mar 31, 2015, 11:53:10 PM3/31/15
to sta...@clarkparsia.com
Mike's Empire RDF for JPA library has a bean generator that may be a good starting point for you:


The project comes with bindings for Stardog too.

Sabino Pariente Juarez

unread,
Apr 1, 2015, 1:25:32 PM4/1/15
to sta...@clarkparsia.com
Dear Conrad

Thank you for reply, It's a good solution, nevertheless I get an error with the pom.xml when load the Empire project on Netbeans and Eclipse IDE. 

Error is "The project com.clarkparsia.empire:examples:0.8.4 (/home/sabino/Descargas/Empire-master/examples/pom.xml) has 1 error
    Non-resolvable parent POM: Could not find artifact com.complexible.empire:Empire-parent:pom:0.8.4 in central (http://repo.maven.apache.org/maven2) and 'parent.relativePath' points at wrong local POM @ line 9, column 10 -> [Help 2]"

Lines in pom.xml are 
      <parent>
<groupId>com.clarkparsia.empire</groupId>
<artifactId>Empire-parent</artifactId>
<version>0.8.4</version>
</parent>

I searched the Maven's central repository, however, I can't found the Empire project.
attached the images from searches on The central repository





best regards

Sabino Pariente

MC. Sabino Pariente Juárez
Cel: 7771347513


--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.

Fernando Hernandez

unread,
Apr 1, 2015, 2:38:56 PM4/1/15
to sta...@clarkparsia.com
Hi Sabino,

On Wed, Apr 1, 2015 at 1:25 PM, Sabino Pariente Juarez <pjsa...@gmail.com> wrote:
Dear Conrad

Thank you for reply, It's a good solution, nevertheless I get an error with the pom.xml when load the Empire project on Netbeans and Eclipse IDE. 

 You should use the gradle project for building Empire. We don't use Netbeans internally but I believe there is a gradle plugin for it as well.

If you just want to install Empire in your system in order to use it in another project you can just run

./gradlew install

and it will install Empire in your local maven repository (in ~./m2/repository/com/clarkparsia/empire). Then you can import it as follows (if you're using maven):

    <dependency>
      <groupId>com.clarkparsia.empire</groupId>
      <artifactId>stardog</artifactId>
      <version>0.9.0</version>
      <scope>compile</scope>
    </dependency>


Cheers,
Fernando

Sabino Pariente Juarez

unread,
Apr 6, 2015, 10:38:08 AM4/6/15
to sta...@clarkparsia.com
Hi Fernando 


Thaks for the recomendation, nevertheless, I got errors when execute the ./gradlew install command.
I attach a text file with the exceptions thows by ./gradlew install 


regards

MC. Sabino Pariente Juárez
Cel: 7771347513


--
errors

Michael Grove

unread,
Apr 6, 2015, 10:46:13 AM4/6/15
to stardog
Empire requires a Java 6 compiler.

Cheers,

Mike

Sabino Pariente Juarez

unread,
Apr 6, 2015, 4:51:00 PM4/6/15
to sta...@clarkparsia.com
Thanks Mike 

I can compile the Empire successfully and I have imported the dependency from a Maven project.
However, When I execute an example to generate java code with class BeanGenerator, I got a Exception

The code is the next:

        String packageName = "beans";
        String ontologyURL = "/home/sabino/owl/ontology.owl";
        String rdfFormat = "rdf/xml";
        String outputDirectory = "src/main/java";
        URL aURL;
        if (NetUtils.isURL(ontologyURL)) {
            aURL = new URL(ontologyURL);
        } else {
            aURL = new File(ontologyURL).toURI().toURL();
        }
        //BeanGenerator bg = new BeanGenerator();
        BeanGenerator.generateSourceFiles(packageName, aURL, RDFFormat.valueOf(rdfFormat), new File(outputDirectory));

The exception thorwn is

Exception in thread "main" java.lang.NoSuchMethodError: com.complexible.common.openrdf.repository.Repositories.createInMemoryRepo()Lorg/openrdf/repository/Repository;
at com.clarkparsia.empire.codegen.BeanGenerator.generateSourceFiles(BeanGenerator.java:441)
at CodeGeneratorBeans.main(CodeGeneratorBeans.java:46)

Somebody know how to fix this exception?

Regards

MC. Sabino Pariente Juárez
Cel: 7771347513


Michael Grove

unread,
Apr 7, 2015, 2:20:02 PM4/7/15
to stardog
On Mon, Apr 6, 2015 at 4:50 PM, Sabino Pariente Juarez <pjsa...@gmail.com> wrote:
Thanks Mike 

I can compile the Empire successfully and I have imported the dependency from a Maven project.
However, When I execute an example to generate java code with class BeanGenerator, I got a Exception

The code is the next:

        String packageName = "beans";
        String ontologyURL = "/home/sabino/owl/ontology.owl";
        String rdfFormat = "rdf/xml";
        String outputDirectory = "src/main/java";
        URL aURL;
        if (NetUtils.isURL(ontologyURL)) {
            aURL = new URL(ontologyURL);
        } else {
            aURL = new File(ontologyURL).toURI().toURL();
        }
        //BeanGenerator bg = new BeanGenerator();
        BeanGenerator.generateSourceFiles(packageName, aURL, RDFFormat.valueOf(rdfFormat), new File(outputDirectory));

The exception thorwn is

Exception in thread "main" java.lang.NoSuchMethodError: com.complexible.common.openrdf.repository.Repositories.createInMemoryRepo()Lorg/openrdf/repository/Repository;
at com.clarkparsia.empire.codegen.BeanGenerator.generateSourceFiles(BeanGenerator.java:441)
at CodeGeneratorBeans.main(CodeGeneratorBeans.java:46)


Looks like you have some sort of mixup in your class path.  L441 in the current codebase is a blank line.

Cheers,

Mike
Reply all
Reply to author
Forward
0 new messages