Difference between revisions of "Development/Tutorials/Metadata/Nepomuk/OntologyLoaderService"

Line 3: Line 3:
name=Nepomuk Ontology Loader Service|
name=Nepomuk Ontology Loader Service|
pre=[[../StorageService|Storage Service]]|
pre=[[../StorageService|Storage Service]]|
next=[[../StrigiService|Strigi Service]]|
next=[[../FileWatchService|File Watch Service]]|
reading=[[../NepomukServices|Nepomuk Services]], [[../NepomukServer|Nepomuk Server]]|
reading=[[../NepomukServices|Nepomuk Services]], [[../NepomukServer|Nepomuk Server]]|

Revision as of 20:30, 17 November 2008

Nepomuk Ontology Loader Service
Tutorial Series   Nepomuk
Previous   Storage Service
What's Next   File Watch Service
Further Reading   Nepomuk Services, Nepomuk Server

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.

Installed ontologies

Nepomuk comes with a set of pre-installed ontologies 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 desktop 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 desktop file which contains at least the following fields:

  • Name - A name for the ontology
  • Comment - A short comment describing the ontology
  • URL - The namespace of the ontology (if possible the ontology should be available under that URL)
  • 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)
  • Type - Always needs to be set to "Data"

For examples and ideas on how to install using cmake see Nepomuk source at kdebase/runtime/nepomuk/ontologies.

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.

This page was last edited on 17 November 2008, at 20:30. Content is available under Creative Commons License SA 4.0 unless otherwise noted.