<br><br><div class="gmail_quote">On Mon, Sep 19, 2011 at 2:42 AM, Sebastian Trüg <span dir="ltr"><<a href="mailto:trueg@kde.org" target="_blank">trueg@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On 09/18/2011 10:00 PM, Vishesh Handa wrote:<br>
><br>
> On Mon, Sep 19, 2011 at 12:52 AM, Sebastian Trüg <<a href="mailto:trueg@kde.org" target="_blank">trueg@kde.org</a><br>
</div><div><div></div><div>> <mailto:<a href="mailto:trueg@kde.org" target="_blank">trueg@kde.org</a>>> wrote:<br>
><br>
> On 09/18/2011 07:36 PM, Vishesh Handa wrote:<br>
> > Hey Sebastian<br>
> ><br>
> > I was working on my note taking application, and I want all the<br>
> > resources which are notes. So, I did this -<br>
> ><br>
> > Nepomuk::Query::ResourceTypeTerm typeTerm( Nepomuk::Types::Class(<br>
> > PIMO::Note() ) );<br>
> > Nepomuk::Query::Query query( typeTerm );<br>
> ><br>
> > which was fine. Then I realized that I wanted the notes to be sorted<br>
> > according to the last modification date.<br>
> ><br>
> > Currently, I'm doing this -<br>
> ><br>
> > Nepomuk::Query::ResourceTypeTerm typeTerm( Nepomuk::Types::Class(<br>
> > PIMO::Note() ) );<br>
> > Nepomuk::Query::Query query( typeTerm );<br>
> ><br>
> > Nepomuk::Query::Query::RequestProperty rp(<br>
> NAO::lastModified(), false );<br>
> > query.addRequestProperty( rp );<br>
> ><br>
> > QString sparql = query.toSparqlQuery() + " order by<br>
> desc(?reqProp1)";<br>
><br>
> Ahhhhhh, my eyes, I think I am blind!!!!!! :P<br>
><br>
><br>
> :D<br>
><br>
><br>
><br>
> This is what you do:<br>
><br>
> ComparisonTerm term(NAO::lastModified(), Term());<br>
> term.setSortWeight(1, Qt::DescendingOrder);<br>
> Query query = ResourceTypeTerm(PIMO::Note()) && term;<br>
><br>
><br>
> Now, why would anybody in their right mind think of using a<br>
> ComparisonTerm, when one is not comparing anything?<br>
<br>
</div></div>Yeah, ComparisionTerm started out for plain comparision but turned out<br>
into the general purpose term for anything that includes a property....<br>
maybe a new name for 5.0?<br></blockquote><div><br>Yes, please. Any ideas for a new name?<br><br>While we're on the subject of 5.0, maybe we could make the term in ComparisonTerm (const Types::Property &property, const Term &term, Comparator comparator=Contains) optional.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<div><br>
> It would be so much easier to have something like -<br>
><br>
> Query q( term );<br>
> q.addSortProperty( NAO::lastModified(), Qt::DescendingOrder ); // the<br>
> weight is optional<br>
<br>
</div>You are right for this example. But think about sorting by some variable<br>
somewhere down the graph. Artificial example:<br>
<br>
ComparisionTerm t1(NAO::lastModified(), Term());<br>
t1.setSortWeight(1);<br>
ComparisionTerm t2(PIMO::isRelated(), t1);<br>
Query q(t2);<br>
<br>
How would you express that with your API? We could of course add a<br>
shortcut/convenience method which internally creates a ComparisionTerm<br>
(actually that is what requestproperties are now)...<br></blockquote><div><br>I wasn't proposing that we remove the ComparisionTerm::setSortWeight function.<br><br>We need both. Your version of sorting using Comparison terms is very powerful. It just isn't convenient for simple use cases.<br>
<br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
<br>
Cheers,<br>
<font color="#888888">Sebastian<br>
</font><div><div></div><div><br>
> and if you want the value of the date simply add:<br>
> term.setVariableName(QLatin1String("date"));<br>
><br>
> and fetch it through Result::additionalBindings.<br>
><br>
> Actually you can read it here:<br>
> <a href="http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/html/classNepomuk_1_1Query_1_1ComparisonTerm.html#_details" target="_blank">http://api.kde.org/4.x-api/kdelibs-apidocs/nepomuk/html/classNepomuk_1_1Query_1_1ComparisonTerm.html#_details</a><br>
><br>
> Cheers,<br>
> Sebastian<br>
><br>
> > client->sparqlQuery( sparql );<br>
> ><br>
> > Is it possible that you forgot to implement sorting in the query lib?<br>
> > Cause I can't seem to find how to do it.<br>
> ><br>
> > --<br>
> > Vishesh Handa<br>
><br>
><br>
><br>
><br>
> --<br>
> Vishesh Handa<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><font color="#999999">Vishesh Handa</font><br>