RDF4J Class Builder

Java class generator from OWL ontologies

License

License

GroupId

GroupId

io.github.radkovo
ArtifactId

ArtifactId

class-builder
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

pom
Description

Description

RDF4J Class Builder
Java class generator from OWL ontologies
Project URL

Project URL

https://github.com/radkovo/rdf4j-class-builder
Source Code Management

Source Code Management

https://github.com/radkovo/rdf4j-class-builder.git

Download class-builder

Filename Size
class-builder-1.0.pom 6 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.radkovo/class-builder/ -->
<dependency>
    <groupId>io.github.radkovo</groupId>
    <artifactId>class-builder</artifactId>
    <version>1.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/io.github.radkovo/class-builder/
implementation 'io.github.radkovo:class-builder:1.0'
// https://jarcasting.com/artifacts/io.github.radkovo/class-builder/
implementation ("io.github.radkovo:class-builder:1.0")
'io.github.radkovo:class-builder:pom:1.0'
<dependency org="io.github.radkovo" name="class-builder" rev="1.0">
  <artifact name="class-builder" type="pom" />
</dependency>
@Grapes(
@Grab(group='io.github.radkovo', module='class-builder', version='1.0')
)
libraryDependencies += "io.github.radkovo" % "class-builder" % "1.0"
[io.github.radkovo/class-builder "1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.25
ch.qos.logback : logback-classic jar 1.1.2

test (1)

Group / Artifact Type Version
junit : junit jar 3.8.1

Project Modules

  • class-builder-core
  • class-builder-runtime
  • class-builder-cli

RDF4J Class Builder

(c) 2017-2019 Radek Burget ([email protected])

RDF4J Class Builder is a tool for generating Java classes from OWL ontology definitions. For every class defined in the OWL file, it generates a Java class definition, that contains

  • Property definitions, getters and setters for every OWL property that has the given class in owl:domain. The property cardinality is distinguished using the owl:Property, owl:FunctionalProperty and owl:InverseFunctionalProperty definitions.
  • The addToModel() and loadFromModel() methods that allow loading and storing the class instatnces from and to a RDF graph represented by the RDF4J Model class.

Additionaly, a factory interface is generated for the whole ontology that allows implementing custom factories for creating the object instances.

The project is inspired by and integrates with the the RDF4J Vocabulary Builder project.

Installation

RDF4J Class Builder is distributed as platform-independent runnable jar archive:

  • Download the runnable archive ClassBuilder.jar from Releases
  • Run the following command in the command prompt (depending on your operating system):
    java -jar ClassBuilder.jar

You should see a list of available parametres.

Usage

RDF4J Class Builder takes an OWL definition file in any format (RDF/XML, Turtle, ...) as the input. It generates two separate components:

  • A single vocabulary class (using the built-in RDF4J Vocabulary Builder). The vocabulary class defines the URI constants for all the classes and predicates defined in the OWL source.
  • Individual java class definitions (as described above) for all the classes defined in the OWL source.

For both the vocabulary and the class definitions, their java package and the target folder may be specified via the command line as follows:

ClassBuilder [options...] <input-file>
  <input-file>                  the input file to read from
  -f,--format <format>          mime-type of the input file (will try to guess
                                if absent)
  -v,--vocab-name <class-name>  vocabulary class name
  -o,--vocab-dir <path>         the output directory for the vocabulary (current
                                directory when absent)
  -O,--class-dir <path>         the output directory for the classes (vocabulary
                                directory when absent)
  -p,--vocab-package <package>  vocabulary package declaration (will use default
                                (empty) package if absent)
  -P,--class-package <package>  class package declaration (will use the
                                vocabulary package if absent)

Example usage:

java -jar ClassBuilder.jar \
	info.owl \
	-v INFO \
	-o src/com/example/vocabulary \
	-p com.example.vocabulary \
	-O src/com/example/ontology \
	-P com.example.ontology \

Building

RDF4J Class Builder may be build from the sources by maven. After cloning the source repository, use mvn package for building and packaging all the components.

Acknowledgements

This work was supported by the Ministry of the Interior of the Czech Republic as a part of the project Integrated platform for analysis of digital data from security incidents VI20172020062.

Versions

Version
1.0