< Projects‎ | Nepomuk
Revision as of 15:48, 23 August 2012 by Vhanda (talk | contribs) (Moved from techbase)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Nepomuk: Metadata Writeback

This page is intended to gather ideas about the GSOC 2011 project Metadata Writeback by Smit Shah.


Resource Watcher

This project relies heavily on one of the parts of Nepomuk called "Resource Watcher" , using it we could monitor the already indexed resources for any changes, this includes addition or removal of any property to be exact and perhaps change in the property in the future, this is a very important part of the project as once we find which resource has been modified using emitted signals and then we can call the method which would writeback the metadata to the resource if there is plugin for that rdf:type/mimetype.

To Connect the resource watcher should be fairly simple as shown below :

ResourceWatcher* resourcewatcher;

        resourcewatcher  = new ResourceWatcher(this);

        connect( resourcewatcher, SIGNAL( propertyAdded(Nepomuk::Resource,                     Nepomuk::Types::Property, QVariant) ),this, SLOT ( write(Nepomuk::Resource) ) );
        connect( resourcewatcher, SIGNAL( propertyRemoved(Nepomuk::Resource,
Nepomuk::Types::Property, QVariant) ),this, SLOT ( write(Nepomuk::Resource) ) );

This how it will be in the future but as of now Resource Watcher has some problems so for now we would be monitoring only a handful of properties like NIE:title or NCO:nickname.

Hybrid Plugin System

This project as of now relies on mimetypes of plugin selection but that limits functionality of the project as it can not writeback metadata except for files (e.g. Akonadi), so it would a good approach to select plugins based on rdf:types as retaining the selection using mimetypes as well.

The current selection of plugin based on mimetype is shown below:

 const QStringList mimetypes = resource.property(NIE::mimeType()).toStringList();
            QString  mimetype = mimetypes.first();
            WritebackPlugin* plugin= KMimeTypeTrader::createInstanceFromQuery<WritebackPlugin>(mimetype,"Nepomuk/WritebackPlugin",this);

            if (plugin)

This is how the selection of done as of now but in future we would be using both rdf:types and mimetypes as well.


To do the writeback job itself we would be relying on kjob to write a class that does the work, it later deletes the plugin after the job finishes and if the plugin does not write the data successfully it will use the next plugin the in the list.

The code looks something like below,

 class WritebackJob : public KJob {
    WritebackJob(const QList<Plugin*>& plugins, QObject* parent) {
        m_plugins = plugins;
    ~WritebackJob() {
    void start() {
    void tryNextPlugin() {
        Plugin* p = m_plugin.takeFirst();
        // start the plugin and so on
    void slotWritebackFinished(Plugin* plugin) {
        if(plugin->success()) {
        else if(!m_plugins.isEmpty()) {

This page was last edited on 23 August 2012, at 15:48. Content is available under Creative Commons License SA 4.0 unless otherwise noted.