~ubuntu-branches/ubuntu/natty/kdebase-runtime/natty-proposed

« back to all changes in this revision

Viewing changes to nepomuk/services/backupsync/lib/resourcemerger.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-11-24 11:07:10 UTC
  • mto: (0.8.7 upstream)
  • mto: This revision was merged to the branch mainline in revision 129.
  • Revision ID: james.westby@ubuntu.com-20101124110710-6dbsyw0yh21qvn82
Tags: upstream-4.5.80
ImportĀ upstreamĀ versionĀ 4.5.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of the Nepomuk KDE project.
 
3
    Copyright (C) 2010  Vishesh Handa <handa.vish@gmail.com>
 
4
 
 
5
   This library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) version 3, or any
 
9
   later version accepted by the membership of KDE e.V. (or its
 
10
   successor approved by the membership of KDE e.V.), which shall
 
11
   act as a proxy defined in Section 6 of version 3 of the license.
 
12
 
 
13
   This library is distributed in the hope that it will be useful,
 
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
   Lesser General Public License for more details.
 
17
 
 
18
   You should have received a copy of the GNU Lesser General Public
 
19
   License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
20
*/
 
21
 
 
22
 
 
23
#ifndef NEPOMUK_RESOURCEMERGER_H
 
24
#define NEPOMUK_RESOURCEMERGER_H
 
25
 
 
26
#include <QtCore/QList>
 
27
#include <QtCore/QHash>
 
28
 
 
29
#include <KUrl>
 
30
 
 
31
#include "nepomuksync_export.h"
 
32
 
 
33
namespace Soprano {
 
34
    class Statement;
 
35
    class Model;
 
36
    class Graph;
 
37
}
 
38
 
 
39
namespace Nepomuk {
 
40
 
 
41
    class Resource;
 
42
    class ResourceManager;
 
43
 
 
44
    namespace Types {
 
45
        class Class;
 
46
    }
 
47
    
 
48
    namespace Sync {
 
49
 
 
50
        /**
 
51
         * \class ResourceMerger resourcemerger.h
 
52
         *
 
53
         * This class can be used to push resources into repository after identification.
 
54
         * It's default behavior is to create all the resources that have not been
 
55
         * identified.
 
56
         *
 
57
         * By default, it pushes all the statements with a nrl:InstanceBase graph. If a
 
58
         * statement already exists in the repository then it is NOT overwritten.
 
59
         * 
 
60
         * \author Vishesh Handa <handa.vish@gmail.com>
 
61
         */
 
62
        class NEPOMUKSYNC_EXPORT ResourceMerger
 
63
        {
 
64
        public:
 
65
            ResourceMerger( ResourceManager * rm = 0 );
 
66
            virtual ~ResourceMerger();
 
67
 
 
68
            ResourceManager * resourceManager() const;
 
69
            void setResourceManager( ResourceManager * rm );
 
70
 
 
71
            Soprano::Model * model() const;
 
72
 
 
73
            /**
 
74
             * Pushes all the statements in \p graph into the model. If the statement
 
75
             * already exists then resolveDuplicate() is called.
 
76
             *
 
77
             * If any of the statements contains a graph, then that graph is used. Otherwise
 
78
             * a newly generated graph is used.
 
79
             *
 
80
             * \sa setGraphType graphType
 
81
             */
 
82
            virtual void merge( const Soprano::Graph & graph, const QHash<KUrl, Resource> & mappings );
 
83
 
 
84
            /**
 
85
             * The graph type by default is nrl:InstanceBase. If \p type is not a subclass of
 
86
             * nrl:Graph then it is ignored.
 
87
             */
 
88
            bool setGraphType( const Types::Class & type );
 
89
            
 
90
            Types::Class graphType() const;
 
91
 
 
92
        protected:
 
93
            
 
94
            /**
 
95
             * Called when trying to merge a statement which contains a Resource that
 
96
             * has not been identified.
 
97
             * 
 
98
             * The default implementation of this creates the resource in the main model.
 
99
             */
 
100
            virtual Resource resolveUnidentifiedResource( const KUrl & uri );
 
101
 
 
102
            /**
 
103
             * Creates a new graph of type graphType()
 
104
             */
 
105
            virtual KUrl createGraph();
 
106
 
 
107
            /**
 
108
             * Push the statement into the Nepomuk repository if it doesn't already exist!
 
109
             */
 
110
            void push( const Soprano::Statement & st );
 
111
 
 
112
        private:
 
113
            class Private;
 
114
            Private * d;
 
115
        };
 
116
    }
 
117
}
 
118
#endif // NEPOMUK_RESOURCEMERGER_H