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

List:       kde-commits
Subject:    KDE/kdebase/runtime/nepomuk/strigibackend
From:       Sebastian Trueg <sebastian () trueg ! de>
Date:       2008-12-09 17:33:38
Message-ID: 1228844018.197248.12572.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 894959 by trueg:

Cleaner context URI scheme + correct relation between data and metadata graph

 M  +24 -9     sopranoindexwriter.cpp  


--- trunk/KDE/kdebase/runtime/nepomuk/strigibackend/sopranoindexwriter.cpp \
#894958:894959 @@ -34,6 +34,7 @@
 #include <QtCore/QDebug>
 #include <QtCore/QThread>
 #include <QtCore/QDateTime>
+#include <QtCore/QUuid>
 
 #include <KUrl>
 
@@ -105,6 +106,10 @@
         return uri;
     }
 
+    QUrl createGraphUri() {
+        return QUrl( "urn:nepomuk:local:" + QUuid::createUuid().toString().remove( \
QRegExp( "[\\{\\}]" ) ) ); +    }
+
     class FileMetaData
     {
     public:
@@ -207,26 +212,32 @@
     QString systemLocationUri = Util::fieldUri( FieldRegister::pathFieldName \
).toString();  for ( unsigned int i = 0; i < entries.size(); ++i ) {
         QString path = QString::fromUtf8( entries[i].c_str() );
-        QString query = QString( "select ?g where { ?r <%1> \"%2\"^^<%3> . "
-                                 "?g <http://www.strigi.org/fields#indexGraphFor> ?r \
. }" ) +        QString query = QString( "select ?g ?mg where { "
+                                 "?r <%1> \"%2\"^^<%3> . "
+                                 "?g <http://www.strigi.org/fields#indexGraphFor> ?r \
. " +                                 "OPTIONAL { ?mg <%4> ?g . } }" )
                         .arg( systemLocationUri )
                         .arg( path )
-                        .arg( Vocabulary::XMLSchema::string().toString() );
+                        .arg( Vocabulary::XMLSchema::string().toString() )
+                        .arg( Vocabulary::NRL::coreGraphMetadataFor().toString() );
 
 //        qDebug() << "deleteEntries query:" << query;
 
         QueryResultIterator result = d->repository->executeQuery( query, \
::Soprano::Query::QueryLanguageSparql );  if ( result.next() ) {
             Node indexGraph = result.binding( "g" );
+            Node metaDataGraph = result.binding( "mg" );
+
             result.close();
 
-//            qDebug() << "Found indexGraph to delete:" << indexGraph;
-
             // delete the indexed data
             d->repository->removeContext( indexGraph );
 
-            // delete the metadata
-            d->repository->removeAllStatements( Statement( indexGraph, Node(), \
Node() ) ); +            // delete the metadata (backwards compatible)
+            if ( metaDataGraph.isValid() )
+                d->repository->removeContext( metaDataGraph );
+            else
+                d->repository->removeAllStatements( Statement( indexGraph, Node(), \
Node() ) );  }
     }
 }
@@ -276,7 +287,7 @@
         data->context = it.current().subject().uri();
     }
     else {
-        data->context = Util::uniqueUri( "http://www.strigi.org/contexts/", \
d->repository ); +        data->context = createGraphUri();
     }
 
 //    qDebug() << "Starting analysis for" << data->fileUri << "in thread" << \
QThread::currentThread(); @@ -466,7 +477,7 @@
 
     // create the provedance data for the data graph
     // TODO: add more data at some point when it becomes of interest
-    QUrl metaDataContext = Util::uniqueUri( "http://www.strigi.org/graphMetaData/", \
d->repository ); +    QUrl metaDataContext = md->context.toString() + "-metadata";
     d->repository->addStatement( Statement( md->context,
                                             Vocabulary::RDF::type(),
                                             Vocabulary::NRL::InstanceBase(),
@@ -483,6 +494,10 @@
                                             Vocabulary::RDF::type(),
                                             Vocabulary::NRL::GraphMetadata(),
                                             metaDataContext ) );
+    d->repository->addStatement( metaDataContext,
+                                 Vocabulary::NRL::coreGraphMetadataFor(),
+                                 md->context,
+                                 metaDataContext );
 
     // cleanup
     delete md;


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

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