Hi everybody,

I have merged commits of Brian and added some other metadata. Here is my
repo:
http://git.gitorious.org/~pakdel/basket/pakdels-basket.git

The last prombems were:

   1.

   I havd to update Krunner Nepomuk plugin to the last version
   2.

   There is a *22rdfsyntaxnsmetadata* function in *rdf* which I had to
   comment out

I have attached latest version of *src/nepomukintegration.h* and *
src/nepomukintegration.cpp* and I would be greateful if you could take look
and inform me of any error, bug or requred features.

Here is the updated and reformatted testing procedure:

   -

   Find the corresponding file of a basket; for example
   /home/amir/.kde/share/apps/basket/baskets/basket106/.basket in my case
   -

   Get the metadata that is already stored in the Nepomuk (perhaps by
   Strigi)
   -

   start nepomukserver if it is not

$ nepomukserver 2> /tmp/nepomuk.stderr

   -

   I use the following alias:

$ alias nepomukcmd="sopranocmd --socket `kde4-config
--localprefix`/share/apps/nepomuk/socket --model main –nrl --foo"

   -

      Query and find the Nepomuk for ResourceID:

$ RES=$(nepomukcmd query "select ?r where { ?r nie:url
<file:///home/amir/.kde/share/apps/basket/baskets/basket106/.basket> . }")

$ echo $RES

   -

      Get everything about the ResourceID

$ nepomukcmd query "select ?a ?b where { $RES ?a ?b . }"

$ nepomukcmd query "select ?a ?b where { $RES nao:hasTag ?t . ?t ?a ?b . }"

   -

   Compile and execute the Basket Note Pads with debug option

$ basket --debug

   -

   Select the basket corresponding to the selected file and click on a note
   to enter the edit mode
   -

   Exit the edit mode. Even without any changes, save function would be
   called
   -

   There should be some debug info in the debug window like the following:

Basket Tree: Saving...

Basket[basket106/]: Saving...

NepomukIntegration: Basket[basket106/]:

initialized

properties :

http://www.semanticdesktop.org/ontologies/2007/08/15/nao#lastModified/lastmodified
at/lastModified: 2010-09-14T16:30:13.797Z

http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileName/fileName/fileName:
.basket

http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#fileUrl/fileUrl/fileUrl:
file:///home/amir/.kde/share/apps/basket/baskets/basket106/.basket

http://purl.org/dc/elements/1.1/title/Title/title: Basket Note Pads
development

http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType/mimeType/mimeType:
application/x-basket-item

http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url/url/url:
file:///home/amir/.kde/share/apps/basket/baskets/basket106/.basket

http://www.semanticdesktop.org/ontologies/2007/08/15/nao#prefLabel/preferred
label/prefLabel<http://www.semanticdesktop.org/ontologies/2007/08/15/nao#prefLabel/preferredlabel/prefLabel>:
Basket Note Pads development

http://www.semanticdesktop.org/ontologies/2007/08/15/nao#hasTag/has
tag/hasTag<http://www.semanticdesktop.org/ontologies/2007/08/15/nao#hasTag/hastag/hasTag>:
nepomuk:/res/996dbc0f-7042-4063-9dd2-9271c651fc1e,nepomuk:/res/3c649e0f-2903-4c73-adde-ad6399e5d54e,nepomuk:/res/8c7196be-c7e3-4bc6-b584-7e87a2331bce,nepomuk:/res/ea02648f-527e-4b55-b477-9d18ff18e805


http://www.semanticdesktop.org/ontologies/2007/08/15/nao#created/created
at/created<http://www.semanticdesktop.org/ontologies/2007/08/15/nao#created/createdat/created>:
2010-09-14T07:18:31.135Z

a/a/a: http://www.semanticdesktop.org/ontologies/2007/11/01/pimo#Note

   -

   Get the metadata of the file once again and compare
   -

   Search for the indexed basket using Krunner
   -

   Label of my basket is "Basket Note Pads development" and I had to quote
   that when searching!
   -

   I could not find tags like “idea” or “information”!
   -

   Clicking on the itme found DOES open the basket in the Basket Note Pads
   application (Hoorray!)


Trüg, do you know why I cannot find tags?
Laura, what metadata do you suggest to add next?

Thanks,
Amir

On Sun, Sep 12, 2010 at 9:02 PM, Amir Pakdel <pak...@gmail.com> wrote:

> Hi Brian,
>
> Thanks, I will merge your code into my git repo as soon as possible.
>
> I had difficulties in using "soprano_add_ontology" in CMake and it took me
> a long time to figure out the problem.
> Until now, I have just added a nepomukintegration::updateMetadata function
> which can add metadata of a basket to the metadata of .basket file in the
> Nepomuk.
> Here is the git repo (57f7f50):
> http://git.gitorious.org/~pakdel/basket/pakdels-basket.git<http://git.gitorious.org/%7Epakdel/basket/pakdels-basket.git>
>
> Here is how I am testing the result of the code so far:
>
>    - Find the corresponding file of a basket; for example
>    /home/amir/.kde/share/apps/basket/baskets/basket106/.basket in my case
>    - Get the metadata that is already stored in the Nepomuk (perhaps by
>    Strigi)
>       - start nepomukserver if it is not
>
> $ nepomukserver 2> /tmp/nepomuk.stderr
>
>    - I use the following alias
>
> $ alias nepomukcmd="sopranocmd --socket `kde4-config
> --localprefix`/share/apps/nepomuk/socket --model main --nrl"
>
>    - Query the Nepomuk for ResourceID
>
> $ nepomukcmd query "select ?r where { ?r nie:url
> <file:///home/amir/.kde/share/apps/basket/baskets/basket106/.basket> . }"
> r -> <nepomuk:/res/7e1e98ce-6b7f-4d4b-8cbd-1e312596e8ee>
>
>    - Get everything about the ResourceID
>
> $ nepomukcmd query "select ?a ?b where {
> <nepomuk:/res/7e1e98ce-6b7f-4d4b-8cbd-1e312596e8ee> ?a ?b . }"
>
>    - Compile and execute the Basket Note Pads with debug option
>
> $ basket --debug
> - Select the basket corresponding to the selected file and click on a note
> to enter the edit mode
> - Exit the edit mode. Even without any changes, save function would be
> called
> - There should be some debug info in the debug window like the following:
> NepomukIntegration: Basket[basket106/]:
> initialized
> properties :
> http://www.semanticdesktop.org/ontologies/2007/08/15/nao#lastModified/lastmodified
>  at/lastModified: 2010-09-12T15:38:53.565Z
>
> http://www.semanticdesktop.org/ontologies/2007/01/19/nie#mimeType/mimeType/mimeType:
> application/x-basket-item
> http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url/url/url:
> /home/amir/.kde/share/apps/basket/baskets/basket106/.basket
> http://www.semanticdesktop.org/ontologies/2007/08/15/nao#created/createdat/created:
>  2010-09-12T15:38:52.924Z
> - Get the metadata of the file once again and compare
>
>
> Thanks,
> Amir
>
>
> On Sun, Sep 12, 2010 at 12:41 AM, Brian Milco <bcmi...@gmail.com> wrote:
> > Hi Amir,
> >
> > Sorry for the delay, it's been a busy week.
> >
> > I've pushed some code that should take care of loading the baskets for
> you
> > (b14d990):
> > http://gitorious.org/~bcmilco/basket/bcmilco-basket/commits/nepomuk<http://gitorious.org/%7Ebcmilco/basket/bcmilco-basket/commits/nepomuk>
> >
> > Also do you have a public branch with your code that I could look at? I'd
> > love to help test/debug/code whatever you need.
> >
> > Thanks,
> > -Brian
> >
>
>
#include "nepomukintegration.h"

#include <QUrl>
#include <QDomNode>
#include <QDomDocument>
#include <QDomElement>
#include <KDE/KDebug>


#include "global.h"
#include "debugwindow.h"

#include <Nepomuk/ResourceManager>
#include <Nepomuk/Variant>
#include <Nepomuk/Types/Class>
/* #include <Nepomuk/File> */
#include <Nepomuk/Tag>
#include <Soprano/Vocabulary/NAO>
#include <Soprano/Vocabulary/RDFS>
#include "rdf.h"
#include "dc.h"
#include "nie.h"
#include "nfo.h"
#include "pimo.h"


bool nepomukintegration::updateMetadata(const QString &fullPath, const QDomDocument &document) {

    if ( Nepomuk::ResourceManager::instance()->initialized() || Nepomuk::ResourceManager::instance()->init() ) {
        DEBUG_WIN << "\tinitialized";
        QUrl basketUri = QUrl::fromLocalFile( fullPath );
        /* Nepomuk::File basketRes(basketUri); */
        Nepomuk::Resource basketRes(basketUri);
        basketRes.setProperty( "a", Soprano::Vocabulary::PIMO::Note() );
        /* basketRes.addType( Soprano::Vocabulary::PIMO::Note() );
        basketRes.addType( Soprano::Vocabulary::NFO::FileDataObject() ); */
        basketRes.setProperty( Soprano::Vocabulary::RDF::type(), Soprano::Vocabulary::PIMO::Note() );
        basketRes.setProperty( Soprano::Vocabulary::NIE::mimeType(), "application/x-basket-item" );
        basketRes.setProperty( Soprano::Vocabulary::NIE::url(), basketUri );
        basketRes.setProperty( Soprano::Vocabulary::NFO::fileUrl(), basketUri );
        basketRes.setProperty( Soprano::Vocabulary::NFO::fileName(), ".basket" );
        QString basketName = document.elementsByTagName("name").item(0).firstChild().nodeValue();
        basketRes.setProperty( Soprano::Vocabulary::DC::title(), basketName);
        basketRes.setProperty( Soprano::Vocabulary::NAO::prefLabel(), basketName);
        QDomNode n;
        Nepomuk::Tag basketTag;

        QDomNodeList tagList = document.elementsByTagName("tags");
        for (int i = 0; i < tagList.count(); i++) {
            foreach(QString t, tagList.item(i).firstChild().nodeValue().split(';') ) {
                basketTag = Nepomuk::Tag( t );
                basketTag.setProperty( Soprano::Vocabulary::NAO::prefLabel(), t );
                basketRes.addTag( basketTag );
            }
        }

        QHash<QUrl, Nepomuk::Variant> basketProperties = basketRes.properties();
        DEBUG_WIN << "\tproperties : ";
        for( QHash<QUrl, Nepomuk::Variant>::const_iterator it = basketProperties.constBegin();
        it != basketProperties.constEnd(); ++it ) {
            QUrl propertyUri = it.key();
            Nepomuk::Variant value = it.value();
            Nepomuk::Types::Class propertyType( propertyUri );
            DEBUG_WIN << "\t" + propertyType.uri().toString() + "/"
                    + propertyType.label() + "/" + propertyType.name() + ": " + value.toString();
        }

        //basketRes.remove();
    } else {
        DEBUG_WIN << "\tinitialization failed!";
        return false;
    }
    return true;

}
#ifndef NEPOMUKINTEGRATION_H
#define NEPOMUKINTEGRATION_H

#include <QString>
#include <QDomDocument>

class nepomukintegration
{
public:
    nepomukintegration(){};
    static bool updateMetadata(const QString &fullPath, const QDomDocument &document);
};

#endif // NEPOMUKINTEGRATION_H
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Basket-devel mailing list
Basket-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/basket-devel

Reply via email to