diff options
-rw-r--r-- | common/commands/modifyentity.fbs | 2 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 5 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 1 | ||||
-rw-r--r-- | common/facade.cpp | 14 | ||||
-rw-r--r-- | common/facade.h | 1 | ||||
-rw-r--r-- | common/facadeinterface.h | 12 | ||||
-rw-r--r-- | common/pipeline.cpp | 48 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 7 | ||||
-rw-r--r-- | common/resourceaccess.h | 4 | ||||
-rw-r--r-- | common/resourcefacade.cpp | 6 | ||||
-rw-r--r-- | common/resourcefacade.h | 1 | ||||
-rw-r--r-- | common/store.cpp | 10 | ||||
-rw-r--r-- | common/store.h | 6 | ||||
-rw-r--r-- | common/test.cpp | 5 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/clientapitest.cpp | 4 |
16 files changed, 120 insertions, 7 deletions
diff --git a/common/commands/modifyentity.fbs b/common/commands/modifyentity.fbs index da6f0e2..d81bacf 100644 --- a/common/commands/modifyentity.fbs +++ b/common/commands/modifyentity.fbs | |||
@@ -8,6 +8,8 @@ table ModifyEntity { | |||
8 | delta: [ubyte]; //Contains an entity buffer with all changed properties set | 8 | delta: [ubyte]; //Contains an entity buffer with all changed properties set |
9 | replayToSource: bool = true; | 9 | replayToSource: bool = true; |
10 | modifiedProperties: [string]; | 10 | modifiedProperties: [string]; |
11 | targetResource: string; //Contains the target resource for a move/copy operation | ||
12 | removeEntity: bool = false; //This modification removes the entity | ||
11 | } | 13 | } |
12 | 14 | ||
13 | root_type ModifyEntity; | 15 | root_type ModifyEntity; |
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index b30eb36..105ae56 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -98,6 +98,11 @@ void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &v | |||
98 | mAdaptor->setProperty(key, value); | 98 | mAdaptor->setProperty(key, value); |
99 | } | 99 | } |
100 | 100 | ||
101 | void ApplicationDomainType::setResource(const QByteArray &identifier) | ||
102 | { | ||
103 | mResourceInstanceIdentifier = identifier; | ||
104 | } | ||
105 | |||
101 | void ApplicationDomainType::setProperty(const QByteArray &key, const ApplicationDomainType &value) | 106 | void ApplicationDomainType::setProperty(const QByteArray &key, const ApplicationDomainType &value) |
102 | { | 107 | { |
103 | Q_ASSERT(!value.identifier().isEmpty()); | 108 | Q_ASSERT(!value.identifier().isEmpty()); |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 4621316..d6bbdd4 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -168,6 +168,7 @@ public: | |||
168 | QByteArrayList availableProperties() const; | 168 | QByteArrayList availableProperties() const; |
169 | qint64 revision() const; | 169 | qint64 revision() const; |
170 | QByteArray resourceInstanceIdentifier() const; | 170 | QByteArray resourceInstanceIdentifier() const; |
171 | void setResource(const QByteArray &identifier); | ||
171 | QByteArray identifier() const; | 172 | QByteArray identifier() const; |
172 | 173 | ||
173 | private: | 174 | private: |
diff --git a/common/facade.cpp b/common/facade.cpp index 3ec58e3..c618d4e 100644 --- a/common/facade.cpp +++ b/common/facade.cpp | |||
@@ -68,7 +68,19 @@ KAsync::Job<void> GenericFacade<DomainType>::modify(const DomainType &domainObje | |||
68 | SinkWarning() << "No domain type adaptor factory available"; | 68 | SinkWarning() << "No domain type adaptor factory available"; |
69 | return KAsync::error<void>(); | 69 | return KAsync::error<void>(); |
70 | } | 70 | } |
71 | return mResourceAccess->sendModifyCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType(), QByteArrayList(), BufferUtils::extractBuffer(entityFbb), domainObject.changedProperties()); | 71 | return mResourceAccess->sendModifyCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType(), QByteArrayList(), BufferUtils::extractBuffer(entityFbb), domainObject.changedProperties(), QByteArray(), false); |
72 | } | ||
73 | |||
74 | template <class DomainType> | ||
75 | KAsync::Job<void> GenericFacade<DomainType>::move(const DomainType &domainObject, const QByteArray &newResource) | ||
76 | { | ||
77 | SinkTrace() << "Moving entity: " << domainObject.identifier() << domainObject.changedProperties() << newResource; | ||
78 | flatbuffers::FlatBufferBuilder entityFbb; | ||
79 | if (!mResourceContext.adaptorFactory<DomainType>().createBuffer(domainObject, entityFbb)) { | ||
80 | SinkWarning() << "No domain type adaptor factory available"; | ||
81 | return KAsync::error<void>(); | ||
82 | } | ||
83 | return mResourceAccess->sendModifyCommand(domainObject.identifier(), domainObject.revision(), bufferTypeForDomainType(), QByteArrayList(), BufferUtils::extractBuffer(entityFbb), domainObject.changedProperties(), newResource, false); | ||
72 | } | 84 | } |
73 | 85 | ||
74 | template <class DomainType> | 86 | template <class DomainType> |
diff --git a/common/facade.h b/common/facade.h index 50d93e0..0fba34a 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -63,6 +63,7 @@ public: | |||
63 | static QByteArray bufferTypeForDomainType(); | 63 | static QByteArray bufferTypeForDomainType(); |
64 | KAsync::Job<void> create(const DomainType &domainObject) Q_DECL_OVERRIDE; | 64 | KAsync::Job<void> create(const DomainType &domainObject) Q_DECL_OVERRIDE; |
65 | KAsync::Job<void> modify(const DomainType &domainObject) Q_DECL_OVERRIDE; | 65 | KAsync::Job<void> modify(const DomainType &domainObject) Q_DECL_OVERRIDE; |
66 | KAsync::Job<void> move(const DomainType &domainObject, const QByteArray &newResource) Q_DECL_OVERRIDE; | ||
66 | KAsync::Job<void> remove(const DomainType &domainObject) Q_DECL_OVERRIDE; | 67 | KAsync::Job<void> remove(const DomainType &domainObject) Q_DECL_OVERRIDE; |
67 | virtual QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; | 68 | virtual QPair<KAsync::Job<void>, typename ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; |
68 | 69 | ||
diff --git a/common/facadeinterface.h b/common/facadeinterface.h index 7d5dd7d..136791e 100644 --- a/common/facadeinterface.h +++ b/common/facadeinterface.h | |||
@@ -63,6 +63,13 @@ public: | |||
63 | virtual KAsync::Job<void> modify(const DomainType &domainObject) = 0; | 63 | virtual KAsync::Job<void> modify(const DomainType &domainObject) = 0; |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * Move an entity to a new resource. | ||
67 | * | ||
68 | * The job returns succefully once the task has been successfully placed in the queue | ||
69 | */ | ||
70 | virtual KAsync::Job<void> move(const DomainType &domainObject, const QByteArray &newResource) = 0; | ||
71 | |||
72 | /** | ||
66 | * Remove an entity from the store. | 73 | * Remove an entity from the store. |
67 | * | 74 | * |
68 | * The job returns succefully once the task has been successfully placed in the queue | 75 | * The job returns succefully once the task has been successfully placed in the queue |
@@ -90,6 +97,11 @@ public: | |||
90 | return KAsync::error<void>(-1, "Failed to create a facade"); | 97 | return KAsync::error<void>(-1, "Failed to create a facade"); |
91 | } | 98 | } |
92 | 99 | ||
100 | KAsync::Job<void> move(const DomainType &domainObject, const QByteArray &newResource) | ||
101 | { | ||
102 | return KAsync::error<void>(-1, "Failed to create a facade"); | ||
103 | } | ||
104 | |||
93 | KAsync::Job<void> remove(const DomainType &domainObject) | 105 | KAsync::Job<void> remove(const DomainType &domainObject) |
94 | { | 106 | { |
95 | return KAsync::error<void>(-1, "Failed to create a facade"); | 107 | return KAsync::error<void>(-1, "Failed to create a facade"); |
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 1eea631..8ace855 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -34,10 +34,12 @@ | |||
34 | #include "entitybuffer.h" | 34 | #include "entitybuffer.h" |
35 | #include "log.h" | 35 | #include "log.h" |
36 | #include "domain/applicationdomaintype.h" | 36 | #include "domain/applicationdomaintype.h" |
37 | #include "domain/applicationdomaintype_p.h" | ||
37 | #include "adaptorfactoryregistry.h" | 38 | #include "adaptorfactoryregistry.h" |
38 | #include "definitions.h" | 39 | #include "definitions.h" |
39 | #include "bufferutils.h" | 40 | #include "bufferutils.h" |
40 | #include "storage/entitystore.h" | 41 | #include "storage/entitystore.h" |
42 | #include "store.h" | ||
41 | 43 | ||
42 | SINK_DEBUG_AREA("pipeline") | 44 | SINK_DEBUG_AREA("pipeline") |
43 | 45 | ||
@@ -186,6 +188,13 @@ KAsync::Job<qint64> Pipeline::newEntity(void const *command, size_t size) | |||
186 | return KAsync::value(d->entityStore.maxRevision()); | 188 | return KAsync::value(d->entityStore.maxRevision()); |
187 | } | 189 | } |
188 | 190 | ||
191 | template <class T> | ||
192 | struct CreateHelper { | ||
193 | KAsync::Job<void> operator()(const ApplicationDomain::ApplicationDomainType &arg) const { | ||
194 | return Sink::Store::create<T>(arg); | ||
195 | } | ||
196 | }; | ||
197 | |||
189 | KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | 198 | KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) |
190 | { | 199 | { |
191 | d->transactionItemCount++; | 200 | d->transactionItemCount++; |
@@ -239,6 +248,45 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
239 | deletions = BufferUtils::fromVector(*modifyEntity->deletions()); | 248 | deletions = BufferUtils::fromVector(*modifyEntity->deletions()); |
240 | } | 249 | } |
241 | 250 | ||
251 | if (modifyEntity->targetResource()) { | ||
252 | auto targetResource = BufferUtils::extractBuffer(modifyEntity->targetResource()); | ||
253 | auto changeset = diff.changedProperties(); | ||
254 | const auto current = d->entityStore.readLatest(bufferType, diff.identifier()); | ||
255 | if (current.identifier().isEmpty()) { | ||
256 | SinkWarning() << "Failed to read current version: " << diff.identifier(); | ||
257 | return KAsync::error<qint64>(0); | ||
258 | } | ||
259 | |||
260 | auto newEntity = *ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<ApplicationDomain::ApplicationDomainType>(current, current.availableProperties()); | ||
261 | |||
262 | // Apply diff | ||
263 | for (const auto &property : changeset) { | ||
264 | const auto value = diff.getProperty(property); | ||
265 | if (value.isValid()) { | ||
266 | newEntity.setProperty(property, value); | ||
267 | } | ||
268 | } | ||
269 | |||
270 | // Remove deletions | ||
271 | for (const auto property : deletions) { | ||
272 | newEntity.setProperty(property, QVariant()); | ||
273 | } | ||
274 | newEntity.setResource(targetResource); | ||
275 | newEntity.setChangedProperties(newEntity.availableProperties().toSet()); | ||
276 | |||
277 | SinkTrace() << "Moving entity to new resource " << newEntity.identifier() << newEntity.resourceInstanceIdentifier() << targetResource; | ||
278 | auto job = TypeHelper<CreateHelper>{bufferType}.operator()<KAsync::Job<void>, ApplicationDomain::ApplicationDomainType&>(newEntity); | ||
279 | job = job.syncThen<void>([=](const KAsync::Error &error) { | ||
280 | if (!error) { | ||
281 | SinkTrace() << "Move of " << newEntity.identifier() << "was successfull"; | ||
282 | } else { | ||
283 | SinkError() << "Failed to move entity " << targetResource << " to resource " << newEntity.identifier(); | ||
284 | } | ||
285 | }); | ||
286 | job.exec(); | ||
287 | return KAsync::value<qint64>(0); | ||
288 | } | ||
289 | |||
242 | auto preprocess = [&, this](const ApplicationDomain::ApplicationDomainType &oldEntity, ApplicationDomain::ApplicationDomainType &newEntity) { | 290 | auto preprocess = [&, this](const ApplicationDomain::ApplicationDomainType &oldEntity, ApplicationDomain::ApplicationDomainType &newEntity) { |
243 | foreach (const auto &processor, d->processors[bufferType]) { | 291 | foreach (const auto &processor, d->processors[bufferType]) { |
244 | processor->modifiedEntity(oldEntity, newEntity); | 292 | processor->modifiedEntity(oldEntity, newEntity); |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index b46e8b2..81715e5 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -323,16 +323,16 @@ KAsync::Job<void> ResourceAccess::sendCreateCommand(const QByteArray &uid, const | |||
323 | } | 323 | } |
324 | 324 | ||
325 | KAsync::Job<void> | 325 | KAsync::Job<void> |
326 | ResourceAccess::sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer, const QByteArrayList &changedProperties) | 326 | ResourceAccess::sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer, const QByteArrayList &changedProperties, const QByteArray &newResource, bool remove) |
327 | { | 327 | { |
328 | flatbuffers::FlatBufferBuilder fbb; | 328 | flatbuffers::FlatBufferBuilder fbb; |
329 | auto entityId = fbb.CreateString(uid.constData()); | 329 | auto entityId = fbb.CreateString(uid.constData()); |
330 | // This is the resource buffer type and not the domain type | ||
331 | auto type = fbb.CreateString(resourceBufferType.constData()); | 330 | auto type = fbb.CreateString(resourceBufferType.constData()); |
332 | auto modifiedProperties = BufferUtils::toVector(fbb, changedProperties); | 331 | auto modifiedProperties = BufferUtils::toVector(fbb, changedProperties); |
333 | auto deletions = BufferUtils::toVector(fbb, deletedProperties); | 332 | auto deletions = BufferUtils::toVector(fbb, deletedProperties); |
334 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); | 333 | auto delta = Sink::EntityBuffer::appendAsVector(fbb, buffer.constData(), buffer.size()); |
335 | auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta, true, modifiedProperties); | 334 | auto resource = newResource.isEmpty() ? 0 : fbb.CreateString(newResource.constData()); |
335 | auto location = Sink::Commands::CreateModifyEntity(fbb, revision, entityId, deletions, type, delta, true, modifiedProperties, resource, remove); | ||
336 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); | 336 | Sink::Commands::FinishModifyEntityBuffer(fbb, location); |
337 | open(); | 337 | open(); |
338 | return sendCommand(Sink::Commands::ModifyEntityCommand, fbb); | 338 | return sendCommand(Sink::Commands::ModifyEntityCommand, fbb); |
@@ -342,7 +342,6 @@ KAsync::Job<void> ResourceAccess::sendDeleteCommand(const QByteArray &uid, qint6 | |||
342 | { | 342 | { |
343 | flatbuffers::FlatBufferBuilder fbb; | 343 | flatbuffers::FlatBufferBuilder fbb; |
344 | auto entityId = fbb.CreateString(uid.constData()); | 344 | auto entityId = fbb.CreateString(uid.constData()); |
345 | // This is the resource buffer type and not the domain type | ||
346 | auto type = fbb.CreateString(resourceBufferType.constData()); | 345 | auto type = fbb.CreateString(resourceBufferType.constData()); |
347 | auto location = Sink::Commands::CreateDeleteEntity(fbb, revision, entityId, type); | 346 | auto location = Sink::Commands::CreateDeleteEntity(fbb, revision, entityId, type); |
348 | Sink::Commands::FinishDeleteEntityBuffer(fbb, location); | 347 | Sink::Commands::FinishDeleteEntityBuffer(fbb, location); |
diff --git a/common/resourceaccess.h b/common/resourceaccess.h index 4229161..de15125 100644 --- a/common/resourceaccess.h +++ b/common/resourceaccess.h | |||
@@ -57,7 +57,7 @@ public: | |||
57 | { | 57 | { |
58 | return KAsync::null<void>(); | 58 | return KAsync::null<void>(); |
59 | }; | 59 | }; |
60 | virtual KAsync::Job<void> sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer, const QByteArrayList &changedProperties) | 60 | virtual KAsync::Job<void> sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer, const QByteArrayList &changedProperties, const QByteArray &newResource, bool remove) |
61 | { | 61 | { |
62 | return KAsync::null<void>(); | 62 | return KAsync::null<void>(); |
63 | }; | 63 | }; |
@@ -116,7 +116,7 @@ public: | |||
116 | KAsync::Job<void> synchronizeResource(const Sink::QueryBase &filter) Q_DECL_OVERRIDE; | 116 | KAsync::Job<void> synchronizeResource(const Sink::QueryBase &filter) Q_DECL_OVERRIDE; |
117 | KAsync::Job<void> sendCreateCommand(const QByteArray &uid, const QByteArray &resourceBufferType, const QByteArray &buffer) Q_DECL_OVERRIDE; | 117 | KAsync::Job<void> sendCreateCommand(const QByteArray &uid, const QByteArray &resourceBufferType, const QByteArray &buffer) Q_DECL_OVERRIDE; |
118 | KAsync::Job<void> | 118 | KAsync::Job<void> |
119 | sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer, const QByteArrayList &changedProperties) Q_DECL_OVERRIDE; | 119 | sendModifyCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType, const QByteArrayList &deletedProperties, const QByteArray &buffer, const QByteArrayList &changedProperties, const QByteArray &newResource, bool remove) Q_DECL_OVERRIDE; |
120 | KAsync::Job<void> sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) Q_DECL_OVERRIDE; | 120 | KAsync::Job<void> sendDeleteCommand(const QByteArray &uid, qint64 revision, const QByteArray &resourceBufferType) Q_DECL_OVERRIDE; |
121 | KAsync::Job<void> sendRevisionReplayedCommand(qint64 revision) Q_DECL_OVERRIDE; | 121 | KAsync::Job<void> sendRevisionReplayedCommand(qint64 revision) Q_DECL_OVERRIDE; |
122 | KAsync::Job<void> | 122 | KAsync::Job<void> |
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp index e5b4496..0a05bd9 100644 --- a/common/resourcefacade.cpp +++ b/common/resourcefacade.cpp | |||
@@ -219,6 +219,12 @@ KAsync::Job<void> LocalStorageFacade<DomainType>::modify(const DomainType &domai | |||
219 | } | 219 | } |
220 | 220 | ||
221 | template <typename DomainType> | 221 | template <typename DomainType> |
222 | KAsync::Job<void> LocalStorageFacade<DomainType>::move(const DomainType &, const QByteArray &) | ||
223 | { | ||
224 | return KAsync::error<void>(1, "Resources and Accounts cannot be moved."); | ||
225 | } | ||
226 | |||
227 | template <typename DomainType> | ||
222 | KAsync::Job<void> LocalStorageFacade<DomainType>::remove(const DomainType &domainObject) | 228 | KAsync::Job<void> LocalStorageFacade<DomainType>::remove(const DomainType &domainObject) |
223 | { | 229 | { |
224 | auto configStoreIdentifier = mIdentifier; | 230 | auto configStoreIdentifier = mIdentifier; |
diff --git a/common/resourcefacade.h b/common/resourcefacade.h index d259d4f..ea552c2 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h | |||
@@ -81,6 +81,7 @@ public: | |||
81 | virtual ~LocalStorageFacade(); | 81 | virtual ~LocalStorageFacade(); |
82 | virtual KAsync::Job<void> create(const DomainType &resource) Q_DECL_OVERRIDE; | 82 | virtual KAsync::Job<void> create(const DomainType &resource) Q_DECL_OVERRIDE; |
83 | virtual KAsync::Job<void> modify(const DomainType &resource) Q_DECL_OVERRIDE; | 83 | virtual KAsync::Job<void> modify(const DomainType &resource) Q_DECL_OVERRIDE; |
84 | virtual KAsync::Job<void> move(const DomainType &resource, const QByteArray &) Q_DECL_OVERRIDE; | ||
84 | virtual KAsync::Job<void> remove(const DomainType &resource) Q_DECL_OVERRIDE; | 85 | virtual KAsync::Job<void> remove(const DomainType &resource) Q_DECL_OVERRIDE; |
85 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; | 86 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename DomainType::Ptr>::Ptr> load(const Sink::Query &query) Q_DECL_OVERRIDE; |
86 | 87 | ||
diff --git a/common/store.cpp b/common/store.cpp index f91973d..fad8c5e 100644 --- a/common/store.cpp +++ b/common/store.cpp | |||
@@ -216,6 +216,15 @@ KAsync::Job<void> Store::modify(const DomainType &domainObject) | |||
216 | } | 216 | } |
217 | 217 | ||
218 | template <class DomainType> | 218 | template <class DomainType> |
219 | KAsync::Job<void> Store::move(const DomainType &domainObject, const QByteArray &newResource) | ||
220 | { | ||
221 | SinkTrace() << "Move: " << domainObject << newResource; | ||
222 | // Potentially move to separate thread as well | ||
223 | auto facade = getFacade<DomainType>(domainObject.resourceInstanceIdentifier()); | ||
224 | return facade->move(domainObject, newResource).addToContext(std::shared_ptr<void>(facade)).onError([](const KAsync::Error &error) { SinkWarning() << "Failed to move"; }); | ||
225 | } | ||
226 | |||
227 | template <class DomainType> | ||
219 | KAsync::Job<void> Store::remove(const DomainType &domainObject) | 228 | KAsync::Job<void> Store::remove(const DomainType &domainObject) |
220 | { | 229 | { |
221 | SinkTrace() << "Remove: " << domainObject; | 230 | SinkTrace() << "Remove: " << domainObject; |
@@ -386,6 +395,7 @@ QList<DomainType> Store::read(const Sink::Query &q) | |||
386 | template KAsync::Job<void> Store::remove<T>(const T &domainObject); \ | 395 | template KAsync::Job<void> Store::remove<T>(const T &domainObject); \ |
387 | template KAsync::Job<void> Store::create<T>(const T &domainObject); \ | 396 | template KAsync::Job<void> Store::create<T>(const T &domainObject); \ |
388 | template KAsync::Job<void> Store::modify<T>(const T &domainObject); \ | 397 | template KAsync::Job<void> Store::modify<T>(const T &domainObject); \ |
398 | template KAsync::Job<void> Store::move<T>(const T &domainObject, const QByteArray &newResource); \ | ||
389 | template QSharedPointer<QAbstractItemModel> Store::loadModel<T>(Query query); \ | 399 | template QSharedPointer<QAbstractItemModel> Store::loadModel<T>(Query query); \ |
390 | template KAsync::Job<T> Store::fetchOne<T>(const Query &); \ | 400 | template KAsync::Job<T> Store::fetchOne<T>(const Query &); \ |
391 | template KAsync::Job<QList<T::Ptr>> Store::fetchAll<T>(const Query &); \ | 401 | template KAsync::Job<QList<T::Ptr>> Store::fetchAll<T>(const Query &); \ |
diff --git a/common/store.h b/common/store.h index c9bd9cf..7c7d2fe 100644 --- a/common/store.h +++ b/common/store.h | |||
@@ -82,6 +82,12 @@ template <class DomainType> | |||
82 | KAsync::Job<void> SINK_EXPORT remove(const DomainType &domainObject); | 82 | KAsync::Job<void> SINK_EXPORT remove(const DomainType &domainObject); |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Move an entity to a new resource. | ||
86 | */ | ||
87 | template <class DomainType> | ||
88 | KAsync::Job<void> SINK_EXPORT move(const DomainType &domainObject, const QByteArray &newResource); | ||
89 | |||
90 | /** | ||
85 | * Synchronize data to local cache. | 91 | * Synchronize data to local cache. |
86 | */ | 92 | */ |
87 | KAsync::Job<void> SINK_EXPORT synchronize(const Sink::Query &query); | 93 | KAsync::Job<void> SINK_EXPORT synchronize(const Sink::Query &query); |
diff --git a/common/test.cpp b/common/test.cpp index 1a0d9bc..74c499c 100644 --- a/common/test.cpp +++ b/common/test.cpp | |||
@@ -125,6 +125,11 @@ public: | |||
125 | // mTestAccount->modifyEntity<T>(domainObject); | 125 | // mTestAccount->modifyEntity<T>(domainObject); |
126 | return KAsync::null<void>(); | 126 | return KAsync::null<void>(); |
127 | }; | 127 | }; |
128 | KAsync::Job<void> move(const T &domainObject, const QByteArray &newResource) Q_DECL_OVERRIDE | ||
129 | { | ||
130 | // mTestAccount->moveEntity<T>(domainObject, newResource); | ||
131 | return KAsync::null<void>(); | ||
132 | }; | ||
128 | KAsync::Job<void> remove(const T &domainObject) Q_DECL_OVERRIDE | 133 | KAsync::Job<void> remove(const T &domainObject) Q_DECL_OVERRIDE |
129 | { | 134 | { |
130 | //FIXME | 135 | //FIXME |
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f8fe3b3..a69fcb3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -47,6 +47,7 @@ auto_tests ( | |||
47 | accountstest | 47 | accountstest |
48 | testaccounttest | 48 | testaccounttest |
49 | dummyresourcemailtest | 49 | dummyresourcemailtest |
50 | interresourcemovetest | ||
50 | ) | 51 | ) |
51 | generate_flatbuffers(dummyresourcetest calendar) | 52 | generate_flatbuffers(dummyresourcetest calendar) |
52 | target_link_libraries(dummyresourcetest sink_resource_dummy) | 53 | target_link_libraries(dummyresourcetest sink_resource_dummy) |
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index ae9286c..71be514 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -41,6 +41,10 @@ public: | |||
41 | { | 41 | { |
42 | return KAsync::null<void>(); | 42 | return KAsync::null<void>(); |
43 | }; | 43 | }; |
44 | KAsync::Job<void> move(const T &domainObject, const QByteArray &) Q_DECL_OVERRIDE | ||
45 | { | ||
46 | return KAsync::null<void>(); | ||
47 | }; | ||
44 | KAsync::Job<void> remove(const T &domainObject) Q_DECL_OVERRIDE | 48 | KAsync::Job<void> remove(const T &domainObject) Q_DECL_OVERRIDE |
45 | { | 49 | { |
46 | return KAsync::null<void>(); | 50 | return KAsync::null<void>(); |