diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-05 14:21:48 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-01-05 14:21:48 +0100 |
commit | 889bda7e1d885498813ec03c16d84cb052c604b4 (patch) | |
tree | 92eba0b4c9b6af67244adeae83781c124c4e96af | |
parent | 3ab66dd16323d8e25e7322dce0fc0cbe9eae7685 (diff) | |
download | sink-889bda7e1d885498813ec03c16d84cb052c604b4.tar.gz sink-889bda7e1d885498813ec03c16d84cb052c604b4.zip |
Remove resources and identities with the account
-rw-r--r-- | common/resourcefacade.cpp | 15 | ||||
-rw-r--r-- | common/resourcefacade.h | 1 |
2 files changed, 16 insertions, 0 deletions
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp index 1c6b0c8..091970c 100644 --- a/common/resourcefacade.cpp +++ b/common/resourcefacade.cpp | |||
@@ -376,6 +376,21 @@ QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename ApplicationDomain | |||
376 | return qMakePair(KAsync::null<void>(), runner->emitter()); | 376 | return qMakePair(KAsync::null<void>(), runner->emitter()); |
377 | } | 377 | } |
378 | 378 | ||
379 | KAsync::Job<void> AccountFacade::remove(const Sink::ApplicationDomain::SinkAccount &account) | ||
380 | { | ||
381 | using namespace Sink::ApplicationDomain; | ||
382 | auto job = KAsync::null(); | ||
383 | |||
384 | //Remove all resources | ||
385 | job = job.then(Store::fetch<SinkResource>(Sink::Query{}.filter<SinkResource::Account>(account))) | ||
386 | .each([] (const SinkResource::Ptr &resource) { return Store::remove(*resource); }); | ||
387 | //Remove all identities | ||
388 | job = job.then(Store::fetch<Identity>(Sink::Query{}.filter<Identity::Account>(account))) | ||
389 | .each([] (const Identity::Ptr &identity) { return Store::remove(*identity); }); | ||
390 | |||
391 | return job.then(LocalStorageFacade<Sink::ApplicationDomain::SinkAccount>::remove(account)); | ||
392 | } | ||
393 | |||
379 | IdentityFacade::IdentityFacade() : LocalStorageFacade<Sink::ApplicationDomain::Identity>("identities", "type") | 394 | IdentityFacade::IdentityFacade() : LocalStorageFacade<Sink::ApplicationDomain::Identity>("identities", "type") |
380 | { | 395 | { |
381 | } | 396 | } |
diff --git a/common/resourcefacade.h b/common/resourcefacade.h index 509b37a..f72132d 100644 --- a/common/resourcefacade.h +++ b/common/resourcefacade.h | |||
@@ -108,6 +108,7 @@ class AccountFacade : public LocalStorageFacade<Sink::ApplicationDomain::SinkAcc | |||
108 | public: | 108 | public: |
109 | AccountFacade(); | 109 | AccountFacade(); |
110 | virtual ~AccountFacade(); | 110 | virtual ~AccountFacade(); |
111 | virtual KAsync::Job<void> remove(const Sink::ApplicationDomain::SinkAccount &resource) Q_DECL_OVERRIDE; | ||
111 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename Sink::ApplicationDomain::SinkAccount::Ptr>::Ptr> load(const Sink::Query &query, const Sink::Log::Context &) Q_DECL_OVERRIDE; | 112 | virtual QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename Sink::ApplicationDomain::SinkAccount::Ptr>::Ptr> load(const Sink::Query &query, const Sink::Log::Context &) Q_DECL_OVERRIDE; |
112 | }; | 113 | }; |
113 | 114 | ||