diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-18 12:44:12 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-21 09:18:49 +0200 |
commit | 71a0167e0216f84588b492c84e92667847fbe5a5 (patch) | |
tree | 016718fe0ab13359e9738b9ddbf2450b05bb4603 /common/storage | |
parent | 2a9c738b813133d398683596df6d41d355e3cb3b (diff) | |
download | sink-71a0167e0216f84588b492c84e92667847fbe5a5.tar.gz sink-71a0167e0216f84588b492c84e92667847fbe5a5.zip |
Use the ApplicationDomainType in the queries as well.
We have to access properties, so we need the mapper anyways, and the
ApplicationDomainType type shouldn't be a large overhead anyways.
Diffstat (limited to 'common/storage')
-rw-r--r-- | common/storage/entitystore.cpp | 9 | ||||
-rw-r--r-- | common/storage/entitystore.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 9615eca..fe63f0b 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -184,6 +184,15 @@ void EntityStore::readLatest(const QByteArray &type, const QByteArray &uid, cons | |||
184 | }); | 184 | }); |
185 | } | 185 | } |
186 | 186 | ||
187 | void EntityStore::readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomain::ApplicationDomainType &, Sink::Operation)> callback) | ||
188 | { | ||
189 | readLatest(type, uid, [&](const QByteArray &uid, const EntityBuffer &buffer) { | ||
190 | auto adaptor = d->resourceContext.adaptorFactory(type).createAdaptor(buffer.entity()); | ||
191 | //TODO cache max revision for the duration of the transaction. | ||
192 | callback(ApplicationDomain::ApplicationDomainType{d->resourceContext.instanceId(), uid, DataStore::maxRevision(d->getTransaction()), adaptor}, buffer.operation()); | ||
193 | }); | ||
194 | } | ||
195 | |||
187 | ApplicationDomain::ApplicationDomainType EntityStore::readLatest(const QByteArray &type, const QByteArray &uid) | 196 | ApplicationDomain::ApplicationDomainType EntityStore::readLatest(const QByteArray &type, const QByteArray &uid) |
188 | { | 197 | { |
189 | ApplicationDomain::ApplicationDomainType dt; | 198 | ApplicationDomain::ApplicationDomainType dt; |
diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index de29e87..455e9c3 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "query.h" | 26 | #include "query.h" |
27 | #include "storage.h" | 27 | #include "storage.h" |
28 | #include "resourcecontext.h" | 28 | #include "resourcecontext.h" |
29 | #include "metadata_generated.h" | ||
29 | 30 | ||
30 | namespace Sink { | 31 | namespace Sink { |
31 | class EntityBuffer; | 32 | class EntityBuffer; |
@@ -56,6 +57,7 @@ public: | |||
56 | 57 | ||
57 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); | 58 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const QByteArray &uid, const EntityBuffer &entity)> callback); |
58 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomain::ApplicationDomainType &entity)> callback); | 59 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomain::ApplicationDomainType &entity)> callback); |
60 | void readLatest(const QByteArray &type, const QByteArray &uid, const std::function<void(const ApplicationDomain::ApplicationDomainType &entity, Sink::Operation)> callback); | ||
59 | 61 | ||
60 | ApplicationDomain::ApplicationDomainType readLatest(const QByteArray &type, const QByteArray &uid); | 62 | ApplicationDomain::ApplicationDomainType readLatest(const QByteArray &type, const QByteArray &uid); |
61 | 63 | ||