[Kde-pim] nepomuk + sentDate()

laurent Montel montel at kde.org
Fri Nov 2 09:21:36 GMT 2012


Hi,

Le vendredi 2 novembre 2012 08:00:10 Vishesh Handa a écrit :
> Hey Laurent
> 
> I just saw this email while browsing some stuff. I seem to have missed it.
> Please feel free to remind me if I do not respond in a couple of days. I
> tend to put stuff for later and then forget about it. Sorry.



> 
> On Fri, Mar 9, 2012 at 2:50 PM, laurent Montel <montel at kde.org> wrote:
> 
> > Hi,
> > I saw in kdepim-runtime/agents/ontologies/nmo/message.h we used a QDateTime
> > when we save Date.
> > It's normal but when we use search message we can search by date.
> > But a date is YYYY-MM-DD but in nepomuk with save time too
> >
> > => when we search which condition "equal" it will not get message.
> >
> > So it it possible to adapt code to use just a QDate ?
> >
> 
> I see. This does seem like a problem.
> 
> I presume you're talking about nmo:sentDate and nmo:receivedDate.

Yes when I search message from date.

> It would
> be possible to just use a QDate, but that would require a lot of change and
> I'm not sure it is the right way to go about it. Specially since the
> sent/received time seems important.
> 
> I think the proper fix would be searching for only the date when performing
> the searches. I experimented with a couple of queries and it seems this
> query gives me the correct results -
> 
> 
> select * where {
> 
> ?r a nmo:Message .
> 
> ?r nmo:sentDate ?dt .
> 
> FILTER(xsd:date(?dt) = "2012-10-09"^^xsd:date ) .
> 
> }

ok

> 
> Could you point me to the relevant code? I'll be happy to take a better
> look.


kdepim/mailcommon/searchpattern.cpp
void SearchRuleDate::addQueryTerms( Nepomuk2::Query::GroupTerm &groupTerm ) const
{
    const QDate date = QDate::fromString( contents(), Qt::ISODate );
    const Nepomuk2::Query::ComparisonTerm dateTerm(
      Vocabulary::NMO::sentDate(),
      Nepomuk2::Query::LiteralTerm( date ),
      nepomukComparator() );
    addAndNegateTerm( dateTerm, groupTerm );
}


And 

void SearchRuleNumerical::addQueryTerms( Nepomuk2::Query::GroupTerm &groupTerm ) const
{
  if ( kasciistricmp( field(), "<size>" ) == 0 ) {
    const Nepomuk2::Query::ComparisonTerm sizeTerm(
      Vocabulary::NIE::byteSize(),
      Nepomuk2::Query::LiteralTerm( contents().toInt() ),
      nepomukComparator() );
    addAndNegateTerm( sizeTerm, groupTerm );
  } else if ( kasciistricmp( field(), "<age in days>" ) == 0 ) {
    QDate date = QDate::currentDate();
    date = date.addDays( contents().toInt() );
    const Nepomuk2::Query::ComparisonTerm dateTerm(
      Vocabulary::NMO::sentDate(),
      Nepomuk2::Query::LiteralTerm( date ),
      nepomukComparator() );
    addAndNegateTerm( dateTerm, groupTerm );
  }
}

Don't know how we can add your filter code but it's here :)

> 
> Also, I just checked and SPARQL seems to have these really cool datetime
> functions which will can be used in queries [1]
> 

Great.

Thanks for your help

> [1] http://www.w3.org/TR/sparql11-query/#func-date-time
> 
> 
> > for the moment:
> >     /**
> >      * Get property
> > http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#sentDate.
> >      * Date when this message was sent.
> >      */
> >     QDateTime sentDate() const {
> >         QDateTime value;
> >         if(m_res-
> > >contains(QUrl::fromEncoded("
> > http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#sentDate",
> > QUrl::StrictMode)))
> >             value = m_res-
> > >property(QUrl::fromEncoded("
> > http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#sentDate",
> > QUrl::StrictMode)).first().value<QDateTime>();
> >         return value;
> >     }
> >
> >
> > Thanks for infos.
> >
> >
> > --
> > Laurent Montel | laurent.montel at kdab.com | KDE/Qt Senior Software Engineer
> > KDAB (France) S.A.S., a KDAB Group company
> > Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
> > KDAB - Qt Experts - Platform-independent software solutions
> >
-- 
Laurent Montel | laurent.montel at kdab.com | KDE/Qt Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090

_______________________________________________
KDE PIM mailing list kde-pim at kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/



More information about the kde-pim mailing list