From 71a0167e0216f84588b492c84e92667847fbe5a5 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 18 Oct 2016 12:44:12 +0200 Subject: 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. --- common/domain/event.cpp | 10 ---------- common/domain/event.h | 2 -- common/domain/folder.cpp | 9 --------- common/domain/folder.h | 1 - common/domain/mail.cpp | 23 ----------------------- common/domain/mail.h | 1 - 6 files changed, 46 deletions(-) (limited to 'common/domain') diff --git a/common/domain/event.cpp b/common/domain/event.cpp index 6717187..d50652d 100644 --- a/common/domain/event.cpp +++ b/common/domain/event.cpp @@ -87,13 +87,3 @@ QSharedPointer::BufferBuilder> > T propertyMapper->addMapping(&BufferBuilder::add_attachment); return propertyMapper; } - -DataStoreQuery::Ptr TypeImplementation::prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr store) -{ - auto mapper = initializeReadPropertyMapper(); - return DataStoreQuery::Ptr::create(query, ApplicationDomain::getTypeName(), store, [mapper](const Sink::Entity &entity, const QByteArray &property) { - - const auto localBuffer = Sink::EntityBuffer::readBuffer(entity.local()); - return mapper->getProperty(property, localBuffer); - }); -} diff --git a/common/domain/event.h b/common/domain/event.h index ce9691d..18e0f20 100644 --- a/common/domain/event.h +++ b/common/domain/event.h @@ -56,8 +56,6 @@ public: typedef Sink::ApplicationDomain::Buffer::EventBuilder BufferBuilder; static void configureIndex(TypeIndex &index); static QSet indexedProperties(); - static QSharedPointer prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr store); - static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction); static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction); static QSharedPointer > initializeReadPropertyMapper(); diff --git a/common/domain/folder.cpp b/common/domain/folder.cpp index 34e59f6..94727a3 100644 --- a/common/domain/folder.cpp +++ b/common/domain/folder.cpp @@ -91,12 +91,3 @@ QSharedPointer::BufferBuilder> > propertyMapper->addMapping(&BufferBuilder::add_specialpurpose); return propertyMapper; } - -DataStoreQuery::Ptr TypeImplementation::prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr store) -{ - auto mapper = initializeReadPropertyMapper(); - return DataStoreQuery::Ptr::create(query, ApplicationDomain::getTypeName(), store, [mapper](const Sink::Entity &entity, const QByteArray &property) { - const auto localBuffer = Sink::EntityBuffer::readBuffer(entity.local()); - return mapper->getProperty(property, localBuffer); - }); -} diff --git a/common/domain/folder.h b/common/domain/folder.h index 0a52b01..ea0d79a 100644 --- a/common/domain/folder.h +++ b/common/domain/folder.h @@ -49,7 +49,6 @@ public: typedef Sink::ApplicationDomain::Buffer::Folder Buffer; typedef Sink::ApplicationDomain::Buffer::FolderBuilder BufferBuilder; static void configureIndex(TypeIndex &index); - static QSharedPointer prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr store); static QSet indexedProperties(); static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction); static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction); diff --git a/common/domain/mail.cpp b/common/domain/mail.cpp index 9e3a824..b0a3aae 100644 --- a/common/domain/mail.cpp +++ b/common/domain/mail.cpp @@ -225,26 +225,3 @@ QSharedPointer::BufferBuilder> > Ty } -DataStoreQuery::Ptr TypeImplementation::prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr store) -{ - auto mapper = initializeReadPropertyMapper(); - return DataStoreQuery::Ptr::create(query, ApplicationDomain::getTypeName(), store, [mapper, store](const Sink::Entity &entity, const QByteArray &property) -> QVariant { - if (property == Mail::ThreadId::name) { - const auto localBuffer = Sink::EntityBuffer::readBuffer(entity.local()); - Q_ASSERT(localBuffer); - auto messageId = mapper->getProperty(Mail::MessageId::name, localBuffer); - //FIXME - //This is an index property that we have too lookup - /* auto thread = getIndex().secondaryLookup(messageId); */ - /* auto thread = store->secondaryLookup(messageId); */ - /* Q_ASSERT(!thread.isEmpty()); */ - /* return thread.first(); */ - return QVariant(); - } else { - const auto localBuffer = Sink::EntityBuffer::readBuffer(entity.local()); - Q_ASSERT(localBuffer); - return mapper->getProperty(property, localBuffer); - } - }); -} - diff --git a/common/domain/mail.h b/common/domain/mail.h index 6c1f670..81a0d1c 100644 --- a/common/domain/mail.h +++ b/common/domain/mail.h @@ -49,7 +49,6 @@ public: typedef Sink::ApplicationDomain::Buffer::Mail Buffer; typedef Sink::ApplicationDomain::Buffer::MailBuilder BufferBuilder; static void configureIndex(TypeIndex &index); - static QSharedPointer prepareQuery(const Sink::Query &query, Sink::Storage::EntityStore::Ptr storage); static QSet indexedProperties(); static void index(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction); static void removeIndex(const QByteArray &identifier, const BufferAdaptor &bufferAdaptor, Sink::Storage::DataStore::Transaction &transaction); -- cgit v1.2.3