summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-17 20:28:24 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-10-21 09:11:14 +0200
commit9e1850071a471ce275194f3882054694cea798e7 (patch)
treeb62b2b3de4e6efbadf0129f4afdbda296ae38eb8
parent237b9ae4113e7a9f489632296941becb71afdb45 (diff)
downloadsink-9e1850071a471ce275194f3882054694cea798e7.tar.gz
sink-9e1850071a471ce275194f3882054694cea798e7.zip
Removed the now obsolete EntityStore
-rw-r--r--common/CMakeLists.txt1
-rw-r--r--common/entitystore.cpp29
-rw-r--r--common/entitystore.h61
-rw-r--r--common/sourcewriteback.cpp13
-rw-r--r--common/sourcewriteback.h5
-rw-r--r--common/synchronizer.cpp1
-rw-r--r--common/synchronizer.h1
-rw-r--r--examples/imapresource/imapresource.cpp1
8 files changed, 6 insertions, 106 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index e1e7a51..fd8e898 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -69,7 +69,6 @@ set(command_SRCS
69 changereplay.cpp 69 changereplay.cpp
70 adaptorfactoryregistry.cpp 70 adaptorfactoryregistry.cpp
71 synchronizer.cpp 71 synchronizer.cpp
72 entitystore.cpp
73 remoteidmap.cpp 72 remoteidmap.cpp
74 sourcewriteback.cpp 73 sourcewriteback.cpp
75 entityreader.cpp 74 entityreader.cpp
diff --git a/common/entitystore.cpp b/common/entitystore.cpp
deleted file mode 100644
index b7b03aa..0000000
--- a/common/entitystore.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
1/*
2 * Copyright (C) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20#include "entitystore.h"
21
22using namespace Sink;
23
24EntityStore::EntityStore(Storage::EntityStore &store_)
25 : store(store_)
26{
27
28}
29
diff --git a/common/entitystore.h b/common/entitystore.h
deleted file mode 100644
index 3d9ca36..0000000
--- a/common/entitystore.h
+++ /dev/null
@@ -1,61 +0,0 @@
1/*
2 * Copyright (C) 2016 Christian Mollekopf <mollekopf@kolabsys.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20#pragma once
21
22#include "sink_export.h"
23
24#include "storage/entitystore.h"
25
26namespace Sink {
27
28class SINK_EXPORT EntityStore
29{
30public:
31 EntityStore(Storage::EntityStore &store);
32
33 template<typename T>
34 T read(const QByteArray &identifier) const
35 {
36 return store.readLatest<T>(identifier);
37 }
38
39 template<typename T>
40 T readFromKey(const QByteArray &key) const
41 {
42 return store.readEntity<T>(key);
43 }
44
45 template<typename T>
46 T readPrevious(const QByteArray &uid, qint64 revision) const
47 {
48 return store.readPrevious<T>(uid, revision);
49 }
50
51 /* template<typename T> */
52 /* EntityReader<T> reader() */
53 /* { */
54 /* return EntityReader<T>(mResourceType, mResourceInstanceIdentifier, mTransaction); */
55 /* } */
56
57private:
58 Sink::Storage::EntityStore &store;
59};
60
61}
diff --git a/common/sourcewriteback.cpp b/common/sourcewriteback.cpp
index 204793e..e2994d1 100644
--- a/common/sourcewriteback.cpp
+++ b/common/sourcewriteback.cpp
@@ -41,12 +41,9 @@ SourceWriteBack::SourceWriteBack(const ResourceContext &context)
41 41
42} 42}
43 43
44EntityStore &SourceWriteBack::store() 44Storage::EntityStore &SourceWriteBack::store()
45{ 45{
46 if (!mEntityStoreWrapper) { 46 return *mEntityStore;
47 mEntityStoreWrapper = QSharedPointer<EntityStore>::create(*mEntityStore);
48 }
49 return *mEntityStoreWrapper;
50} 47}
51 48
52RemoteIdMap &SourceWriteBack::syncStore() 49RemoteIdMap &SourceWriteBack::syncStore()
@@ -78,7 +75,6 @@ KAsync::Job<void> SourceWriteBack::replay(const QByteArray &type, const QByteArr
78 const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata()); 75 const auto metadataBuffer = Sink::EntityBuffer::readBuffer<Sink::Metadata>(entity.metadata());
79 Q_ASSERT(metadataBuffer); 76 Q_ASSERT(metadataBuffer);
80 Q_ASSERT(!mSyncStore); 77 Q_ASSERT(!mSyncStore);
81 Q_ASSERT(!mEntityStoreWrapper);
82 Q_ASSERT(!mSyncTransaction); 78 Q_ASSERT(!mSyncTransaction);
83 mEntityStore->startTransaction(Storage::DataStore::ReadOnly); 79 mEntityStore->startTransaction(Storage::DataStore::ReadOnly);
84 mSyncTransaction = mSyncStorage.createTransaction(Sink::Storage::DataStore::ReadWrite); 80 mSyncTransaction = mSyncStorage.createTransaction(Sink::Storage::DataStore::ReadWrite);
@@ -100,10 +96,10 @@ KAsync::Job<void> SourceWriteBack::replay(const QByteArray &type, const QByteArr
100 96
101 KAsync::Job<QByteArray> job = KAsync::null<QByteArray>(); 97 KAsync::Job<QByteArray> job = KAsync::null<QByteArray>();
102 if (type == ENTITY_TYPE_FOLDER) { 98 if (type == ENTITY_TYPE_FOLDER) {
103 auto folder = store().readFromKey<ApplicationDomain::Folder>(key); 99 auto folder = store().readEntity<ApplicationDomain::Folder>(key);
104 job = replay(folder, operation, oldRemoteId, modifiedProperties); 100 job = replay(folder, operation, oldRemoteId, modifiedProperties);
105 } else if (type == ENTITY_TYPE_MAIL) { 101 } else if (type == ENTITY_TYPE_MAIL) {
106 auto mail = store().readFromKey<ApplicationDomain::Mail>(key); 102 auto mail = store().readEntity<ApplicationDomain::Mail>(key);
107 job = replay(mail, operation, oldRemoteId, modifiedProperties); 103 job = replay(mail, operation, oldRemoteId, modifiedProperties);
108 } 104 }
109 105
@@ -134,7 +130,6 @@ KAsync::Job<void> SourceWriteBack::replay(const QByteArray &type, const QByteArr
134 SinkWarning() << "Failed to replay change: " << error.errorMessage; 130 SinkWarning() << "Failed to replay change: " << error.errorMessage;
135 } 131 }
136 mSyncStore.clear(); 132 mSyncStore.clear();
137 mEntityStoreWrapper.clear();
138 mSyncTransaction.commit(); 133 mSyncTransaction.commit();
139 mEntityStore->abortTransaction(); 134 mEntityStore->abortTransaction();
140 }); 135 });
diff --git a/common/sourcewriteback.h b/common/sourcewriteback.h
index 327d1ad..cf393e4 100644
--- a/common/sourcewriteback.h
+++ b/common/sourcewriteback.h
@@ -23,7 +23,7 @@
23 23
24#include "changereplay.h" 24#include "changereplay.h"
25#include "storage.h" 25#include "storage.h"
26#include "entitystore.h" 26#include "storage/entitystore.h"
27#include "remoteidmap.h" 27#include "remoteidmap.h"
28#include "metadata_generated.h" 28#include "metadata_generated.h"
29 29
@@ -58,12 +58,11 @@ protected:
58 58
59private: 59private:
60 //Read only access to main storage 60 //Read only access to main storage
61 EntityStore &store(); 61 Storage::EntityStore &store();
62 ResourceContext mResourceContext; 62 ResourceContext mResourceContext;
63 Sink::Storage::DataStore mSyncStorage; 63 Sink::Storage::DataStore mSyncStorage;
64 QSharedPointer<RemoteIdMap> mSyncStore; 64 QSharedPointer<RemoteIdMap> mSyncStore;
65 QSharedPointer<Storage::EntityStore> mEntityStore; 65 QSharedPointer<Storage::EntityStore> mEntityStore;
66 QSharedPointer<EntityStore> mEntityStoreWrapper;
67 Sink::Storage::DataStore::Transaction mSyncTransaction; 66 Sink::Storage::DataStore::Transaction mSyncTransaction;
68 QByteArray mResourceType; 67 QByteArray mResourceType;
69 QByteArray mResourceInstanceIdentifier; 68 QByteArray mResourceInstanceIdentifier;
diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp
index 5ddd77c..9bba9cf 100644
--- a/common/synchronizer.cpp
+++ b/common/synchronizer.cpp
@@ -22,7 +22,6 @@
22#include "definitions.h" 22#include "definitions.h"
23#include "commands.h" 23#include "commands.h"
24#include "bufferutils.h" 24#include "bufferutils.h"
25#include "entitystore.h"
26#include "remoteidmap.h" 25#include "remoteidmap.h"
27#include "entityreader.h" 26#include "entityreader.h"
28#include "createentity_generated.h" 27#include "createentity_generated.h"
diff --git a/common/synchronizer.h b/common/synchronizer.h
index f3319f6..0a1efe1 100644
--- a/common/synchronizer.h
+++ b/common/synchronizer.h
@@ -28,7 +28,6 @@
28#include <storage.h> 28#include <storage.h>
29 29
30namespace Sink { 30namespace Sink {
31class EntityStore;
32class RemoteIdMap; 31class RemoteIdMap;
33 32
34/** 33/**
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp
index 0ea07bf..90dae7a 100644
--- a/examples/imapresource/imapresource.cpp
+++ b/examples/imapresource/imapresource.cpp
@@ -37,7 +37,6 @@
37#include "inspection.h" 37#include "inspection.h"
38#include "synchronizer.h" 38#include "synchronizer.h"
39#include "sourcewriteback.h" 39#include "sourcewriteback.h"
40#include "entitystore.h"
41#include "remoteidmap.h" 40#include "remoteidmap.h"
42#include "query.h" 41#include "query.h"
43 42