Development/Tutorials/Metadata/Nepomuk/NepomukServer: Difference between revisions

From KDE TechBase
No edit summary
No edit summary
Line 9: Line 9:
==The Nepomuk Server==
==The Nepomuk Server==


The Nepomuk Server is a KDED module which hosts the main Nepomuk data repository. The main repository is an RDF database using [http://soprano.sf.net Soprano] including a [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/namespaceSoprano_1_1Index.html Soprano full text index]. The interface of the repository is exported via DBus (The DBus interface is defined by [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/soprano_server_dbus.html Soprano]). When using the Soprano DBus interface from within a KDE application there is no need to bother with QDBus. Soprano provides the [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/classSoprano_1_1Client_1_1DBusModel.html Soprano::Client::DBusModel] class which wraps all DBus communication into a nice [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/classSoprano_1_1Model.html Soprano::Model] interface.
The Nepomuk Server is a daemon which hosts all Nepomuk service including the main Nepomuk data repository. The main repository is an RDF database using [http://soprano.sf.net Soprano] including a [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/namespaceSoprano_1_1Index.html Soprano full text index]. The interface of the repository is exported via DBus (The DBus interface is defined by [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/soprano_server_dbus.html Soprano]). When using the Soprano DBus interface from within a KDE application there is no need to bother with QDBus. Soprano provides the [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/classSoprano_1_1Client_1_1DBusModel.html Soprano::Client::DBusModel] class which wraps all DBus communication into a nice [http://api.kde.org/kdesupport-api/kdesupport-apidocs/soprano/html/classSoprano_1_1Model.html Soprano::Model] interface.


There are two ways to access this wrapper model:
There are two ways to access this wrapper model:
Line 16: Line 16:


<code cppqt>
<code cppqt>
Soprano::Client::DBusClient* client = new Soprano::Client::DBusClient( "org.kde.NepomukServer" );
Soprano::Client::DBusClient* client = new Soprano::Client::DBusClient( "org.kde.NepomukStorage" );
Soprano::Model* model = client->createModel( "main" );
Soprano::Model* model = client->createModel( "main" );
</code>
</code>


The Nepomuk Server registers as DBus service ''org.kde.NepomukServer'' and the name of the main data repository is ''main''.
The Nepomuk Server registers as DBus service ''org.kde.NepomukStorage'' and the name of the main data repository is ''main''.


2. Use the Nepomuk library, i.e. [http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/core/html/classNepomuk_1_1ResourceManager.html ResourceManager] to access the main model:
2. Use the Nepomuk library, i.e. [http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/core/html/classNepomuk_1_1ResourceManager.html ResourceManager] to access the main model:
Line 28: Line 28:
</code>
</code>


The advantage of the first version is that there is no need to link to libnepomuk.
The advantage of the first version is that there is no need to link to libnepomuk. On the other hand the main model as provided by libnepomuk connects via a local socket if available which is faster. Also, it provides an automatic re-connect feature.
 
So all in all the easy way is also the recommended one: use libnepomuk and the ResourceManager to access the data.

Revision as of 19:06, 3 April 2008

Nepomuk Server
Tutorial Series   Nepomuk
Previous  
What's Next   Advanced Queries
Further Reading   Introduction to RDF and Ontologies, Handling Resources with Nepomuk

The Nepomuk Server

The Nepomuk Server is a daemon which hosts all Nepomuk service including the main Nepomuk data repository. The main repository is an RDF database using Soprano including a Soprano full text index. The interface of the repository is exported via DBus (The DBus interface is defined by Soprano). When using the Soprano DBus interface from within a KDE application there is no need to bother with QDBus. Soprano provides the Soprano::Client::DBusModel class which wraps all DBus communication into a nice Soprano::Model interface.

There are two ways to access this wrapper model:

1. Use Soprano::Client::DBusClient to create a connection to the Nepomuk Server:

Soprano::Client::DBusClient* client = new Soprano::Client::DBusClient( "org.kde.NepomukStorage" ); Soprano::Model* model = client->createModel( "main" );

The Nepomuk Server registers as DBus service org.kde.NepomukStorage and the name of the main data repository is main.

2. Use the Nepomuk library, i.e. ResourceManager to access the main model:

Soprano::Model* model = Nepomuk::ResourceManager::instance()->mainModel();

The advantage of the first version is that there is no need to link to libnepomuk. On the other hand the main model as provided by libnepomuk connects via a local socket if available which is faster. Also, it provides an automatic re-connect feature.

So all in all the easy way is also the recommended one: use libnepomuk and the ResourceManager to access the data.