Browse files

Add example demonstrating how Jena class generation works

  • Loading branch information...
1 parent 95db123 commit 3051b18ff66f3b1323b1ec903670d28efcc6b7d9 @piscisaureus committed Jul 8, 2010
View
6,937 resources/demo/industries-application.owl
6,937 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
29 src/nl/tudelft/tbm/eeni/demo/ClassGenerator.java
@@ -0,0 +1,29 @@
+package nl.tudelft.tbm.eeni.demo;
+
+import nl.tudelft.tbm.eeni.owl2java.JenaGenerator;
+import nl.tudelft.tbm.eeni.owlstructure.processor.PropertyRangeSimplifier;
+import nl.tudelft.tbm.eeni.owlstructure.utils.OntologyUtils;
+
+import com.hp.hpl.jena.ontology.OntModel;
+
+class ClassGenerator {
+
+ public static void main(String[] args) {
+ try {
+ // Load example ontology
+ OntModel ontModel = OntologyUtils.loadOntology("file:resources/demo/industries-application.owl");
+
+ // Simplify the definition of property ranges
+ // This is necessary because owl2java chokes on complex range
+ // definitions (i.e. those containing anonymous classes)
+ (new PropertyRangeSimplifier()).process(ontModel);
+
+ // Generate classes that provide access to ontology instances
+ JenaGenerator generator = new JenaGenerator();
+ generator.generate(ontModel, "src", "nl.tudelft.tbm.eeni.demo.ont");
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
View
2 src/nl/tudelft/tbm/eeni/demo/ont/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore

0 comments on commit 3051b18

Please sign in to comment.