Difference between revisions of "Tutorial: Ontology Development"
m |
m |
||
Line 2: | Line 2: | ||
''"What's up folks."'' Today we are going to create a movie ontology for a client of your Acme company. | ''"What's up folks."'' Today we are going to create a movie ontology for a client of your Acme company. | ||
− | == Step 1: Ontology Plug-in == | + | == Step 1: Setup Ontology Plug-in == |
Ontologies are encapsulated in OSGi bundles. In eclipse we develop them as equinox plug-ins. An ontology bundle is a package that contains the sources (graph/*.pgraph), a compiled graph file (graph.tg), and Java resource files (src/ and bin/). | Ontologies are encapsulated in OSGi bundles. In eclipse we develop them as equinox plug-ins. An ontology bundle is a package that contains the sources (graph/*.pgraph), a compiled graph file (graph.tg), and Java resource files (src/ and bin/). | ||
Line 13: | Line 13: | ||
# Our organization is Acme Software ltd and from there is our plug-in name derived, ''com.acme.movie.ontology''. Insert that as project name. '''Next >''' | # Our organization is Acme Software ltd and from there is our plug-in name derived, ''com.acme.movie.ontology''. Insert that as project name. '''Next >''' | ||
# 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. '''Next >''' | # 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. '''Next >''' | ||
− | # | + | # Use template ''Plug-in with a Simantics Ontology''. '''Next >''' |
+ | # Your company domain is ''com.acme.movie'' and ontology name ''Movie'', and the inital version is 1.0. '''Finish''' | ||
− | + | You have now a new project in Package Explorer. If you open the project you will find META-INF/MANIFEST.MF, graph/Movie.pgraph, and graph.tg. | |
− | |||
− | |||
− | + | == Step 2: Edit 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" | ||
− | + | == Step 3: Export package == | |
− | * | + | Now that you have some content, graph compiler has created a Resource class. You will find it under ''src/'' folder. When developing Java-code you can gain access to your ontology concepts using this class. In equinox plugin environment, the access to other plugins' classes is denied by default. You must export its package to share the access. Do this my opening ''META-INF/MANIFEST.MF'' file, a form sheet opens. |
+ | * '' Select '''META-INF/MANIFEST.MF''' >> '''Exported Packages / Add''' >> '''com.acme.ontology''' | ||
Your MANIFEST.MF should look like this. | Your MANIFEST.MF should look like this. | ||
Line 43: | Line 48: | ||
Export-Package: com.acme.ontology | Export-Package: com.acme.ontology | ||
</pre> | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 09:40, 14 October 2010
"What's up folks." Today we are going to create a movie ontology for a client of your Acme company.
Step 1: Setup Ontology Plug-in
Ontologies are encapsulated in OSGi bundles. In eclipse we develop them as equinox plug-ins. An ontology bundle is a package that contains the sources (graph/*.pgraph), a compiled graph file (graph.tg), and Java resource files (src/ and bin/).
Open a New Plug-in Project wizard:
- Open Plug-in Development Perspective
- Select File >> New >> Other
- Select Plug-in Development >> Plug-in Project
A New Plug-in Project wizard will open.
- Our organization is Acme Software ltd and from there is our plug-in name derived, com.acme.movie.ontology. Insert that as project name. Next >
- 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. Next >
- Use template Plug-in with a Simantics Ontology. Next >
- Your company domain is com.acme.movie and ontology name Movie, and the inital version is 1.0. Finish
You have now a new project in Package Explorer. If you open the project you will find META-INF/MANIFEST.MF, graph/Movie.pgraph, and graph.tg.
Step 2: Edit 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"
Step 3: Export package
Now that you have some content, graph compiler has created a Resource class. You will find it under src/ folder. When developing Java-code you can gain access to your ontology concepts using this class. In equinox plugin environment, the access to other plugins' classes is denied by default. You must export its package to share the access. Do this my opening META-INF/MANIFEST.MF file, a form sheet opens.
- Select META-INF/MANIFEST.MF >> Exported Packages / Add >> com.acme.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