1 /* This file is part of the KDE Project
2 Copyright (c) 2008 Sebastian Trueg <trueg@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "migration1.h"
21 #include <Soprano/Model>
22 #include <Soprano/Node>
23 #include <Soprano/Statement>
24 #include <Soprano/StatementIterator>
25 #include <Soprano/Vocabulary/NAO>
27 #include <kpluginfactory.h>
28 #include <kpluginloader.h>
31 Nepomuk::Migration1::Migration1( QObject
* parent
, const QList
<QVariant
>& )
34 // we just do our data updating and afterwards we idle
37 // ====================================
38 QList
<Soprano::Statement
> oldLabelStatements
39 = mainModel()->listStatements( Soprano::Node(),
40 QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#label" ),
41 Soprano::Node() ).allStatements();
44 // (keep all metametadata like graphs and creation dates since the actual data does not change)
45 foreach( Soprano::Statement s
, oldLabelStatements
) {
46 s
.setPredicate( Soprano::Vocabulary::NAO::prefLabel() );
47 mainModel()->addStatement( s
);
50 mainModel()->removeStatements( oldLabelStatements
);
54 // ====================================
55 QList
<Soprano::Statement
> oldRatingStatements
56 = mainModel()->listStatements( Soprano::Node(),
57 QUrl::fromEncoded( "http://www.semanticdesktop.org/ontologies/2007/08/15/nao#rating" ),
58 Soprano::Node() ).allStatements();
61 // (keep all metametadata like graphs and creation dates since the actual data does not change)
62 foreach( Soprano::Statement s
, oldRatingStatements
) {
63 s
.setPredicate( Soprano::Vocabulary::NAO::numericRating() );
64 mainModel()->addStatement( s
);
67 mainModel()->removeStatements( oldLabelStatements
);
71 Nepomuk::Migration1::~Migration1()
75 NEPOMUK_EXPORT_SERVICE( Nepomuk::Migration1
, "nepomukmigration1" )
77 #include "migration1.moc"