From 5bf7ded65ef517fac6b088342d195392bc09be4c Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 11 Apr 2017 15:41:20 +0200 Subject: Moved all preprocessing back into the pipeline --- common/pipeline.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'common/pipeline.cpp') diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 15ed5fc..91437d4 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -175,13 +175,14 @@ KAsync::Job Pipeline::newEntity(void const *command, size_t size) auto o = Sink::ApplicationDomain::ApplicationDomainType{d->resourceContext.instanceId(), key, revision, memoryAdaptor}; o.setChangedProperties(o.availableProperties().toSet()); - auto preprocess = [&, this](ApplicationDomain::ApplicationDomainType &newEntity) { - foreach (const auto &processor, d->processors[bufferType]) { - processor->newEntity(newEntity); - } - }; + auto newEntity = *ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation(o, o.availableProperties()); + newEntity.setChangedProperties(newEntity.availableProperties().toSet()); + + foreach (const auto &processor, d->processors[bufferType]) { + processor->newEntity(newEntity); + } - if (!d->entityStore.add(bufferType, o, replayToSource, preprocess)) { + if (!d->entityStore.add(bufferType, o, replayToSource)) { return KAsync::error(0); } @@ -323,14 +324,14 @@ KAsync::Job Pipeline::deletedEntity(void const *command, size_t size) const QByteArray key = QByteArray(reinterpret_cast(deleteEntity->entityId()->Data()), deleteEntity->entityId()->size()); SinkTraceCtx(d->logCtx) << "Deleted Entity. Type: " << bufferType << "uid: "<< key << " replayToSource: " << replayToSource; - auto preprocess = [&, this](const ApplicationDomain::ApplicationDomainType &oldEntity) { - foreach (const auto &processor, d->processors[bufferType]) { - processor->deletedEntity(oldEntity); - } - }; + const auto current = d->entityStore.readLatest(bufferType, key); + + foreach (const auto &processor, d->processors[bufferType]) { + processor->deletedEntity(current); + } d->revisionChanged = true; - if (!d->entityStore.remove(bufferType, key, replayToSource, preprocess)) { + if (!d->entityStore.remove(bufferType, current, replayToSource)) { return KAsync::error(0); } -- cgit v1.2.3