3
3
Copyright (C) 2010 Sebastian Trueg <trueg@kde.org>
5
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License version 2 as published by the Free Software Foundation.
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
8
version 2.1 of the License, or (at your option) version 3, or any
9
later version accepted by the membership of KDE e.V. (or its
10
successor approved by the membership of KDE e.V.), which shall
11
act as a proxy defined in Section 6 of version 3 of the license.
9
13
This library is distributed in the hope that it will be useful,
10
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
16
Lesser General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17
Boston, MA 02110-1301, USA.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library. If not, see <http://www.gnu.org/licenses/>.
20
22
#include "timelinetools.h"
22
24
#include <Soprano/Node>
23
25
#include <Soprano/Vocabulary/XMLSchema>
27
#include <Nepomuk/Vocabulary/NFO>
28
#include <Nepomuk/Vocabulary/NIE>
29
#include <Nepomuk/Vocabulary/NUAO>
31
#include <Nepomuk/Query/FileQuery>
32
#include <Nepomuk/Query/AndTerm>
33
#include <Nepomuk/Query/OrTerm>
34
#include <Nepomuk/Query/ComparisonTerm>
35
#include <Nepomuk/Query/LiteralTerm>
36
#include <Nepomuk/Query/StandardQuery>
31
39
#include <KCalendarSystem>
144
KUrl Nepomuk::buildTimelineQueryUrl( const QDate& date )
152
Nepomuk::Query::Query Nepomuk::buildTimelineQuery( const QDate& date )
146
static const char* DATEFORMATSTART("yyyy-MM-ddT00:00:00.000Z");
147
static const char* DATEFORMATEND("yyyy-MM-ddT23:59:59.999Z");
149
QString dateFrom = date.toString(DATEFORMATSTART);
150
QString dateTo = date.toString(DATEFORMATEND);
152
QString query = QString("select distinct ?r where { "
159
"FILTER(?date > '%5'^^%7 && ?date < '%6'^^%7) . "
160
"OPTIONAL { ?r2 a %8 . FILTER(?r=?r2) . } . FILTER(!BOUND(?r2)) . "
162
.arg( Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NFO::FileDataObject()),
163
Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NIE::lastModified()),
164
Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NUAO::lastUsage()),
165
Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NIE::contentCreated()),
168
Soprano::Node::resourceToN3(Soprano::Vocabulary::XMLSchema::dateTime()),
169
Soprano::Node::resourceToN3(Nepomuk::Vocabulary::NFO::Folder()) );
170
KUrl url("nepomuksearch:/");
171
url.addQueryItem( "sparql", query );
154
Nepomuk::Query::FileQuery query = Nepomuk::Query::dateRangeQuery( date, date );
155
query.setFileMode( Query::FileQuery::QueryFiles );