[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-pim
Subject: Re: [Kde-pim] Baloo Status
From: Vishesh Handa <me () vhanda ! in>
Date: 2014-01-20 18:43:25
Message-ID: 36585978.yKRQQ1bisv () vlap
[Download RAW message or body]
On Monday 20 January 2014 17:27:11 Till Adam wrote:
> On Monday, January 20, 2014 05:16:06 PM Vishesh Handa wrote:
> > 5. Porting the ContactSearchJob - Baloo uses a JSON based language. The
> > ContactSearchJob has a lot of SPARQL queries. These should be replaced
> > with
> > json which Baloo understands. It's a simple task, but it needs to be done.
> > Any takers?
>
> I can asssure you that nothing about ContactSearchJob is ever easy. :)
>
It really is. I had already ported it once when the JSON wasn't finalized. Now
it just needs to be done again.
Initial patch attached.
> Till
--
Vishesh Handa
["Contact-Search-job.diff" (Contact-Search-job.diff)]
commit 6dc1fc07a794ff42e4ea49ac996e198fb4347f5e
Author: Vishesh Handa <me@vhanda.in>
Date: Wed Nov 6 11:29:04 2013 +0100
Allow the ContactSearchJob to send queires recognized by Baloo
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7abf889..ddae21e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,6 +40,8 @@ endif()
############### Build Options ###############
+option(AKONADI_USE_BALOO_SEARCH "Build Akonadi with Baloo as the search engine." \
TRUE) +
option(KDEPIM_ONLY_KLEO "Only build the libraries needed by Kleopatra." FALSE)
cmake_dependent_option(KDEPIM_NO_KCAL "Build without legacy KCal" TRUE \
"KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED" FALSE) \
cmake_dependent_option(KDEPIM_NO_KRESOURCES "Build without legacy KResource support." \
TRUE "KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED" FALSE) @@ -108,6 +110,9 @@ if (NOT \
KDEPIM_ONLY_KLEO) find_package(NepomukCore)
set_package_properties(NepomukCore PROPERTIES DESCRIPTION "NepomukCore" URL \
"http://www.kde.org" TYPE REQUIRED PURPOSE "Nepomuk extends the search and tagging \
functionalities in KMail and Akonadi")
+ find_package(Baloo)
+ set_package_properties(Baloo PROPERTIES DESCRIPTION "Baloo" URL \
"http://www.kde.org" TYPE REQUIRED PURPOSE "Baloo extends the search and tagging \
functionalities in KMail and Akonadi") +
set(LIBICAL_MIN_VERSION "0.42")
find_package(Libical)
set_package_properties(Libical PROPERTIES DESCRIPTION "libical" URL \
"http://sourceforge.net/projects/freeassociation" TYPE REQUIRED PURPOSE "Calendar \
support")
diff --git a/akonadi/contact/contactsearchjob.cpp \
b/akonadi/contact/contactsearchjob.cpp index 8102381..20c0af4 100644
--- a/akonadi/contact/contactsearchjob.cpp
+++ b/akonadi/contact/contactsearchjob.cpp
@@ -23,6 +23,8 @@
#include <akonadi/itemfetchscope.h>
+#define AKONADI_USE_BALOO_SEARCH 1
+
using namespace Akonadi;
class ContactSearchJob::Private
@@ -38,7 +40,13 @@ ContactSearchJob::ContactSearchJob( QObject * parent )
d->mLimit = -1;
// by default search for all contacts
- ItemSearchJob::setQuery( QLatin1String( "SELECT ?r WHERE { ?r a nco:Contact }" ) \
); + ItemSearchJob::setQuery( QLatin1String(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ ""
+#else
+ "SELECT ?r WHERE { ?r a nco:Contact }"
+#endif
+ ) );
}
ContactSearchJob::~ContactSearchJob()
@@ -80,6 +88,12 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc if ( match == ExactMatch ) {
if ( criterion == Name ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria': \"Exact\","
+ " \"name': \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -87,9 +101,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc
" ?r nco:fullname \"%1\"^^<http://www.w3.org/2001/XMLSchema#string>. "
" "
"} "
+#endif
);
} else if ( criterion == Email ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"Exact\","
+ " \"email\": \"%1\""
+#else
"SELECT DISTINCT ?person ?reqProp1 "
"WHERE { "
" "
@@ -98,9 +119,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc
" ?email nco:emailAddress \
\"%1\"^^<http://www.w3.org/2001/XMLSchema#string> . " " "
"}"
+#endif
);
} else if ( criterion == NickName ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"Exact\","
+ " \"nick\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -108,9 +136,17 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc
" ?r nco:nickname \"%1\"^^<http://www.w3.org/2001/XMLSchema#string> ."
" "
"}"
+#endif
);
} else if ( criterion == NameOrEmail ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"Exact\","
+ " \"name\": \"%1\","
+ " \"email\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -122,9 +158,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc
" ?email nco:emailAddress \
\"%1\"^^<http://www.w3.org/2001/XMLSchema#string> . } " " "
"}"
+#endif
);
} else if ( criterion == ContactUid ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"Exact\","
+ " \"uid\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -132,11 +175,18 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc
" ?r nco:contactUID \"%1\"^^<http://www.w3.org/2001/XMLSchema#string> \
." " "
"}"
+#endif
);
}
} else if ( match == StartsWithMatch ) {
if ( criterion == Name ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"StartsWith\","
+ " \"name\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -145,9 +195,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc " ?v bif:contains \"'%1*'\" . "
" "
"} "
+#endif
);
} else if ( criterion == Email ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"StartsWith\","
+ " \"email\": \"%1\""
+#else
"SELECT DISTINCT ?person ?reqProp1 "
"WHERE { "
" "
@@ -157,9 +214,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc " ?v bif:contains \"'%1\'\" . "
" "
"}"
+#endif
);
} else if ( criterion == NickName ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"StartsWith\","
+ " \"nick\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -168,9 +232,17 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc " ?v bif:contains \"'%1\'\" . "
" "
"}"
+#endif
);
} else if ( criterion == NameOrEmail ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"StartsWith\","
+ " \"name\": \"%1\","
+ " \"email\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -184,9 +256,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc " ?v bif:contains \"'%1'\" . }"
" "
"}"
+#endif
);
} else if ( criterion == ContactUid ) {
query += QString::fromLatin1(
+#ifdef AKONADI_USE_BALOO_SEARCH
+ "{"
+ " \"type\": \"Contact\","
+ " \"matchCriteria\": \"StartsWith\","
+ " \"uid\": \"%1\""
+#else
"SELECT DISTINCT ?r ?reqProp1 "
"WHERE { "
" "
@@ -195,6 +274,7 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc " ?v bif:contains \"'%1*'\" . "
" "
"}"
+#endif
);
}
} else if ( match == ContainsMatch || match == ContainsWordBoundaryMatch ) {
@@ -266,7 +346,16 @@ void ContactSearchJob::setQuery( Criterion criterion, const \
QString &value, Matc }
if ( d->mLimit != -1 ) {
+#ifdef AKONADI_USE_BALOO_SEARCH
+ query += QString::fromLatin1( ", \"limit\": %1 }" ).arg( d->mLimit );
+#else
query += QString::fromLatin1( " LIMIT %1" ).arg( d->mLimit );
+#endif
+ }
+ else {
+#ifdef AKONADI_USE_BALOO_SEARCH
+ query += QString::fromLatin1( "}" );
+#endif
}
query = query.arg( value );
_______________________________________________
KDE PIM mailing list kde-pim@kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
KDE PIM home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic