diff options
-rw-r--r-- | common/pipeline.cpp | 11 | ||||
-rw-r--r-- | common/pipeline.h | 7 | ||||
-rw-r--r-- | common/specialpurposepreprocessor.cpp | 39 | ||||
-rw-r--r-- | common/storage/entitystore.h | 1 |
4 files changed, 36 insertions, 22 deletions
diff --git a/common/pipeline.cpp b/common/pipeline.cpp index ea59ae9..b1c2c58 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp | |||
@@ -73,7 +73,7 @@ void Pipeline::setPreprocessors(const QString &entityType, const QVector<Preproc | |||
73 | auto &list = d->processors[entityType]; | 73 | auto &list = d->processors[entityType]; |
74 | list.clear(); | 74 | list.clear(); |
75 | for (auto p : processors) { | 75 | for (auto p : processors) { |
76 | p->setup(d->resourceContext.resourceType, d->resourceContext.instanceId(), this); | 76 | p->setup(d->resourceContext.resourceType, d->resourceContext.instanceId(), this, &d->entityStore); |
77 | list.append(QSharedPointer<Preprocessor>(p)); | 77 | list.append(QSharedPointer<Preprocessor>(p)); |
78 | } | 78 | } |
79 | } | 79 | } |
@@ -307,6 +307,7 @@ public: | |||
307 | QByteArray resourceType; | 307 | QByteArray resourceType; |
308 | QByteArray resourceInstanceIdentifier; | 308 | QByteArray resourceInstanceIdentifier; |
309 | Pipeline *pipeline; | 309 | Pipeline *pipeline; |
310 | Storage::EntityStore *entityStore; | ||
310 | }; | 311 | }; |
311 | 312 | ||
312 | Preprocessor::Preprocessor() : d(new Preprocessor::Private) | 313 | Preprocessor::Preprocessor() : d(new Preprocessor::Private) |
@@ -317,11 +318,12 @@ Preprocessor::~Preprocessor() | |||
317 | { | 318 | { |
318 | } | 319 | } |
319 | 320 | ||
320 | void Preprocessor::setup(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier, Pipeline *pipeline) | 321 | void Preprocessor::setup(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier, Pipeline *pipeline, Storage::EntityStore *entityStore) |
321 | { | 322 | { |
322 | d->resourceType = resourceType; | 323 | d->resourceType = resourceType; |
323 | d->resourceInstanceIdentifier = resourceInstanceIdentifier; | 324 | d->resourceInstanceIdentifier = resourceInstanceIdentifier; |
324 | d->pipeline = pipeline; | 325 | d->pipeline = pipeline; |
326 | d->entityStore = entityStore; | ||
325 | } | 327 | } |
326 | 328 | ||
327 | void Preprocessor::startBatch() | 329 | void Preprocessor::startBatch() |
@@ -337,6 +339,11 @@ QByteArray Preprocessor::resourceInstanceIdentifier() const | |||
337 | return d->resourceInstanceIdentifier; | 339 | return d->resourceInstanceIdentifier; |
338 | } | 340 | } |
339 | 341 | ||
342 | Storage::EntityStore &Preprocessor::entityStore() const | ||
343 | { | ||
344 | return *d->entityStore; | ||
345 | } | ||
346 | |||
340 | void Preprocessor::createEntity(const Sink::ApplicationDomain::ApplicationDomainType &entity, const QByteArray &typeName) | 347 | void Preprocessor::createEntity(const Sink::ApplicationDomain::ApplicationDomainType &entity, const QByteArray &typeName) |
341 | { | 348 | { |
342 | flatbuffers::FlatBufferBuilder entityFbb; | 349 | flatbuffers::FlatBufferBuilder entityFbb; |
diff --git a/common/pipeline.h b/common/pipeline.h index 0461507..c6efaa6 100644 --- a/common/pipeline.h +++ b/common/pipeline.h | |||
@@ -35,6 +35,9 @@ | |||
35 | #include <resourcecontext.h> | 35 | #include <resourcecontext.h> |
36 | 36 | ||
37 | namespace Sink { | 37 | namespace Sink { |
38 | namespace Storage { | ||
39 | class EntityStore; | ||
40 | } | ||
38 | 41 | ||
39 | class Preprocessor; | 42 | class Preprocessor; |
40 | 43 | ||
@@ -87,7 +90,7 @@ public: | |||
87 | virtual void deletedEntity(const ApplicationDomain::ApplicationDomainType &oldEntity) {}; | 90 | virtual void deletedEntity(const ApplicationDomain::ApplicationDomainType &oldEntity) {}; |
88 | virtual void finalizeBatch(); | 91 | virtual void finalizeBatch(); |
89 | 92 | ||
90 | void setup(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier, Pipeline *); | 93 | void setup(const QByteArray &resourceType, const QByteArray &resourceInstanceIdentifier, Pipeline *, Storage::EntityStore *entityStore); |
91 | 94 | ||
92 | protected: | 95 | protected: |
93 | template <typename DomainType> | 96 | template <typename DomainType> |
@@ -99,6 +102,8 @@ protected: | |||
99 | 102 | ||
100 | QByteArray resourceInstanceIdentifier() const; | 103 | QByteArray resourceInstanceIdentifier() const; |
101 | 104 | ||
105 | Storage::EntityStore &entityStore() const; | ||
106 | |||
102 | private: | 107 | private: |
103 | friend class Pipeline; | 108 | friend class Pipeline; |
104 | class Private; | 109 | class Private; |
diff --git a/common/specialpurposepreprocessor.cpp b/common/specialpurposepreprocessor.cpp index 920f78a..b3a6bab 100644 --- a/common/specialpurposepreprocessor.cpp +++ b/common/specialpurposepreprocessor.cpp | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "specialpurposepreprocessor.h" | 1 | #include "specialpurposepreprocessor.h" |
2 | #include "query.h" | 2 | #include "query.h" |
3 | #include "applicationdomaintype.h" | 3 | #include "applicationdomaintype.h" |
4 | #include "datastorequery.h" | ||
4 | 5 | ||
5 | using namespace Sink; | 6 | using namespace Sink; |
6 | 7 | ||
@@ -48,25 +49,25 @@ SpecialPurposeProcessor::SpecialPurposeProcessor(const QByteArray &resourceType, | |||
48 | 49 | ||
49 | QByteArray SpecialPurposeProcessor::ensureFolder(const QByteArray &specialPurpose) | 50 | QByteArray SpecialPurposeProcessor::ensureFolder(const QByteArray &specialPurpose) |
50 | { | 51 | { |
51 | /* if (!mSpecialPurposeFolders.contains(specialPurpose)) { */ | 52 | if (!mSpecialPurposeFolders.contains(specialPurpose)) { |
52 | /* //Try to find an existing drafts folder */ | 53 | //Try to find an existing drafts folder |
53 | /* Sink::EntityReader<ApplicationDomain::Folder> reader(mResourceType, mResourceInstanceIdentifier); */ | 54 | DataStoreQuery dataStoreQuery{Sink::Query().filter<ApplicationDomain::Folder::SpecialPurpose>(Query::Comparator(specialPurpose, Query::Comparator::Contains)), ApplicationDomain::getTypeName<ApplicationDomain::Folder>(), entityStore()}; |
54 | /* reader.query(Sink::Query().filter<ApplicationDomain::Folder::SpecialPurpose>(Query::Comparator(specialPurpose, Query::Comparator::Contains)), */ | 55 | auto resultSet = dataStoreQuery.execute(); |
55 | /* [this, specialPurpose](const ApplicationDomain::Folder &f) -> bool{ */ | 56 | resultSet.replaySet(0, 1, [&, this](const ResultSet::Result &r) { |
56 | /* mSpecialPurposeFolders.insert(specialPurpose, f.identifier()); */ | 57 | mSpecialPurposeFolders.insert(specialPurpose, r.entity.identifier()); |
57 | /* return false; */ | 58 | }); |
58 | /* }); */ | 59 | |
59 | /* if (!mSpecialPurposeFolders.contains(specialPurpose)) { */ | 60 | if (!mSpecialPurposeFolders.contains(specialPurpose)) { |
60 | /* SinkTrace() << "Failed to find a drafts folder, creating a new one"; */ | 61 | SinkTrace() << "Failed to find a drafts folder, creating a new one"; |
61 | /* auto folder = ApplicationDomain::Folder::create(mResourceInstanceIdentifier); */ | 62 | auto folder = ApplicationDomain::Folder::create(mResourceInstanceIdentifier); |
62 | /* folder.setSpecialPurpose(QByteArrayList() << specialPurpose); */ | 63 | folder.setSpecialPurpose(QByteArrayList() << specialPurpose); |
63 | /* folder.setName(sSpecialPurposeFolders.value(specialPurpose)); */ | 64 | folder.setName(sSpecialPurposeFolders.value(specialPurpose)); |
64 | /* folder.setIcon("folder"); */ | 65 | folder.setIcon("folder"); |
65 | /* //This processes the pipeline synchronously */ | 66 | //This processes the pipeline synchronously |
66 | /* createEntity(folder); */ | 67 | createEntity(folder); |
67 | /* mSpecialPurposeFolders.insert(specialPurpose, folder.identifier()); */ | 68 | mSpecialPurposeFolders.insert(specialPurpose, folder.identifier()); |
68 | /* } */ | 69 | } |
69 | /* } */ | 70 | } |
70 | return mSpecialPurposeFolders.value(specialPurpose); | 71 | return mSpecialPurposeFolders.value(specialPurpose); |
71 | } | 72 | } |
72 | 73 | ||
diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index 65bff50..39f5fc1 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h | |||
@@ -42,6 +42,7 @@ public: | |||
42 | typedef std::function<void(ApplicationDomain::ApplicationDomainType &)> PreprocessCreation; | 42 | typedef std::function<void(ApplicationDomain::ApplicationDomainType &)> PreprocessCreation; |
43 | typedef std::function<void(const ApplicationDomain::ApplicationDomainType &)> PreprocessRemoval; | 43 | typedef std::function<void(const ApplicationDomain::ApplicationDomainType &)> PreprocessRemoval; |
44 | 44 | ||
45 | //Only the pipeline may call the following functions outside of tests | ||
45 | bool add(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, bool replayToSource, const PreprocessCreation &); | 46 | bool add(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, bool replayToSource, const PreprocessCreation &); |
46 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); | 47 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); |
47 | bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); | 48 | bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); |