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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/agents
From:       Volker Krause <vkrause () kde ! org>
Date:       2009-09-25 11:45:02
Message-ID: 1253879102.383984.13449.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1027995 by vkrause:

Factor out graph creation.


 M  +1 -16     nepomuk_calendar_feeder/nepomukcalendarfeeder.cpp  
 M  +0 -7      nepomuk_calendar_feeder/nepomukcalendarfeeder.h  
 M  +1 -20     nepomuk_contact_feeder/nepomukcontactfeeder.cpp  
 M  +0 -7      nepomuk_contact_feeder/nepomukcontactfeeder.h  
 M  +3 -22     nepomuk_email_feeder/nepomukemailfeeder.cpp  
 M  +0 -6      nepomuk_email_feeder/nepomukemailfeeder.h  
 M  +20 -0     nepomukfeeder/nepomukfeederagent.cpp  
 M  +9 -0      nepomukfeeder/nepomukfeederagent.h  


--- trunk/KDE/kdepim/akonadi/agents/nepomuk_calendar_feeder/nepomukcalendarfeeder.cpp \
#1027994:1027995 @@ -34,11 +34,7 @@
 #include <Soprano/Model>
 #include <Soprano/NodeIterator>
 #include <Soprano/QueryResultIterator>
-#include <soprano/nrl.h>
 
-#define USING_SOPRANO_NRLMODEL_UNSTABLE_API 1
-#include <soprano/nrlmodel.h>
-
 // ontology includes
 #include "attendee.h"
 #include "emailaddress.h"
@@ -95,13 +91,10 @@
   addSupportedMimeType( KCalMimeTypeVisitor::freeBusyMimeType() );
 
   changeRecorder()->itemFetchScope().fetchFullPayload();
-
-  mNrlModel = new Soprano::NRLModel( \
Nepomuk::ResourceManager::instance()->mainModel() );  }
 
 NepomukCalendarFeeder::~NepomukCalendarFeeder()
 {
-  delete mNrlModel;
 }
 
 void NepomukCalendarFeeder::updateItem( const Akonadi::Item &item )
@@ -115,16 +108,8 @@
   // first remove the item: since we use a graph that has a reference to all parts
   // of the item's semantic representation this is a really fast operation
   removeItemFromNepomuk( item );
+  const QUrl graphUri = createGraphForItem( item );
 
-  // create a new graph for the item
-  QUrl metaDataGraphUri;
-  QUrl graphUri = mNrlModel->createGraph( Soprano::Vocabulary::NRL::InstanceBase(), \
                &metaDataGraphUri );
-
-  // remember to which graph the item belongs to (used in search query in \
                removeItemFromNepomuk())
-  mNrlModel->addStatement( graphUri,
-                           QUrl::fromEncoded( \
"http://www.semanticdesktop.org/ontologies/2007/01/19/nie#dataGraphFor", \
                QUrl::StrictMode ),
-                           item.url(), metaDataGraphUri );
-
   if ( item.hasPayload<KCal::Event::Ptr>() ) {
     updateEventItem( item, item.payload<KCal::Event::Ptr>(), graphUri );
   } else if ( item.hasPayload<KCal::Journal::Ptr>() ) {
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_calendar_feeder/nepomukcalendarfeeder.h \
#1027994:1027995 @@ -31,11 +31,6 @@
 
 #include "ncal.h"
 
-namespace Soprano
-{
-class NRLModel;
-}
-
 namespace Akonadi {
 
 class NepomukCalendarFeeder : public NepomukFeederAgent
@@ -66,8 +61,6 @@
 
       tagsFromCategories( incidence, calInc->categories() );
     }
-
-    Soprano::NRLModel *mNrlModel;
 };
 
 }
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_contact_feeder/nepomukcontactfeeder.cpp \
#1027994:1027995 @@ -31,14 +31,6 @@
 #include <nepomuk/variant.h>
 #include <kurl.h>
 
-#include <Soprano/Model>
-#include <Soprano/NodeIterator>
-#include <Soprano/QueryResultIterator>
-#include <soprano/nrl.h>
-
-#define USING_SOPRANO_NRLMODEL_UNSTABLE_API 1
-#include <soprano/nrlmodel.h>
-
 // ontology includes
 #include "bbsnumber.h"
 #include "carphonenumber.h"
@@ -68,13 +60,10 @@
   addSupportedMimeType( KABC::ContactGroup::mimeType() );
 
   changeRecorder()->itemFetchScope().fetchFullPayload();
-
-  mNrlModel = new Soprano::NRLModel( \
Nepomuk::ResourceManager::instance()->mainModel() );  }
 
 NepomukContactFeeder::~NepomukContactFeeder()
 {
-  delete mNrlModel;
 }
 
 namespace {
@@ -97,16 +86,8 @@
   // first remove the item: since we use a graph that has a reference to all parts
   // of the item's semantic representation this is a really fast operation
   removeItemFromNepomuk( item );
+  const QUrl graphUri = createGraphForItem( item );
 
-  // create a new graph for the item
-  QUrl metaDataGraphUri;
-  QUrl graphUri = mNrlModel->createGraph( Soprano::Vocabulary::NRL::InstanceBase(), \
                &metaDataGraphUri );
-
-  // remember to which graph the item belongs to (used in search query in \
                removeItemFromNepomuk())
-  mNrlModel->addStatement( graphUri,
-                           QUrl::fromEncoded( \
"http://www.semanticdesktop.org/ontologies/2007/01/19/nie#dataGraphFor", \
                QUrl::StrictMode ),
-                           item.url(), metaDataGraphUri );
-
   if ( item.hasPayload<KABC::Addressee>() )
     updateContactItem( item, graphUri );
   else
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_contact_feeder/nepomukcontactfeeder.h \
#1027994:1027995 @@ -25,11 +25,6 @@
 #include <akonadi/agentbase.h>
 #include <akonadi/item.h>
 
-namespace Soprano
-{
-class NRLModel;
-}
-
 namespace Akonadi {
 
 class NepomukContactFeeder : public NepomukFeederAgent
@@ -43,8 +38,6 @@
     void updateItem( const Akonadi::Item &item );
     void updateContactItem( const Akonadi::Item &item, const QUrl& );
     void updateGroupItem( const Akonadi::Item &item, const QUrl& );
-
-    Soprano::NRLModel *mNrlModel;
 };
 
 }
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/nepomukemailfeeder.cpp \
#1027994:1027995 @@ -38,18 +38,11 @@
 #include <Nepomuk/Variant>
 #include <kurl.h>
 
-#include <Soprano/Vocabulary/Xesam>
-#include <Soprano/Vocabulary/NAO>
-#include <Soprano/Vocabulary/XMLSchema>
 #include <Soprano/Model>
 #include <Soprano/QueryResultIterator>
-#include <soprano/node.h>
-#include <soprano/nodeiterator.h>
-#include <soprano/nrl.h>
+#include <Soprano/Vocabulary/NAO>
+#include <Soprano/Vocabulary/XMLSchema>
 
-#define USING_SOPRANO_NRLMODEL_UNSTABLE_API 1
-#include <soprano/nrlmodel.h>
-
 using namespace Akonadi;
 
 Akonadi::NepomukEMailFeeder::NepomukEMailFeeder( const QString &id ) :
@@ -59,13 +52,10 @@
   addSupportedMimeType( "message/news" );
 
   changeRecorder()->itemFetchScope().fetchFullPayload();
-
-  mNrlModel = new Soprano::NRLModel( \
Nepomuk::ResourceManager::instance()->mainModel() );  }
 
 NepomukEMailFeeder::~NepomukEMailFeeder()
 {
-  delete mNrlModel;
 }
 
 void NepomukEMailFeeder::updateItem(const Akonadi::Item & item)
@@ -76,16 +66,7 @@
   // first remove the item: since we use a graph that has a reference to all parts
   // of the item's semantic representation this is a really fast operation
   removeItemFromNepomuk( item );
-
-  // create a new graph for the item
-  QUrl metaDataGraphUri;
-  QUrl graphUri = mNrlModel->createGraph( Soprano::Vocabulary::NRL::InstanceBase(), \
                &metaDataGraphUri );
-
-  // remember to which graph the item belongs to (used in search query in \
                removeItemFromNepomuk())
-  mNrlModel->addStatement( graphUri,
-                           QUrl::fromEncoded( \
"http://www.semanticdesktop.org/ontologies/2007/01/19/nie#dataGraphFor", \
                QUrl::StrictMode ),
-                           item.url(), metaDataGraphUri );
-
+  const QUrl graphUri = createGraphForItem( item );
   const KMime::Message::Ptr msg = item.payload<KMime::Message::Ptr>();
 
   // FIXME: make a distinction between email and news
--- trunk/KDE/kdepim/akonadi/agents/nepomuk_email_feeder/nepomukemailfeeder.h \
#1027994:1027995 @@ -30,11 +30,6 @@
 #include <kmime/kmime_header_parsing.h>
 #include <nepomukfeederagent.h>
 
-namespace Soprano
-{
-class NRLModel;
-}
-
 namespace Akonadi {
 
 class NepomukEMailFeeder : public NepomukFeederAgent
@@ -49,7 +44,6 @@
   private:
     QList<NepomukFast::Contact> extractContactsFromMailboxes( const \
                KMime::Types::Mailbox::List& mbs, const QUrl& );
     NepomukFast::PersonContact findContact( const QByteArray& address, const QUrl&, \
                bool *found );
-    Soprano::NRLModel *mNrlModel;
 };
 
 }
--- trunk/KDE/kdepim/akonadi/agents/nepomukfeeder/nepomukfeederagent.cpp \
#1027994:1027995 @@ -44,7 +44,11 @@
 #include <Soprano/NodeIterator>
 #include <Soprano/QueryResultIterator>
 #include <Soprano/Vocabulary/NAO>
+#include <Soprano/Vocabulary/NRL>
 
+#define USING_SOPRANO_NRLMODEL_UNSTABLE_API 1
+#include <Soprano/NRLModel>
+
 #include <QtCore/QTimer>
 #include <QtDBus/QDBusConnection>
 #include <QtDBus/QDBusReply>
@@ -61,11 +65,13 @@
   mTotalAmount( 0 ),
   mProcessedAmount( 0 ),
   mPendingJobs( 0 ),
+  mNrlModel( 0 ),
   mNepomukStartupAttempted( false ),
   mInitialUpdateDone( false )
 {
   // initialize Nepomuk
   Nepomuk::ResourceManager::instance()->init();
+  mNrlModel = new Soprano::NRLModel( \
Nepomuk::ResourceManager::instance()->mainModel() );  
   changeRecorder()->setChangeRecordingEnabled( false );
 
@@ -80,6 +86,7 @@
 
 NepomukFeederAgent::~NepomukFeederAgent()
 {
+  delete mNrlModel;
 }
 
 void NepomukFeederAgent::removeItemFromNepomuk( const Akonadi::Item &item )
@@ -293,4 +300,17 @@
     selfTest();
 }
 
+QUrl NepomukFeederAgent::createGraphForItem(const Akonadi::Item& item)
+{
+  QUrl metaDataGraphUri;
+  const QUrl graphUri = mNrlModel->createGraph( \
Soprano::Vocabulary::NRL::InstanceBase(), &metaDataGraphUri ); +
+  // remember to which graph the item belongs to (used in search query in \
removeItemFromNepomuk()) +  mNrlModel->addStatement( graphUri,
+                           QUrl::fromEncoded( \
"http://www.semanticdesktop.org/ontologies/2007/01/19/nie#dataGraphFor", \
QUrl::StrictMode ), +                           item.url(), metaDataGraphUri );
+
+  return graphUri;
+}
+
 #include "nepomukfeederagent.moc"
--- trunk/KDE/kdepim/akonadi/agents/nepomukfeeder/nepomukfeederagent.h \
#1027994:1027995 @@ -37,6 +37,11 @@
   class Item;
 }
 
+namespace Soprano
+{
+  class NRLModel;
+}
+
 class KJob;
 
 /** Shared base class for all Nepomuk feeders. */
@@ -60,6 +65,9 @@
     /** Reimplement to do the actual work. */
     virtual void updateItem( const Akonadi::Item &item ) = 0;
 
+    /** Create a graph for the given item with we use to mark all information \
created by the feeder agent. */ +    QUrl createGraphForItem( const Akonadi::Item \
&item ); +
   public slots:
     /** Trigger a complete update of all items. */
     void updateAll();
@@ -88,6 +96,7 @@
     Akonadi::Collection mCurrentCollection;
     int mTotalAmount, mProcessedAmount, mPendingJobs;
     QTimer mNepomukStartupTimeout;
+    Soprano::NRLModel *mNrlModel;
     bool mNepomukStartupAttempted;
     bool mInitialUpdateDone;
 };


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

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