Re: [Tracker] About getting ImageList from tracker



Well, thanks Ivan!

I have made it work, and below are commands that work, I want to share it so that maybe others could benefit. J

 

INSERT

tracker-sparql -u -q " INSERT { _:a a nmm:ImageList ; nie:identifier 'AlbumA' ; nie:title 'AlbumATitle' ; nfo:entryCounter 3; nfo:hasMediaFileListEntry [ a nfo:MediaFileListEntry; nfo:entryContent <urn:uuid:e9fbb886-f975-562c-6771-bfc51fb90548> ; nfo:listPosition 0 ] ; nfo:hasMediaFileListEntry [a nfo:MediaFileListEntry; nfo:entryContent <urn:uuid:fed29ebe-f29b-ff86-d36d-39df77055b6c>; nfo:listPosition 1 ] ; nfo:hasMediaFileListEntry [a nfo:MediaFileListEntry; nfo:entryContent <urn:uuid:34e88028-2110-a54a-1ecc-afa7a77f104b> ; nfo:listPosition 2 ]}"

 

DELETE

tracker-sparql -u -q " DELETE { ?photoalbum a nmm:ImageList } WHERE { ?photoalbum nie:identifier 'AlbumA'}"

 

QUERY ImageList

tracker-sparql -q "SELECT nie:identifier(?imagelist) nie:title(?imagelist) nfo:entryCounter(?imagelist) WHERE {?imagelist a nmm:ImageList}"

 

QUERY files inside ImageList

tracker-sparql -q "SELECT nie:url(nie:isStoredAs(?image)) nie:identifier(?imagelist) nie:title(?imagelist) nfo:entryCounter(?imagelist) WHERE { ?imagelist nfo:hasMediaFileListEntry ?entry . ?entry nfo:entryContent ?image { SELECT ?imagelist WHERE {?imagelist a nmm:ImageList ; nie:identifier 'AlbumA'} } }"

 

 

NOTE: you can see I use anonymous node when Insert, because there’s possible bug in tracker if I directly use <urn:uuid:image-albumA> to INSERT/DELETE/QUERY, if using that, even if I delete and then insert some thing new, the things returned by query would be very odd, kinda like mix of two different inserts.

From: Ivan Frade [mailto:ivan frade gmail com]
Sent: Tuesday, May 18, 2010 5:55 PM
To: Zheng, Huan
Cc: tracker-list gnome org
Subject: Re: [Tracker] About getting ImageList from tracker

 

Hi Huan,

On Tue, May 18, 2010 at 12:09 PM, Zheng, Huan <huan zheng intel com> wrote:

 

Insert:

tracker-sparql -u -q " INSERT { <urn:uuid:image-albumA> a nmm:ImageList ; nie:identifier 'AlbumA' ; nie:keyword 'AlbumATitle' ; nfo:entryCounter 2 ; nfo:hasMediaFileListEntry [ a nfo:MediaFileListEntry; nfo:entryContent <urn:uuid:5ea315ca-54c1-dbdf-45f5-0865a41425fa>] ; nfo:hasMediaFileListEntry [a nfo:MediaFileListEntry; nfo:entryContent <urn:uuid:a35e2d11-5451-c912-bd2f-3e8303dfd4ef>]}"

*here comes the question*, I want to get the whole list of urls from nmm:ImageList, I tried the following, but cant work

tracker-sparql -q "SELECT ?entry  WHERE { <urn:uuid:image-albumA> nfo:hasMediaFileListEntry ?entry . ?entry nfo:listPosition 1}"  *failed*

tracker-sparql -q "SELECT ?entry ?image ?position WHERE { <urn:uuid:image-albumA> nfo:hasMediaFileListEntry ?entry . ?entry nfo:entryContent ?image; nfo:listPosition ?position}"  *failed*


 This queries are failing because in the INSERT, you didn't set values to nfo:listPosition! so ?position is NULL and the query doesn't match :)

Solution 1: When you insert the mediafilelistentry set listPosition
Solution 2: Use this query instead (you get all entries but no warrantie of order):

tracker-sparql -q "SELECT ?entry ?image WHERE { <urn:uuid:image-albumA> nfo:hasMediaFileListEntry ?entry . ?entry nfo:entryContent ?image. }"
 

Regards,

Ivan



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]