diff options
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r-- | common/storage/entitystore.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 3addf94..a1f6108 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -220,7 +220,9 @@ bool EntityStore::add(const QByteArray &type, ApplicationDomainType entity, bool | |||
220 | 220 | ||
221 | SinkTraceCtx(d->logCtx) << "New entity " << entity; | 221 | SinkTraceCtx(d->logCtx) << "New entity " << entity; |
222 | 222 | ||
223 | d->typeIndex(type).add(entity.identifier(), entity, d->transaction, d->resourceContext.instanceId()); | 223 | const auto identifier = Identifier::fromDisplayByteArray(entity.identifier()); |
224 | |||
225 | d->typeIndex(type).add(identifier, entity, d->transaction, d->resourceContext.instanceId()); | ||
224 | 226 | ||
225 | //The maxRevision may have changed meanwhile if the entity created sub-entities | 227 | //The maxRevision may have changed meanwhile if the entity created sub-entities |
226 | const qint64 newRevision = maxRevision() + 1; | 228 | const qint64 newRevision = maxRevision() + 1; |
@@ -237,7 +239,7 @@ bool EntityStore::add(const QByteArray &type, ApplicationDomainType entity, bool | |||
237 | flatbuffers::FlatBufferBuilder fbb; | 239 | flatbuffers::FlatBufferBuilder fbb; |
238 | d->resourceContext.adaptorFactory(type).createBuffer(entity, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); | 240 | d->resourceContext.adaptorFactory(type).createBuffer(entity, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); |
239 | 241 | ||
240 | const auto key = Key(Identifier::fromDisplayByteArray(entity.identifier()), newRevision); | 242 | const auto key = Key(identifier, newRevision); |
241 | 243 | ||
242 | DataStore::mainDatabase(d->transaction, type) | 244 | DataStore::mainDatabase(d->transaction, type) |
243 | .write(key.toInternalByteArray(), BufferUtils::extractBuffer(fbb), | 245 | .write(key.toInternalByteArray(), BufferUtils::extractBuffer(fbb), |
@@ -289,7 +291,8 @@ bool EntityStore::modify(const QByteArray &type, const ApplicationDomainType &cu | |||
289 | { | 291 | { |
290 | SinkTraceCtx(d->logCtx) << "Modified entity: " << newEntity; | 292 | SinkTraceCtx(d->logCtx) << "Modified entity: " << newEntity; |
291 | 293 | ||
292 | d->typeIndex(type).modify(newEntity.identifier(), current, newEntity, d->transaction, d->resourceContext.instanceId()); | 294 | const auto identifier = Identifier::fromDisplayByteArray(newEntity.identifier()); |
295 | d->typeIndex(type).modify(identifier, current, newEntity, d->transaction, d->resourceContext.instanceId()); | ||
293 | 296 | ||
294 | const qint64 newRevision = DataStore::maxRevision(d->transaction) + 1; | 297 | const qint64 newRevision = DataStore::maxRevision(d->transaction) + 1; |
295 | 298 | ||
@@ -313,7 +316,7 @@ bool EntityStore::modify(const QByteArray &type, const ApplicationDomainType &cu | |||
313 | flatbuffers::FlatBufferBuilder fbb; | 316 | flatbuffers::FlatBufferBuilder fbb; |
314 | d->resourceContext.adaptorFactory(type).createBuffer(newEntity, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); | 317 | d->resourceContext.adaptorFactory(type).createBuffer(newEntity, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); |
315 | 318 | ||
316 | const auto key = Key(Identifier::fromDisplayByteArray(newEntity.identifier()), newRevision); | 319 | const auto key = Key(identifier, newRevision); |
317 | 320 | ||
318 | DataStore::mainDatabase(d->transaction, type) | 321 | DataStore::mainDatabase(d->transaction, type) |
319 | .write(key.toInternalByteArray(), BufferUtils::extractBuffer(fbb), | 322 | .write(key.toInternalByteArray(), BufferUtils::extractBuffer(fbb), |
@@ -331,8 +334,8 @@ bool EntityStore::remove(const QByteArray &type, const ApplicationDomainType &cu | |||
331 | SinkWarningCtx(d->logCtx) << "Remove: Entity is already removed " << uid; | 334 | SinkWarningCtx(d->logCtx) << "Remove: Entity is already removed " << uid; |
332 | return false; | 335 | return false; |
333 | } | 336 | } |
334 | 337 | const auto identifier = Identifier::fromDisplayByteArray(uid); | |
335 | d->typeIndex(type).remove(current.identifier(), current, d->transaction, d->resourceContext.instanceId()); | 338 | d->typeIndex(type).remove(identifier, current, d->transaction, d->resourceContext.instanceId()); |
336 | 339 | ||
337 | SinkTraceCtx(d->logCtx) << "Removed entity " << current; | 340 | SinkTraceCtx(d->logCtx) << "Removed entity " << current; |
338 | 341 | ||
@@ -350,7 +353,7 @@ bool EntityStore::remove(const QByteArray &type, const ApplicationDomainType &cu | |||
350 | flatbuffers::FlatBufferBuilder fbb; | 353 | flatbuffers::FlatBufferBuilder fbb; |
351 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), 0, 0, 0, 0); | 354 | EntityBuffer::assembleEntityBuffer(fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize(), 0, 0, 0, 0); |
352 | 355 | ||
353 | const auto key = Key(Identifier::fromDisplayByteArray(uid), newRevision); | 356 | const auto key = Key(identifier, newRevision); |
354 | 357 | ||
355 | DataStore::mainDatabase(d->transaction, type) | 358 | DataStore::mainDatabase(d->transaction, type) |
356 | .write(key.toInternalByteArray(), BufferUtils::extractBuffer(fbb), | 359 | .write(key.toInternalByteArray(), BufferUtils::extractBuffer(fbb), |