[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9

Maximiliano Curia maxy at moszumanska.debian.org
Mon May 9 09:07:28 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=383f1f6

The following commit has been merged in the master branch:
commit 383f1f61d0fe886f95a8e9a41146b00b907c04d4
Author: Vishesh Handa <handa.vish at gmail.com>
Date:   Sat Feb 18 19:57:40 2012 +0530

    Switch to nepomuk:/me from nepomuk:/myself
    
    Additionally, avoid using Nepomuk::Resource as it caches the data
    and uses resource to make sure the cache is up to date.
    
    Plus, this is faster.
---
 kpeople/nepomuk-feeder/nepomuk-storage.cpp | 66 +++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 23 deletions(-)

diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index bb70366..23adae9 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -38,6 +38,7 @@
 
 #include <Nepomuk/Vocabulary/NCO>
 #include <Nepomuk/Vocabulary/PIMO>
+#include <Soprano/Vocabulary/RDF>
 
 #include <Nepomuk/Query/Query>
 #include <Nepomuk/Query/AndTerm>
@@ -55,8 +56,11 @@
 #include <TelepathyQt/Constants>
 #include <TelepathyQt/AvatarData>
 #include <Soprano/Vocabulary/NAO>
+#include <Soprano/Model>
+#include <Soprano/QueryResultIterator>
 
 using namespace Nepomuk::Vocabulary;
+using namespace Soprano::Vocabulary;
 
 class AccountResources::Data : public QSharedData {
 public:
@@ -322,35 +326,51 @@ void NepomukStorage::init()
     // Here we get the "me" person contact.
     // FIXME: Port to new OSCAF standard for accessing "me" as soon as it
     // becomes available.
-    Nepomuk::Thing me(QUrl::fromEncoded("nepomuk:/myself"));
-
-    // FIXME: We should not create "me" if it doesn't exist once the above
-    // fixme has been dealt with.
-    if (!me.exists()) {
-        // The PIMO:Person representing "me" does not exist, so we need to create it.
-        kWarning() << "PIMO 'me' does not exist. Creating it.";
-        me.addType(Nepomuk::Vocabulary::PIMO::Person());
+    QUrl meUri("nepomuk:/me");
+
+    Soprano::Model* model = Nepomuk::ResourceManager::instance()->mainModel();
+    bool exists = model->containsAnyStatement( meUri, RDF::type(), PIMO::Person() );
+    if( !exists ) {
+        // It should have been created by the Storage Service
+        // TODO: Create it
+        kWarning() << "nepomuk:/me doesn't exist!! Aborting";
+        return;
     }
 
-    // Loop through all the grounding instances of this person
-    Q_FOREACH (Nepomuk::Resource resource, me.groundingOccurrences()) {
-        // See if this grounding instance is of type nco:contact.
-        if (resource.hasType(Nepomuk::Vocabulary::NCO::PersonContact())) {
-            // FIXME: We are going to assume the first NCO::PersonContact is the
-            // right one. Can we improve this?
-            m_mePersonContact = resource.resourceUri();
-            break;
-        }
+    QString query = QString::fromLatin1("select ?o where { <nepomuk:/me> %1 ?o. ?o a %2 .}")
+                    .arg( Soprano::Node::resourceToN3( PIMO::groundingOccurrence() ),
+                          Soprano::Node::resourceToN3( NCO::PersonContact() ) );
+
+    Soprano::QueryResultIterator it = model->executeQuery( query, Soprano::Query::QueryLanguageSparql );
+
+    QList<QUrl> groundingOccurrences;
+    while( it.next() ) {
+        groundingOccurrences << it["o"].uri();
     }
 
-    if (!Nepomuk::Resource(m_mePersonContact).exists()) {
-        kWarning() << "PersonContact 'me' does not exist. Creating it.";
-        // FIXME: We shouldn't create this person contact, but for now we will
-        // to ease development :) (see above FIXME's)
-        m_mePersonContact = "nepomuk:/myself-person-contact";
-        me.addGroundingOccurrence(m_mePersonContact);
+    if( groundingOccurrences.isEmpty() ) {
+        Nepomuk::SimpleResource personContact;
+        personContact.addType( NCO::PersonContact() );
+
+        Nepomuk::SimpleResource me( meUri );
+        me.addProperty( PIMO::groundingOccurrence(), personContact );
+
+        Nepomuk::SimpleResourceGraph graph;
+        graph << me << personContact;
+
+        Nepomuk::StoreResourcesJob * job = Nepomuk::storeResources( graph );
+        job->exec();
+
+        if( job->error() ) {
+            kWarning() << job->errorString();
+            return;
+        }
+        groundingOccurrences << job->mappings().value( personContact.uri() );
     }
 
+    //FIXME: Use all of them, not just the first one
+    m_mePersonContact = groundingOccurrences.first();
+
     // *********************************************************************************************
     // Load all the relevant accounts and contacts that are already in Nepomuk.
 

-- 
ktp-common-internals packaging



More information about the pkg-kde-commits mailing list