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

« back to all changes in this revision

Viewing changes to nepomuk/services/backupsync/service/changelogmerger.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
 
 
24
#ifndef CHANGELOGMERGER_H
 
25
#define CHANGELOGMERGER_H
 
26
 
 
27
#include "resourcemerger.h"
 
28
#include "simpleresource.h"
 
29
#include "changelog.h"
 
30
#include "resourcelog.h"
 
31
 
 
32
#include <QtCore/QDateTime>
 
33
 
 
34
namespace Nepomuk {
 
35
    class ChangeLogMerger : public Sync::ResourceMerger
 
36
    {
 
37
    public:
 
38
        ChangeLogMerger( ChangeLog log );
 
39
 
 
40
        int id();
 
41
        void mergeChangeLog();
 
42
 
 
43
        /**
 
44
         * Converts the contents of the LogFile into the MergeHash
 
45
         * The LogFile can get rather large, so this could be a time consuming
 
46
         * process.
 
47
         */
 
48
        void load();
 
49
 
 
50
        QList<Soprano::Statement> multipleMergers() const;
 
51
        
 
52
    private:
 
53
        ChangeLog m_logFile;
 
54
        QDateTime m_minDateTime;
 
55
        
 
56
        QList<Sync::SimpleResource> m_jobs;
 
57
        QList<Soprano::Statement> m_multipleMergers;
 
58
        
 
59
        /// Contains all the records from the LogFile
 
60
        ResourceLogMap m_hash;
 
61
        
 
62
        static int NextId;
 
63
        int m_id;
 
64
 
 
65
        KUrl m_theGraph;
 
66
 
 
67
        /**
 
68
         * Handles the case when the Resource's metadata has been deleted from
 
69
         * the LogFile.
 
70
         * \return true if resUri was deleted, false otherwsie
 
71
         */
 
72
        bool handleResourceDeletion( const KUrl & resUri );
 
73
 
 
74
        /**
 
75
         * Resolve conflicts for properties with multiple cardinalities. It works by locally
 
76
         * making all the changes in the SimpleResource.
 
77
         */
 
78
        void resolveMultipleCardinality( const QList<ChangeLogRecord >& theirRecords, const QList<ChangeLogRecord >& ownRecords );
 
79
        
 
80
        /**
 
81
         * Same as multiple Cardinality resolution, but a lot faster. It figures out which statement
 
82
         * should be present by looking at the max time stamp.
 
83
         */
 
84
        void resolveSingleCardinality( const QList< Nepomuk::ChangeLogRecord >& theirRecords, const QList< Nepomuk::ChangeLogRecord >& ownRecords );
 
85
    };
 
86
 
 
87
}
 
88
#endif // CHANGELOGMERGER_H