Development/Tutorials/Metadata/Nepomuk/OntologyLoaderService: Difference between revisions
No edit summary |
Neverendingo (talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
||
(One intermediate revision by the same user not shown) | |||
Line 37: | Line 37: | ||
For this task the service provides a DBus interface named ''org.kde.nepomuk.OntologyManager'' which is exported at ''nepomukontologyloader'': | For this task the service provides a DBus interface named ''org.kde.nepomuk.OntologyManager'' which is exported at ''nepomukontologyloader'': | ||
< | <syntaxhighlight lang="text">QString findOntologyContext(QString uri)</syntaxhighlight> | ||
Searches for the ontology with the provided namespace. If found the context (named graph) the ontology is stored in is returned. | Searches for the ontology with the provided namespace. If found the context (named graph) the ontology is stored in is returned. | ||
< | <syntaxhighlight lang="text">void importOntology(QString url)</syntaxhighlight> | ||
Import an ontology from the provided URL. All URLs suported by KIO can be used. | Import an ontology from the provided URL. All URLs suported by KIO can be used. | ||
This is an async method that will report its success through the following signals. | This is an async method that will report its success through the following signals. | ||
< | <syntaxhighlight lang="text">void ontologyUpdateFailed(QString uri, QString errorString)</syntaxhighlight> | ||
Emitted if updating en ontology failed. | Emitted if updating en ontology failed. | ||
< | <syntaxhighlight lang="text">void ontologyUpdated(QString uri)</syntaxhighlight> | ||
Emitted if updating an ontology was successful. | Emitted if updating an ontology was successful. | ||
< | <syntaxhighlight lang="text">void updateAllLocalOntologies()</syntaxhighlight> | ||
Forces the service to update all installed ontologies, even if they did not change. | Forces the service to update all installed ontologies, even if they did not change. | ||
< | <syntaxhighlight lang="text">void updateLocalOntologies()</syntaxhighlight> | ||
Make the service update all installed ontologies that have changed. Normally there is no need to call this method as the service monitors all installed ontologies. | Make the service update all installed ontologies that have changed. Normally there is no need to call this method as the service monitors all installed ontologies. |
Latest revision as of 20:53, 29 June 2011
Tutorial Series | Nepomuk |
Previous | Storage Service |
What's Next | File Watch Service |
Further Reading | Nepomuk Services, Nepomuk Server,Data Layout in Nepomuk |
Nepomuk Ontology Loader Service
The ontology loader service maintains the ontologies in Nepomuk and allows to fetch ontologies from the internet. Normally applications should work with ontologies through the Nepomuk::Types API provided by libnepomuk which is part of the kdelibs.
See the Nepomuk Data Layout for details on how ontologies are stored in Nepomuk.
Installed ontologies
Nepomuk uses a set of pre-installed ontologies from the shared-desktop-ontologies project which are automatically read into the storage by this service.
The ontologies are stored in KDEDIR/share/apps/nepomuk/ontologies. Each ontology consists of two files: the ontology itself (in most cases a trig file) and a .ontology file describing the ontology. The latter is read by the service and used to find the ontology file which is then parsed, validated and updated in the Nepomuk Storage.
Installing new ontologies (in case an application needs them) is rather simple: write a .ontology file which contains at least the following fields:
- Name - A name for the ontology
- Comment - A short comment describing the ontology
- Namespace - The namespace of the ontology
- Path - The path to the ontology file (which will be parsed by the service)
- MimeType - The mimetype used to encode the RDF data in the file (for example "application/x-trig" for trig data or "application/rdf+xml" for RDF+XML data)
For examples and ideas on how to install using cmake see the shared-desktop-ontology sources.
Further Ontologies
The Ontology service also allows to fetch new ontologies from the internet. The advantage of using the service in comparison to simply downloading and parsing is that the service performs some checks, makes sure the data is compatible with the Nepomuk system, and performs updates rather than just storing it in addition to old versions.
For this task the service provides a DBus interface named org.kde.nepomuk.OntologyManager which is exported at nepomukontologyloader:
QString findOntologyContext(QString uri)
Searches for the ontology with the provided namespace. If found the context (named graph) the ontology is stored in is returned.
void importOntology(QString url)
Import an ontology from the provided URL. All URLs suported by KIO can be used. This is an async method that will report its success through the following signals.
void ontologyUpdateFailed(QString uri, QString errorString)
Emitted if updating en ontology failed.
void ontologyUpdated(QString uri)
Emitted if updating an ontology was successful.
void updateAllLocalOntologies()
Forces the service to update all installed ontologies, even if they did not change.
void updateLocalOntologies()
Make the service update all installed ontologies that have changed. Normally there is no need to call this method as the service monitors all installed ontologies.