[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/nepomuk-kde/annotation/plugins/scribo
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2010-05-05 8:51:32
Message-ID: 20100505085132.EEDB9AC8AB () svn ! kde ! org
[Download RAW message or body]
SVN commit 1123078 by trueg:
Ported to Nepomuk query API
M +1 -1 CMakeLists.txt
M +19 -11 scriboannotationplugin.cpp
--- trunk/playground/base/nepomuk-kde/annotation/plugins/scribo/CMakeLists.txt \
#1123077:1123078 @@ -21,8 +21,8 @@
kde4_add_plugin(nepomuk_scriboannotationplugin ${scriboannotationplugin_SRC})
target_link_libraries(nepomuk_scriboannotationplugin
${NEPOMUK_LIBRARIES}
+ ${NEPOMUK_QUERY_LIBRARIES}
${SOPRANO_LIBRARIES}
- ${SOPRANO_INDEX_LIBRARIES}
${KDE4_KDEUI_LIBS}
${KDE4_KIO_LIBS}
${SCRIBO_LIBRARIES}
--- trunk/playground/base/nepomuk-kde/annotation/plugins/scribo/scriboannotationplugin.cpp \
#1123077:1123078 @@ -1,6 +1,6 @@
/*
* This file is part of the Nepomuk KDE project.
- * Copyright (c) 2009 Sebastian Trueg <trueg@kde.org>
+ * Copyright (c) 2009-2010 Sebastian Trueg <trueg@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -41,6 +41,11 @@
#include <Nepomuk/Variant>
#include <Nepomuk/Types/Property>
#include <Nepomuk/Types/Class>
+#include <Nepomuk/Query/Query>
+#include <Nepomuk/Query/ResourceTypeTerm>
+#include <Nepomuk/Query/AndTerm>
+#include <Nepomuk/Query/OrTerm>
+#include <Nepomuk/Query/LiteralTerm>
#include <Soprano/Model>
#include <Soprano/QueryResultIterator>
@@ -150,20 +155,23 @@
else {
// FIXME: use the entity type
- QString query = QString( "%1 AND ( %2:%3 OR %2:%4 OR %2:%5 OR %2:%6 )" )
- .arg( \
Soprano::Index::IndexFilterModel::encodeStringForLuceneQuery( entity.label() \
).replace( ' ', " AND " ) )
- .arg( \
Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery( \
Soprano::Vocabulary::RDF::type() ) )
- .arg( \
Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery( \
Soprano::Vocabulary::NAO::Tag() ) )
- .arg( \
Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery( \
Vocabulary::PIMO::Project() ) )
- .arg( \
Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery( Vocabulary::PIMO::Task() ) \
)
- .arg( \
Soprano::Index::IndexFilterModel::encodeUriForLuceneQuery( Vocabulary::PIMO::Person() \
) );
- kDebug() << query;
+ Query::Query query(
+ Query::AndTerm(
+ Query::LiteralTerm( entity.label() ),
+ Query::OrTerm(
+ Query::ResourceTypeTerm( Soprano::Vocabulary::NAO::Tag() ),
+ Query::ResourceTypeTerm( Vocabulary::PIMO::Project() ),
+ Query::ResourceTypeTerm( Vocabulary::PIMO::Task() ),
+ Query::ResourceTypeTerm( Vocabulary::PIMO::Person() )
+ )
+ )
+ );
bool haveTag = false;
- Soprano::QueryResultIterator it = \
ResourceManager::instance()->mainModel()->executeQuery( query, \
Soprano::Query::QueryLanguageUser, "lucene" ); + \
Soprano::QueryResultIterator it = \
ResourceManager::instance()->mainModel()->executeQuery( query.toSparqlQuery(), \
Soprano::Query::QueryLanguageSparql ); while ( it.next() ) {
Nepomuk::Resource res( it[0].uri() );
- double score = it[1].literal().toDouble();
+ double score = 0.0; //it[1].literal().toDouble();
kDebug() << res.resourceUri() << score;
if ( res.resourceType() == Soprano::Vocabulary::NAO::Tag() )
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic