Difference between revisions of "Tutorial: Ontology Development"

From Developer Documents
Jump to navigation Jump to search
m
Line 8: Line 8:
  
 
===Setup Graph Building Nature===
 
===Setup Graph Building Nature===
First, Make sure you have installed [Graph Compiler].
+
First, Make sure you have installed [[Graph Compiler]].
 
Next, add Graph builder into the project nature.  
 
Next, add Graph builder into the project nature.  
  
Line 15: Line 15:
 
[[File:graph_nature.png]]
 
[[File:graph_nature.png]]
  
Also create dictory called graphs, and there a file Movie.pgraph.
+
Also create directory called graphs, and there a file Movie.pgraph.
  
 
=== Configure MANIFEST.MF ===
 
=== Configure MANIFEST.MF ===

Revision as of 20:24, 9 October 2010

Step 1: Ontology Plug-in

Ontologies are encapsulated in OSGi bundles. In eclipse we develop them as equinox plug-ins. It contains ontology sources (graph/*.pgraph), compiled graph file (graph.tg), and Java resource files (src and bin).

Open a New Plug-in Project wizard:

  • Select File >> New >> Plug-in Development >> Plug-in Project

Our organization is Acme Software ltd and from there is our plug-in name derived, com.acme.movie.ontology. Insert that as project name. In the following page you should know that this plugin does not contribute to UI, does not need activator or isn't a rich client application.

Setup Graph Building Nature

First, Make sure you have installed Graph Compiler. Next, add Graph builder into the project nature.

  • "com.acme.movie.ontology"' >> Context Menu >> Configure >> Add graph compilation

Graph nature.png

Also create directory called graphs, and there a file Movie.pgraph.

Configure MANIFEST.MF

Your ontology well depend on Layer0, so open META-INF/MANIFEST.MF in a editor and add org.simantics.layer0 to plug-in dependencies.

Also, you are going to

  • Export package com.acme.movie.ontology

Your MANIFEST.MF should look like this.

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ontology
Bundle-SymbolicName: com.acme.movie.ontology
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: ACME
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.simantics.layer0;bundle-version="1.0.0"
Export-Package: com.acme.ontology

Developing the ontology

Open Movie.pgraph and start editing.

As you are using Layer0 concepts, it is a good idea to capture its namespace:

 L0 = <http://www.simantics.org/Layer0-1.0>

Your acme company has a namespace which is used . You are creating a new one so it must be stated.

 <http://com.acme> : L0.Library
     @L0.new

The ontology has a representing resource, an instance of L0.Ontology. Don't forget to add stub-compiler metadata L0.HasResourceClass.

 Movie = <http://com.acme/Movie-1.0> : L0.Ontology
     L0.HasResourceClass "com.acme.ontology.Movie"