[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/nepomuk/query
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2010-09-06 19:50:31
Message-ID: 20100906195031.1DDFEAC888 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1172248 by trueg:

Let the dataRangeQuery properly handle invalid QDate arguments:
* If both are invalid return an invalid Query
* If only one is valid return an date range with an open end or start

 M  +21 -1     standardqueries.cpp  
 M  +4 -0      standardqueries.h  


--- trunk/KDE/kdelibs/nepomuk/query/standardqueries.cpp #1172247:1172248
@@ -84,6 +84,9 @@
 
     case ResourcesForActivityQuery: {
         // FIXME
+        // get all resources that have some prop defined in a graph which was \
created in the requested activity? +        // select distinct ?r where { graph ?g { \
?r ?p ?o . } . ?g <activity> <A> . } +        // it would be something like: \
MetaDataTerm( <activity>, <A> )  }
     }
 
@@ -103,14 +106,24 @@
         // include files modified in our date range
         ComparisonTerm lastModifiedStart = Nepomuk::Vocabulary::NIE::lastModified() \
>                 dateFrom;
         ComparisonTerm lastModifiedEnd = Nepomuk::Vocabulary::NIE::lastModified() < \
dateTo; +        if( start.isValid() && end.isValid() )
         query = query || ( lastModifiedStart && lastModifiedEnd );
+        else if( start.isValid() )
+            query = query || lastModifiedStart;
+        else if( end.isValid() )
+            query = query || lastModifiedEnd;
     }
 
     if( dateFlags & ContentDate ) {
         // include files created (as in photos taken) in our data range
         ComparisonTerm contentCreatedStart = \
                Nepomuk::Vocabulary::NIE::contentCreated() > dateFrom;
         ComparisonTerm contentCreatedEnd = \
Nepomuk::Vocabulary::NIE::contentCreated() < dateTo; +        if( start.isValid() && \
end.isValid() )  query = query || ( contentCreatedStart && contentCreatedEnd );
+        else if( start.isValid() )
+            query = query || contentCreatedStart;
+        else if( end.isValid() )
+            query = query || contentCreatedEnd;
     }
 
     if( dateFlags & UsageDate ) {
@@ -118,7 +131,14 @@
         // TODO: also take the end of the event into account
         ComparisonTerm accessEventStart = Nepomuk::Vocabulary::NUAO::start() > \
                dateFrom;
         ComparisonTerm accessEventEnd = Nepomuk::Vocabulary::NUAO::start() < dateTo;
-        ComparisonTerm accessEventCondition = Nepomuk::Vocabulary::NUAO::involves() \
== ( accessEventStart && accessEventEnd ); +        ComparisonTerm \
accessEventCondition( Nepomuk::Vocabulary::NUAO::involves(), Term() ); +        if( \
start.isValid() && end.isValid() ) +            accessEventCondition.setSubTerm( \
accessEventStart && accessEventEnd ); +        else if( start.isValid() )
+            accessEventCondition.setSubTerm( accessEventStart );
+        else if( end.isValid() )
+            accessEventCondition.setSubTerm( accessEventEnd );
+        if( accessEventCondition.subTerm().isValid() )
         query = query || accessEventCondition.inverted();
     }
 
--- trunk/KDE/kdelibs/nepomuk/query/standardqueries.h #1172247:1172248
@@ -127,6 +127,10 @@
          * from \p start to \p end (including both full days). The flags specified \
                in \p dateFlags can be used to influence the
          * type of dates that are queried.
          *
+         * \param start The start date of the range, if invalid no start is used, \
i.e. everything before \p end matches. +         * \param end The end date of the \
range, if invalid no end is used, i.e. everything after \p start matches. +         * \
\param dateFlags Optional flags to influence the final query. +         *
          * \since 4.6
          */
         NEPOMUKQUERY_EXPORT Query dateRangeQuery( const QDate& start, const QDate& \
end, DateRangeFlags dateFlags = AllDates );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic