diff options
Diffstat (limited to 'common/pipeline.cpp')
-rw-r--r-- | common/pipeline.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 8ace855..b94e3f0 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -249,6 +249,7 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
249 | } | 249 | } |
250 | 250 | ||
251 | if (modifyEntity->targetResource()) { | 251 | if (modifyEntity->targetResource()) { |
252 | auto isMove = modifyEntity->removeEntity(); | ||
252 | auto targetResource = BufferUtils::extractBuffer(modifyEntity->targetResource()); | 253 | auto targetResource = BufferUtils::extractBuffer(modifyEntity->targetResource()); |
253 | auto changeset = diff.changedProperties(); | 254 | auto changeset = diff.changedProperties(); |
254 | const auto current = d->entityStore.readLatest(bufferType, diff.identifier()); | 255 | const auto current = d->entityStore.readLatest(bufferType, diff.identifier()); |
@@ -276,9 +277,20 @@ KAsync::Job<qint64> Pipeline::modifiedEntity(void const *command, size_t size) | |||
276 | 277 | ||
277 | SinkTrace() << "Moving entity to new resource " << newEntity.identifier() << newEntity.resourceInstanceIdentifier() << targetResource; | 278 | 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 | auto job = TypeHelper<CreateHelper>{bufferType}.operator()<KAsync::Job<void>, ApplicationDomain::ApplicationDomainType&>(newEntity); |
279 | job = job.syncThen<void>([=](const KAsync::Error &error) { | 280 | job = job.syncThen<void>([this, newEntity, isMove, targetResource, bufferType](const KAsync::Error &error) { |
280 | if (!error) { | 281 | if (!error) { |
281 | SinkTrace() << "Move of " << newEntity.identifier() << "was successfull"; | 282 | SinkTrace() << "Move of " << newEntity.identifier() << "was successfull"; |
283 | if (isMove) { | ||
284 | startTransaction(); | ||
285 | flatbuffers::FlatBufferBuilder fbb; | ||
286 | auto entityId = fbb.CreateString(newEntity.identifier()); | ||
287 | auto type = fbb.CreateString(bufferType); | ||
288 | auto location = Sink::Commands::CreateDeleteEntity(fbb, newEntity.revision(), entityId, type, true); | ||
289 | Sink::Commands::FinishDeleteEntityBuffer(fbb, location); | ||
290 | const auto data = BufferUtils::extractBuffer(fbb); | ||
291 | deletedEntity(data, data.size()).exec(); | ||
292 | commit(); | ||
293 | } | ||
282 | } else { | 294 | } else { |
283 | SinkError() << "Failed to move entity " << targetResource << " to resource " << newEntity.identifier(); | 295 | SinkError() << "Failed to move entity " << targetResource << " to resource " << newEntity.identifier(); |
284 | } | 296 | } |