diff options
-rw-r--r-- | common/domain/applicationdomaintype.cpp | 35 | ||||
-rw-r--r-- | common/domain/applicationdomaintype.h | 61 | ||||
-rw-r--r-- | common/propertymapper.cpp | 19 | ||||
-rw-r--r-- | common/query.h | 11 | ||||
-rw-r--r-- | common/queryrunner.cpp | 6 | ||||
-rw-r--r-- | common/specialpurposepreprocessor.cpp | 20 | ||||
-rw-r--r-- | common/storage/entitystore.cpp | 3 | ||||
-rw-r--r-- | common/typeindex.cpp | 6 | ||||
-rw-r--r-- | examples/dummyresource/resourcefactory.cpp | 25 | ||||
-rw-r--r-- | examples/imapresource/imapresource.cpp | 8 | ||||
-rw-r--r-- | examples/maildirresource/maildirresource.cpp | 8 | ||||
-rw-r--r-- | tests/clientapitest.cpp | 6 | ||||
-rw-r--r-- | tests/domainadaptortest.cpp | 2 | ||||
-rw-r--r-- | tests/mailquerybenchmark.cpp | 10 | ||||
-rw-r--r-- | tests/pipelinebenchmark.cpp | 8 | ||||
-rw-r--r-- | tests/querytest.cpp | 60 |
16 files changed, 188 insertions, 100 deletions
diff --git a/common/domain/applicationdomaintype.cpp b/common/domain/applicationdomaintype.cpp index a655871..f00f3ed 100644 --- a/common/domain/applicationdomaintype.cpp +++ b/common/domain/applicationdomaintype.cpp | |||
@@ -31,7 +31,16 @@ namespace ApplicationDomain { | |||
31 | 31 | ||
32 | constexpr const char *Mail::ThreadId::name; | 32 | constexpr const char *Mail::ThreadId::name; |
33 | 33 | ||
34 | void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties, bool copyBlobs) | 34 | int foo = [] { |
35 | QMetaType::registerEqualsComparator<Reference>(); | ||
36 | QMetaType::registerDebugStreamOperator<Reference>(); | ||
37 | QMetaType::registerConverter<Reference, QByteArray>(); | ||
38 | QMetaType::registerDebugStreamOperator<BLOB>(); | ||
39 | QMetaType::registerDebugStreamOperator<Mail::Contact>(); | ||
40 | return 0; | ||
41 | }(); | ||
42 | |||
43 | void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties, bool copyBlobs, bool pruneReferences) | ||
35 | { | 44 | { |
36 | auto propertiesToCopy = properties; | 45 | auto propertiesToCopy = properties; |
37 | if (properties.isEmpty()) { | 46 | if (properties.isEmpty()) { |
@@ -44,6 +53,8 @@ void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::Applicatio | |||
44 | auto newPath = oldPath + "copy"; | 53 | auto newPath = oldPath + "copy"; |
45 | QFile::copy(oldPath, newPath); | 54 | QFile::copy(oldPath, newPath); |
46 | memoryAdaptor.setProperty(property, QVariant::fromValue(BLOB{newPath})); | 55 | memoryAdaptor.setProperty(property, QVariant::fromValue(BLOB{newPath})); |
56 | } else if (pruneReferences && value.canConvert<Reference>()) { | ||
57 | continue; | ||
47 | } else { | 58 | } else { |
48 | memoryAdaptor.setProperty(property, value); | 59 | memoryAdaptor.setProperty(property, value); |
49 | } | 60 | } |
@@ -51,14 +62,16 @@ void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::Applicatio | |||
51 | } | 62 | } |
52 | 63 | ||
53 | ApplicationDomainType::ApplicationDomainType() | 64 | ApplicationDomainType::ApplicationDomainType() |
54 | :mAdaptor(new MemoryBufferAdaptor()) | 65 | :mAdaptor(new MemoryBufferAdaptor()), |
66 | mChangeSet(new QSet<QByteArray>()) | ||
55 | { | 67 | { |
56 | 68 | ||
57 | } | 69 | } |
58 | 70 | ||
59 | ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceIdentifier) | 71 | ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceIdentifier) |
60 | :mAdaptor(new MemoryBufferAdaptor()), | 72 | :mAdaptor(new MemoryBufferAdaptor()), |
61 | mResourceInstanceIdentifier(resourceInstanceIdentifier) | 73 | mResourceInstanceIdentifier(resourceInstanceIdentifier), |
74 | mChangeSet(new QSet<QByteArray>()) | ||
62 | { | 75 | { |
63 | 76 | ||
64 | } | 77 | } |
@@ -67,11 +80,13 @@ ApplicationDomainType::ApplicationDomainType(const QByteArray &resourceInstanceI | |||
67 | : mAdaptor(adaptor), | 80 | : mAdaptor(adaptor), |
68 | mResourceInstanceIdentifier(resourceInstanceIdentifier), | 81 | mResourceInstanceIdentifier(resourceInstanceIdentifier), |
69 | mIdentifier(identifier), | 82 | mIdentifier(identifier), |
70 | mRevision(revision) | 83 | mRevision(revision), |
84 | mChangeSet(new QSet<QByteArray>()) | ||
71 | { | 85 | { |
72 | } | 86 | } |
73 | 87 | ||
74 | ApplicationDomainType::ApplicationDomainType(const ApplicationDomainType &other) | 88 | ApplicationDomainType::ApplicationDomainType(const ApplicationDomainType &other) |
89 | : mChangeSet(new QSet<QByteArray>()) | ||
75 | { | 90 | { |
76 | *this = other; | 91 | *this = other; |
77 | } | 92 | } |
@@ -79,7 +94,9 @@ ApplicationDomainType::ApplicationDomainType(const ApplicationDomainType &other) | |||
79 | ApplicationDomainType& ApplicationDomainType::operator=(const ApplicationDomainType &other) | 94 | ApplicationDomainType& ApplicationDomainType::operator=(const ApplicationDomainType &other) |
80 | { | 95 | { |
81 | mAdaptor = other.mAdaptor; | 96 | mAdaptor = other.mAdaptor; |
82 | mChangeSet = other.mChangeSet; | 97 | if (other.mChangeSet) { |
98 | *mChangeSet = *other.mChangeSet; | ||
99 | } | ||
83 | mResourceInstanceIdentifier = other.mResourceInstanceIdentifier; | 100 | mResourceInstanceIdentifier = other.mResourceInstanceIdentifier; |
84 | mIdentifier = other.mIdentifier; | 101 | mIdentifier = other.mIdentifier; |
85 | mRevision = other.mRevision; | 102 | mRevision = other.mRevision; |
@@ -110,7 +127,7 @@ QVariant ApplicationDomainType::getProperty(const QByteArray &key) const | |||
110 | void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value) | 127 | void ApplicationDomainType::setProperty(const QByteArray &key, const QVariant &value) |
111 | { | 128 | { |
112 | Q_ASSERT(mAdaptor); | 129 | Q_ASSERT(mAdaptor); |
113 | mChangeSet.insert(key); | 130 | mChangeSet->insert(key); |
114 | mAdaptor->setProperty(key, value); | 131 | mAdaptor->setProperty(key, value); |
115 | } | 132 | } |
116 | 133 | ||
@@ -122,7 +139,7 @@ void ApplicationDomainType::setResource(const QByteArray &identifier) | |||
122 | void ApplicationDomainType::setProperty(const QByteArray &key, const ApplicationDomainType &value) | 139 | void ApplicationDomainType::setProperty(const QByteArray &key, const ApplicationDomainType &value) |
123 | { | 140 | { |
124 | Q_ASSERT(!value.identifier().isEmpty()); | 141 | Q_ASSERT(!value.identifier().isEmpty()); |
125 | setProperty(key, value.identifier()); | 142 | setProperty(key, QVariant::fromValue(Reference{value.identifier()})); |
126 | } | 143 | } |
127 | 144 | ||
128 | QByteArray ApplicationDomainType::getBlobProperty(const QByteArray &key) const | 145 | QByteArray ApplicationDomainType::getBlobProperty(const QByteArray &key) const |
@@ -152,12 +169,12 @@ void ApplicationDomainType::setBlobProperty(const QByteArray &key, const QByteAr | |||
152 | 169 | ||
153 | void ApplicationDomainType::setChangedProperties(const QSet<QByteArray> &changeset) | 170 | void ApplicationDomainType::setChangedProperties(const QSet<QByteArray> &changeset) |
154 | { | 171 | { |
155 | mChangeSet = changeset; | 172 | *mChangeSet = changeset; |
156 | } | 173 | } |
157 | 174 | ||
158 | QByteArrayList ApplicationDomainType::changedProperties() const | 175 | QByteArrayList ApplicationDomainType::changedProperties() const |
159 | { | 176 | { |
160 | return mChangeSet.toList(); | 177 | return mChangeSet->toList(); |
161 | } | 178 | } |
162 | 179 | ||
163 | QByteArrayList ApplicationDomainType::availableProperties() const | 180 | QByteArrayList ApplicationDomainType::availableProperties() const |
diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicationdomaintype.h index 21e42cf..1c0f208 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h | |||
@@ -73,12 +73,12 @@ | |||
73 | #define SINK_REFERENCE_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | 73 | #define SINK_REFERENCE_PROPERTY(TYPE, NAME, LOWERCASENAME) \ |
74 | struct NAME { \ | 74 | struct NAME { \ |
75 | static constexpr const char *name = #LOWERCASENAME; \ | 75 | static constexpr const char *name = #LOWERCASENAME; \ |
76 | typedef QByteArray Type; \ | 76 | typedef Reference Type; \ |
77 | typedef ApplicationDomain::TYPE ReferenceType; \ | 77 | typedef ApplicationDomain::TYPE ReferenceType; \ |
78 | }; \ | 78 | }; \ |
79 | void set##NAME(const ApplicationDomain::TYPE &value) { setProperty(NAME::name, value); } \ | 79 | void set##NAME(const ApplicationDomain::TYPE &value) { setProperty(NAME::name, value); } \ |
80 | void set##NAME(const QByteArray &value) { setProperty(NAME::name, QVariant::fromValue(value)); } \ | 80 | void set##NAME(const QByteArray &value) { setProperty(NAME::name, QVariant::fromValue(Reference{value})); } \ |
81 | QByteArray get##NAME() const { return getProperty(NAME::name).value<QByteArray>(); } \ | 81 | QByteArray get##NAME() const { return getProperty(NAME::name).value<Reference>().value; } \ |
82 | 82 | ||
83 | #define SINK_INDEX_PROPERTY(TYPE, NAME, LOWERCASENAME) \ | 83 | #define SINK_INDEX_PROPERTY(TYPE, NAME, LOWERCASENAME) \ |
84 | struct NAME { \ | 84 | struct NAME { \ |
@@ -102,7 +102,27 @@ struct BLOB { | |||
102 | QString value; | 102 | QString value; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties, bool copyBlobs); | 105 | /** |
106 | * Internal type. | ||
107 | * | ||
108 | * Represents a reference to another entity in the same resource. | ||
109 | */ | ||
110 | struct Reference { | ||
111 | Reference() = default; | ||
112 | Reference(const Reference &) = default; | ||
113 | Reference(const QByteArray &id) : value(id) {}; | ||
114 | Reference(const char *id) : value(id) {}; | ||
115 | ~Reference() = default; | ||
116 | bool operator==(const Reference &other) const { | ||
117 | return value == other.value; | ||
118 | } | ||
119 | operator QByteArray() const { | ||
120 | return value; | ||
121 | } | ||
122 | QByteArray value; | ||
123 | }; | ||
124 | |||
125 | void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::ApplicationDomain::BufferAdaptor &memoryAdaptor, const QList<QByteArray> &properties, bool copyBlobs, bool pruneReferences); | ||
106 | 126 | ||
107 | /** | 127 | /** |
108 | * The domain type interface has two purposes: | 128 | * The domain type interface has two purposes: |
@@ -121,6 +141,14 @@ public: | |||
121 | ApplicationDomainType(const ApplicationDomainType &other); | 141 | ApplicationDomainType(const ApplicationDomainType &other); |
122 | ApplicationDomainType& operator=(const ApplicationDomainType &other); | 142 | ApplicationDomainType& operator=(const ApplicationDomainType &other); |
123 | 143 | ||
144 | template <typename DomainType> | ||
145 | DomainType cast() { | ||
146 | static_assert(std::is_base_of<ApplicationDomainType, DomainType>::value, "You can only cast to base classes of ApplicationDomainType."); | ||
147 | DomainType t = *this; | ||
148 | t.mChangeSet = mChangeSet; | ||
149 | return t; | ||
150 | } | ||
151 | |||
124 | /** | 152 | /** |
125 | * Returns an in memory representation of the same entity. | 153 | * Returns an in memory representation of the same entity. |
126 | */ | 154 | */ |
@@ -140,7 +168,7 @@ public: | |||
140 | { | 168 | { |
141 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(); | 169 | auto memoryAdaptor = QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create(); |
142 | Q_ASSERT(domainType.mAdaptor); | 170 | Q_ASSERT(domainType.mAdaptor); |
143 | copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, true); | 171 | copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, true, true); |
144 | return QSharedPointer<DomainType>::create(QByteArray{}, QByteArray{}, 0, memoryAdaptor); | 172 | return QSharedPointer<DomainType>::create(QByteArray{}, QByteArray{}, 0, memoryAdaptor); |
145 | } | 173 | } |
146 | 174 | ||
@@ -195,7 +223,7 @@ public: | |||
195 | private: | 223 | private: |
196 | friend QDebug operator<<(QDebug, const ApplicationDomainType &); | 224 | friend QDebug operator<<(QDebug, const ApplicationDomainType &); |
197 | QSharedPointer<BufferAdaptor> mAdaptor; | 225 | QSharedPointer<BufferAdaptor> mAdaptor; |
198 | QSet<QByteArray> mChangeSet; | 226 | QSharedPointer<QSet<QByteArray>> mChangeSet; |
199 | /* | 227 | /* |
200 | * Each domain object needs to store the resource, identifier, revision triple so we can link back to the storage location. | 228 | * Each domain object needs to store the resource, identifier, revision triple so we can link back to the storage location. |
201 | */ | 229 | */ |
@@ -223,6 +251,19 @@ inline QDebug operator<< (QDebug d, const ApplicationDomainType &type) | |||
223 | return d; | 251 | return d; |
224 | } | 252 | } |
225 | 253 | ||
254 | inline QDebug operator<< (QDebug d, const Reference &ref) | ||
255 | { | ||
256 | d << ref.value; | ||
257 | return d; | ||
258 | } | ||
259 | |||
260 | inline QDebug operator<< (QDebug d, const BLOB &blob) | ||
261 | { | ||
262 | d << blob.value; | ||
263 | return d; | ||
264 | } | ||
265 | |||
266 | |||
226 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { | 267 | struct SINK_EXPORT SinkAccount : public ApplicationDomainType { |
227 | typedef QSharedPointer<SinkAccount> Ptr; | 268 | typedef QSharedPointer<SinkAccount> Ptr; |
228 | explicit SinkAccount(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); | 269 | explicit SinkAccount(const QByteArray &resourceInstanceIdentifier, const QByteArray &identifier, qint64 revision, const QSharedPointer<BufferAdaptor> &adaptor); |
@@ -318,6 +359,13 @@ struct SINK_EXPORT Mail : public Entity { | |||
318 | SINK_INDEX_PROPERTY(QByteArray, ThreadId, threadId); | 359 | SINK_INDEX_PROPERTY(QByteArray, ThreadId, threadId); |
319 | }; | 360 | }; |
320 | 361 | ||
362 | inline QDebug operator<< (QDebug d, const Mail::Contact &c) | ||
363 | { | ||
364 | d << "Contact(" << c.name << ", " << c.emailAddress << ")"; | ||
365 | return d; | ||
366 | } | ||
367 | |||
368 | |||
321 | /** | 369 | /** |
322 | * The status of an account or resource. | 370 | * The status of an account or resource. |
323 | * | 371 | * |
@@ -454,3 +502,4 @@ Q_DECLARE_METATYPE(Sink::ApplicationDomain::Mail::Contact) | |||
454 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) | 502 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Error) |
455 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) | 503 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Progress) |
456 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) | 504 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::BLOB) |
505 | Q_DECLARE_METATYPE(Sink::ApplicationDomain::Reference) | ||
diff --git a/common/propertymapper.cpp b/common/propertymapper.cpp index 249221a..4cfe154 100644 --- a/common/propertymapper.cpp +++ b/common/propertymapper.cpp | |||
@@ -42,6 +42,15 @@ flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::BLOB>(const QV | |||
42 | } | 42 | } |
43 | 43 | ||
44 | template <> | 44 | template <> |
45 | flatbuffers::uoffset_t variantToProperty<Sink::ApplicationDomain::Reference>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | ||
46 | { | ||
47 | if (property.isValid()) { | ||
48 | return fbb.CreateString(property.value<Sink::ApplicationDomain::Reference>().value.toStdString()).o; | ||
49 | } | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | template <> | ||
45 | flatbuffers::uoffset_t variantToProperty<QByteArray>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) | 54 | flatbuffers::uoffset_t variantToProperty<QByteArray>(const QVariant &property, flatbuffers::FlatBufferBuilder &fbb) |
46 | { | 55 | { |
47 | if (property.isValid()) { | 56 | if (property.isValid()) { |
@@ -130,6 +139,16 @@ QVariant propertyToVariant<Sink::ApplicationDomain::BLOB>(const flatbuffers::Str | |||
130 | } | 139 | } |
131 | 140 | ||
132 | template <> | 141 | template <> |
142 | QVariant propertyToVariant<Sink::ApplicationDomain::Reference>(const flatbuffers::String *property) | ||
143 | { | ||
144 | if (property) { | ||
145 | // We have to copy the memory, otherwise it would become eventually invalid | ||
146 | return QVariant::fromValue(Sink::ApplicationDomain::Reference{QString::fromStdString(property->c_str()).toUtf8()}); | ||
147 | } | ||
148 | return QVariant(); | ||
149 | } | ||
150 | |||
151 | template <> | ||
133 | QVariant propertyToVariant<QByteArray>(const flatbuffers::String *property) | 152 | QVariant propertyToVariant<QByteArray>(const flatbuffers::String *property) |
134 | { | 153 | { |
135 | if (property) { | 154 | if (property) { |
diff --git a/common/query.h b/common/query.h index b69639b..c265f92 100644 --- a/common/query.h +++ b/common/query.h | |||
@@ -325,16 +325,17 @@ public: | |||
325 | } | 325 | } |
326 | 326 | ||
327 | template <typename T> | 327 | template <typename T> |
328 | Query &filter(const QVariant &value) | 328 | Query &filter(const typename T::Type &value) |
329 | { | 329 | { |
330 | filter(T::name, value); | 330 | filter(T::name, QVariant::fromValue(value)); |
331 | return *this; | 331 | return *this; |
332 | } | 332 | } |
333 | 333 | ||
334 | template <typename T> | 334 | template <typename T> |
335 | Query &containsFilter(const QVariant &value) | 335 | Query &containsFilter(const QByteArray &value) |
336 | { | 336 | { |
337 | QueryBase::filter(T::name, QueryBase::Comparator(value, QueryBase::Comparator::Contains)); | 337 | static_assert(std::is_same<typename T::Type, QByteArrayList>::value, "The contains filter is only implemented for QByteArray in QByteArrayList"); |
338 | QueryBase::filter(T::name, QueryBase::Comparator(QVariant::fromValue(value), QueryBase::Comparator::Contains)); | ||
338 | return *this; | 339 | return *this; |
339 | } | 340 | } |
340 | 341 | ||
@@ -366,7 +367,7 @@ public: | |||
366 | template <typename T> | 367 | template <typename T> |
367 | Query &filter(const ApplicationDomain::Entity &value) | 368 | Query &filter(const ApplicationDomain::Entity &value) |
368 | { | 369 | { |
369 | filter(T::name, QVariant::fromValue(value.identifier())); | 370 | filter(T::name, QVariant::fromValue(ApplicationDomain::Reference{value.identifier()})); |
370 | return *this; | 371 | return *this; |
371 | } | 372 | } |
372 | 373 | ||
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index cf56268..d6a90de 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -224,15 +224,15 @@ QPair<qint64, qint64> QueryWorker<DomainType>::executeInitialQuery( | |||
224 | if (!query.parentProperty().isEmpty()) { | 224 | if (!query.parentProperty().isEmpty()) { |
225 | if (parent) { | 225 | if (parent) { |
226 | SinkTrace() << "Running initial query for parent:" << parent->identifier(); | 226 | SinkTrace() << "Running initial query for parent:" << parent->identifier(); |
227 | modifiedQuery.filter(query.parentProperty(), Query::Comparator(parent->identifier())); | 227 | modifiedQuery.filter(query.parentProperty(), Query::Comparator(QVariant::fromValue(Sink::ApplicationDomain::Reference{parent->identifier()}))); |
228 | } else { | 228 | } else { |
229 | SinkTrace() << "Running initial query for toplevel"; | 229 | SinkTrace() << "Running initial query for toplevel"; |
230 | modifiedQuery.filter(query.parentProperty(), Query::Comparator(QVariant())); | 230 | modifiedQuery.filter(query.parentProperty(), Query::Comparator(QVariant{})); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | auto entityStore = EntityStore{mResourceContext}; | 234 | auto entityStore = EntityStore{mResourceContext}; |
235 | auto preparedQuery = DataStoreQuery{query, ApplicationDomain::getTypeName<DomainType>(), entityStore}; | 235 | auto preparedQuery = DataStoreQuery{modifiedQuery, ApplicationDomain::getTypeName<DomainType>(), entityStore}; |
236 | auto resultSet = preparedQuery.execute(); | 236 | auto resultSet = preparedQuery.execute(); |
237 | 237 | ||
238 | SinkTrace() << "Filtered set retrieved. " << Log::TraceTime(time.elapsed()); | 238 | SinkTrace() << "Filtered set retrieved. " << Log::TraceTime(time.elapsed()); |
diff --git a/common/specialpurposepreprocessor.cpp b/common/specialpurposepreprocessor.cpp index ce1a218..e73e4ce 100644 --- a/common/specialpurposepreprocessor.cpp +++ b/common/specialpurposepreprocessor.cpp | |||
@@ -59,7 +59,7 @@ QByteArray SpecialPurposeProcessor::ensureFolder(const QByteArray &specialPurpos | |||
59 | }); | 59 | }); |
60 | 60 | ||
61 | if (!mSpecialPurposeFolders.contains(specialPurpose)) { | 61 | if (!mSpecialPurposeFolders.contains(specialPurpose)) { |
62 | SinkTrace() << "Failed to find a drafts folder, creating a new one"; | 62 | SinkTrace() << "Failed to find a " << specialPurpose << " folder, creating a new one"; |
63 | auto folder = ApplicationDomain::Folder::create(mResourceInstanceIdentifier); | 63 | auto folder = ApplicationDomain::Folder::create(mResourceInstanceIdentifier); |
64 | folder.setSpecialPurpose(QByteArrayList() << specialPurpose); | 64 | folder.setSpecialPurpose(QByteArrayList() << specialPurpose); |
65 | folder.setName(sSpecialPurposeFolders.value(specialPurpose)); | 65 | folder.setName(sSpecialPurposeFolders.value(specialPurpose)); |
@@ -74,15 +74,21 @@ QByteArray SpecialPurposeProcessor::ensureFolder(const QByteArray &specialPurpos | |||
74 | 74 | ||
75 | void SpecialPurposeProcessor::moveToFolder(Sink::ApplicationDomain::ApplicationDomainType &newEntity) | 75 | void SpecialPurposeProcessor::moveToFolder(Sink::ApplicationDomain::ApplicationDomainType &newEntity) |
76 | { | 76 | { |
77 | if (newEntity.getProperty(ApplicationDomain::Mail::Trash::name).toBool()) { | 77 | using namespace Sink::ApplicationDomain; |
78 | newEntity.setProperty("folder", ensureFolder(ApplicationDomain::SpecialPurpose::Mail::trash)); | 78 | auto mail = newEntity.cast<Mail>(); |
79 | if (mail.getTrash()) { | ||
80 | auto f = ensureFolder(ApplicationDomain::SpecialPurpose::Mail::trash); | ||
81 | SinkTrace() << "Setting trash folder: " << f; | ||
82 | mail.setFolder(f); | ||
79 | return; | 83 | return; |
80 | } | 84 | } |
81 | if (newEntity.getProperty(ApplicationDomain::Mail::Draft::name).toBool()) { | 85 | if (mail.getDraft()) { |
82 | newEntity.setProperty("folder", ensureFolder(ApplicationDomain::SpecialPurpose::Mail::drafts)); | 86 | mail.setFolder(ensureFolder(ApplicationDomain::SpecialPurpose::Mail::drafts)); |
87 | return; | ||
83 | } | 88 | } |
84 | if (newEntity.getProperty(ApplicationDomain::Mail::Sent::name).toBool()) { | 89 | if (mail.getSent()) { |
85 | newEntity.setProperty("folder", ensureFolder(ApplicationDomain::SpecialPurpose::Mail::sent)); | 90 | mail.setFolder(ensureFolder(ApplicationDomain::SpecialPurpose::Mail::sent)); |
91 | return; | ||
86 | } | 92 | } |
87 | } | 93 | } |
88 | 94 | ||
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 7414f49..999bb2c 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp | |||
@@ -205,9 +205,10 @@ bool EntityStore::modify(const QByteArray &type, const ApplicationDomain::Applic | |||
205 | auto metadataBuffer = metadataBuilder.Finish(); | 205 | auto metadataBuffer = metadataBuilder.Finish(); |
206 | FinishMetadataBuffer(metadataFbb, metadataBuffer); | 206 | FinishMetadataBuffer(metadataFbb, metadataBuffer); |
207 | } | 207 | } |
208 | SinkTrace() << "Modified entity: " << newEntity; | ||
209 | SinkTrace() << "Changed properties: " << changeset + newEntity.changedProperties(); | ||
208 | 210 | ||
209 | newEntity.setChangedProperties(newEntity.availableProperties().toSet()); | 211 | newEntity.setChangedProperties(newEntity.availableProperties().toSet()); |
210 | SinkTrace() << "Modified entity " << newEntity; | ||
211 | 212 | ||
212 | flatbuffers::FlatBufferBuilder fbb; | 213 | flatbuffers::FlatBufferBuilder fbb; |
213 | d->resourceContext.adaptorFactory(type).createBuffer(newEntity, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); | 214 | d->resourceContext.adaptorFactory(type).createBuffer(newEntity, fbb, metadataFbb.GetBufferPointer(), metadataFbb.GetSize()); |
diff --git a/common/typeindex.cpp b/common/typeindex.cpp index b0494f3..9d71463 100644 --- a/common/typeindex.cpp +++ b/common/typeindex.cpp | |||
@@ -34,6 +34,12 @@ static QByteArray getByteArray(const QVariant &value) | |||
34 | return "nodate"; | 34 | return "nodate"; |
35 | } | 35 | } |
36 | } | 36 | } |
37 | if (value.canConvert<Sink::ApplicationDomain::Reference>()) { | ||
38 | const auto ba = value.value<Sink::ApplicationDomain::Reference>().value; | ||
39 | if (!ba.isEmpty()) { | ||
40 | return ba; | ||
41 | } | ||
42 | } | ||
37 | if (value.isValid() && !value.toByteArray().isEmpty()) { | 43 | if (value.isValid() && !value.toByteArray().isEmpty()) { |
38 | return value.toByteArray(); | 44 | return value.toByteArray(); |
39 | } | 45 | } |
diff --git a/examples/dummyresource/resourcefactory.cpp b/examples/dummyresource/resourcefactory.cpp index d230ea3..07021b9 100644 --- a/examples/dummyresource/resourcefactory.cpp +++ b/examples/dummyresource/resourcefactory.cpp | |||
@@ -59,34 +59,33 @@ class DummySynchronizer : public Sink::Synchronizer { | |||
59 | { | 59 | { |
60 | static uint8_t rawData[100]; | 60 | static uint8_t rawData[100]; |
61 | auto event = Sink::ApplicationDomain::Event::Ptr::create(); | 61 | auto event = Sink::ApplicationDomain::Event::Ptr::create(); |
62 | event->setProperty("summary", data.value("summary").toString()); | 62 | event->setSummary(data.value("summary").toString()); |
63 | event->setProperty("remoteId", ridBuffer); | 63 | event->setProperty("remoteId", ridBuffer); |
64 | event->setProperty("description", data.value("description").toString()); | 64 | event->setDescription(data.value("description").toString()); |
65 | event->setProperty("attachment", QByteArray::fromRawData(reinterpret_cast<const char*>(rawData), 100)); | 65 | event->setAttachment(QByteArray::fromRawData(reinterpret_cast<const char*>(rawData), 100)); |
66 | return event; | 66 | return event; |
67 | } | 67 | } |
68 | 68 | ||
69 | Sink::ApplicationDomain::Mail::Ptr createMail(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) | 69 | Sink::ApplicationDomain::Mail::Ptr createMail(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) |
70 | { | 70 | { |
71 | auto mail = Sink::ApplicationDomain::Mail::Ptr::create(); | 71 | auto mail = Sink::ApplicationDomain::Mail::Ptr::create(); |
72 | mail->setProperty("subject", data.value("subject").toString()); | 72 | mail->setExtractedSubject(data.value("subject").toString()); |
73 | mail->setProperty("senderEmail", data.value("senderEmail").toString()); | 73 | mail->setExtractedSender(Sink::ApplicationDomain::Mail::Contact{data.value("senderName").toString(), data.value("senderEmail").toString()}); |
74 | mail->setProperty("senderName", data.value("senderName").toString()); | 74 | mail->setExtractedDate(data.value("date").toDateTime()); |
75 | mail->setProperty("date", data.value("date").toString()); | 75 | mail->setFolder(syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parentFolder").toByteArray())); |
76 | mail->setProperty("folder", syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parentFolder").toByteArray())); | 76 | mail->setUnread(data.value("unread").toBool()); |
77 | mail->setProperty("unread", data.value("unread").toBool()); | 77 | mail->setImportant(data.value("important").toBool()); |
78 | mail->setProperty("important", data.value("important").toBool()); | ||
79 | return mail; | 78 | return mail; |
80 | } | 79 | } |
81 | 80 | ||
82 | Sink::ApplicationDomain::Folder::Ptr createFolder(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) | 81 | Sink::ApplicationDomain::Folder::Ptr createFolder(const QByteArray &ridBuffer, const QMap<QString, QVariant> &data) |
83 | { | 82 | { |
84 | auto folder = Sink::ApplicationDomain::Folder::Ptr::create(); | 83 | auto folder = Sink::ApplicationDomain::Folder::Ptr::create(); |
85 | folder->setProperty("name", data.value("name").toString()); | 84 | folder->setName(data.value("name").toString()); |
86 | folder->setProperty("icon", data.value("icon").toString()); | 85 | folder->setIcon(data.value("icon").toByteArray()); |
87 | if (!data.value("parent").toString().isEmpty()) { | 86 | if (!data.value("parent").toString().isEmpty()) { |
88 | auto sinkId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parent").toByteArray()); | 87 | auto sinkId = syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, data.value("parent").toByteArray()); |
89 | folder->setProperty("parent", sinkId); | 88 | folder->setParent(sinkId); |
90 | } | 89 | } |
91 | return folder; | 90 | return folder; |
92 | } | 91 | } |
diff --git a/examples/imapresource/imapresource.cpp b/examples/imapresource/imapresource.cpp index 9577f3e..238fb0c 100644 --- a/examples/imapresource/imapresource.cpp +++ b/examples/imapresource/imapresource.cpp | |||
@@ -92,17 +92,17 @@ public: | |||
92 | const auto remoteId = folderPath.toUtf8(); | 92 | const auto remoteId = folderPath.toUtf8(); |
93 | const auto bufferType = ENTITY_TYPE_FOLDER; | 93 | const auto bufferType = ENTITY_TYPE_FOLDER; |
94 | Sink::ApplicationDomain::Folder folder; | 94 | Sink::ApplicationDomain::Folder folder; |
95 | folder.setProperty(ApplicationDomain::Folder::Name::name, folderName); | 95 | folder.setName(folderName); |
96 | folder.setProperty(ApplicationDomain::Folder::Icon::name, icon); | 96 | folder.setIcon(icon); |
97 | QHash<QByteArray, Query::Comparator> mergeCriteria; | 97 | QHash<QByteArray, Query::Comparator> mergeCriteria; |
98 | if (SpecialPurpose::isSpecialPurposeFolderName(folderName)) { | 98 | if (SpecialPurpose::isSpecialPurposeFolderName(folderName)) { |
99 | auto type = SpecialPurpose::getSpecialPurposeType(folderName); | 99 | auto type = SpecialPurpose::getSpecialPurposeType(folderName); |
100 | folder.setProperty(ApplicationDomain::Folder::SpecialPurpose::name, QVariant::fromValue(QByteArrayList() << type)); | 100 | folder.setSpecialPurpose(QByteArrayList() << type); |
101 | mergeCriteria.insert(ApplicationDomain::Folder::SpecialPurpose::name, Query::Comparator(type, Query::Comparator::Contains)); | 101 | mergeCriteria.insert(ApplicationDomain::Folder::SpecialPurpose::name, Query::Comparator(type, Query::Comparator::Contains)); |
102 | } | 102 | } |
103 | 103 | ||
104 | if (!parentFolderRid.isEmpty()) { | 104 | if (!parentFolderRid.isEmpty()) { |
105 | folder.setProperty("parent", syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, parentFolderRid.toUtf8())); | 105 | folder.setParent(syncStore().resolveRemoteId(ENTITY_TYPE_FOLDER, parentFolderRid.toUtf8())); |
106 | } | 106 | } |
107 | createOrModify(bufferType, remoteId, folder, mergeCriteria); | 107 | createOrModify(bufferType, remoteId, folder, mergeCriteria); |
108 | return remoteId; | 108 | return remoteId; |
diff --git a/examples/maildirresource/maildirresource.cpp b/examples/maildirresource/maildirresource.cpp index 1eee786..a05afc6 100644 --- a/examples/maildirresource/maildirresource.cpp +++ b/examples/maildirresource/maildirresource.cpp | |||
@@ -129,16 +129,16 @@ public: | |||
129 | 129 | ||
130 | void newEntity(Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE | 130 | void newEntity(Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE |
131 | { | 131 | { |
132 | const ApplicationDomain::Mail mail{newEntity}; | 132 | auto mail = newEntity.cast<ApplicationDomain::Mail>(); |
133 | const auto mimeMessage = mail.getMimeMessagePath(); | 133 | const auto mimeMessage = mail.getMimeMessagePath(); |
134 | if (!mimeMessage.isNull()) { | 134 | if (!mimeMessage.isNull()) { |
135 | ApplicationDomain::Mail{newEntity}.setMimeMessagePath(moveMessage(mimeMessage, mail.getFolder())); | 135 | mail.setMimeMessagePath(moveMessage(mimeMessage, mail.getFolder())); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | void modifiedEntity(const Sink::ApplicationDomain::ApplicationDomainType &oldEntity, Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE | 139 | void modifiedEntity(const Sink::ApplicationDomain::ApplicationDomainType &oldEntity, Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE |
140 | { | 140 | { |
141 | ApplicationDomain::Mail newMail{newEntity}; | 141 | auto newMail = newEntity.cast<ApplicationDomain::Mail>(); |
142 | const ApplicationDomain::Mail oldMail{oldEntity}; | 142 | const ApplicationDomain::Mail oldMail{oldEntity}; |
143 | const auto mimeMessage = newMail.getMimeMessagePath(); | 143 | const auto mimeMessage = newMail.getMimeMessagePath(); |
144 | const auto newFolder = newMail.getFolder(); | 144 | const auto newFolder = newMail.getFolder(); |
@@ -190,7 +190,7 @@ public: | |||
190 | 190 | ||
191 | void newEntity(Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE | 191 | void newEntity(Sink::ApplicationDomain::ApplicationDomainType &newEntity) Q_DECL_OVERRIDE |
192 | { | 192 | { |
193 | auto folderName = newEntity.getProperty("name").toString(); | 193 | auto folderName = Sink::ApplicationDomain::Folder{newEntity}.getName(); |
194 | const auto path = mMaildirPath + "/" + folderName; | 194 | const auto path = mMaildirPath + "/" + folderName; |
195 | KPIM::Maildir maildir(path, false); | 195 | KPIM::Maildir maildir(path, false); |
196 | maildir.create(); | 196 | maildir.create(); |
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 4a33d17..4afe328 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -148,7 +148,7 @@ private slots: | |||
148 | auto facade = TestDummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); | 148 | auto facade = TestDummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
149 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 149 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
150 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 150 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
151 | subfolder->setProperty("parent", "id"); | 151 | subfolder->setParent("id"); |
152 | facade->results << folder << subfolder; | 152 | facade->results << folder << subfolder; |
153 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 153 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
154 | 154 | ||
@@ -170,7 +170,7 @@ private slots: | |||
170 | auto facade = TestDummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); | 170 | auto facade = TestDummyResourceFacade<Sink::ApplicationDomain::Folder>::registerFacade(); |
171 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 171 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
172 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 172 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
173 | subfolder->setProperty("parent", "id"); | 173 | subfolder->setParent("id"); |
174 | facade->results << folder << subfolder; | 174 | facade->results << folder << subfolder; |
175 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 175 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
176 | 176 | ||
@@ -192,7 +192,7 @@ private slots: | |||
192 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("dummyresource.instance1", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 192 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("dummyresource.instance1", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
193 | auto subfolder = | 193 | auto subfolder = |
194 | QSharedPointer<Sink::ApplicationDomain::Folder>::create("dummyresource.instance1", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 194 | QSharedPointer<Sink::ApplicationDomain::Folder>::create("dummyresource.instance1", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
195 | subfolder->setProperty("parent", "id"); | 195 | subfolder->setParent("id"); |
196 | facade->results << folder << subfolder; | 196 | facade->results << folder << subfolder; |
197 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); | 197 | ResourceConfig::addResource("dummyresource.instance1", "dummyresource"); |
198 | 198 | ||
diff --git a/tests/domainadaptortest.cpp b/tests/domainadaptortest.cpp index 4fd04db..a17152e 100644 --- a/tests/domainadaptortest.cpp +++ b/tests/domainadaptortest.cpp | |||
@@ -110,6 +110,7 @@ private slots: | |||
110 | Sink::ApplicationDomain::Mail mail; | 110 | Sink::ApplicationDomain::Mail mail; |
111 | mail.setExtractedSubject("summary"); | 111 | mail.setExtractedSubject("summary"); |
112 | mail.setMimeMessage("foobar"); | 112 | mail.setMimeMessage("foobar"); |
113 | mail.setFolder("folder"); | ||
113 | 114 | ||
114 | flatbuffers::FlatBufferBuilder metadataFbb; | 115 | flatbuffers::FlatBufferBuilder metadataFbb; |
115 | auto metadataBuilder = Sink::MetadataBuilder(metadataFbb); | 116 | auto metadataBuilder = Sink::MetadataBuilder(metadataFbb); |
@@ -134,6 +135,7 @@ private slots: | |||
134 | Sink::ApplicationDomain::Mail readMail{QByteArray{}, QByteArray{}, 0, adaptor}; | 135 | Sink::ApplicationDomain::Mail readMail{QByteArray{}, QByteArray{}, 0, adaptor}; |
135 | QCOMPARE(readMail.getSubject(), mail.getSubject()); | 136 | QCOMPARE(readMail.getSubject(), mail.getSubject()); |
136 | QCOMPARE(readMail.getMimeMessage(), mail.getMimeMessage()); | 137 | QCOMPARE(readMail.getMimeMessage(), mail.getMimeMessage()); |
138 | QCOMPARE(readMail.getFolder(), mail.getFolder()); | ||
137 | } | 139 | } |
138 | 140 | ||
139 | } | 141 | } |
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index 702239d..0e2f6fa 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp | |||
@@ -69,11 +69,11 @@ class MailQueryBenchmark : public QObject | |||
69 | const auto date = QDateTime::currentDateTimeUtc(); | 69 | const auto date = QDateTime::currentDateTimeUtc(); |
70 | for (int i = 0; i < count; i++) { | 70 | for (int i = 0; i < count; i++) { |
71 | auto domainObject = Mail::Ptr::create(); | 71 | auto domainObject = Mail::Ptr::create(); |
72 | domainObject->setProperty("uid", "uid"); | 72 | domainObject->setUid("uid"); |
73 | domainObject->setProperty("subject", QString("subject%1").arg(i)); | 73 | domainObject->setExtractedSubject(QString("subject%1").arg(i)); |
74 | domainObject->setProperty("date", date.addSecs(count)); | 74 | domainObject->setExtractedDate(date.addSecs(count)); |
75 | domainObject->setProperty("folder", "folder1"); | 75 | domainObject->setFolder("folder1"); |
76 | // domainObject->setProperty("attachment", attachment); | 76 | // domainObject->setAttachment(attachment); |
77 | const auto command = createCommand<Mail>(*domainObject, *domainTypeAdaptorFactory); | 77 | const auto command = createCommand<Mail>(*domainObject, *domainTypeAdaptorFactory); |
78 | pipeline->newEntity(command.data(), command.size()); | 78 | pipeline->newEntity(command.data(), command.size()); |
79 | } | 79 | } |
diff --git a/tests/pipelinebenchmark.cpp b/tests/pipelinebenchmark.cpp index 2e614ef..341c733 100644 --- a/tests/pipelinebenchmark.cpp +++ b/tests/pipelinebenchmark.cpp | |||
@@ -73,10 +73,10 @@ class PipelineBenchmark : public QObject | |||
73 | const auto date = QDateTime::currentDateTimeUtc(); | 73 | const auto date = QDateTime::currentDateTimeUtc(); |
74 | for (int i = 0; i < count; i++) { | 74 | for (int i = 0; i < count; i++) { |
75 | auto domainObject = Sink::ApplicationDomain::Mail::Ptr::create(); | 75 | auto domainObject = Sink::ApplicationDomain::Mail::Ptr::create(); |
76 | domainObject->setProperty("uid", "uid"); | 76 | domainObject->setUid("uid"); |
77 | domainObject->setProperty("subject", QString("subject%1").arg(i)); | 77 | domainObject->setExtractedSubject(QString("subject%1").arg(i)); |
78 | domainObject->setProperty("date", date.addSecs(count)); | 78 | domainObject->setExtractedDate(date.addSecs(count)); |
79 | domainObject->setProperty("folder", "folder1"); | 79 | domainObject->setFolder("folder1"); |
80 | // domainObject->setProperty("attachment", attachment); | 80 | // domainObject->setProperty("attachment", attachment); |
81 | const auto command = createCommand<Sink::ApplicationDomain::Mail>(*domainObject, *domainTypeAdaptorFactory); | 81 | const auto command = createCommand<Sink::ApplicationDomain::Mail>(*domainObject, *domainTypeAdaptorFactory); |
82 | pipeline->newEntity(command.data(), command.size()); | 82 | pipeline->newEntity(command.data(), command.size()); |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 2eb1239..574e68d 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -228,25 +228,13 @@ private slots: | |||
228 | { | 228 | { |
229 | // Setup | 229 | // Setup |
230 | { | 230 | { |
231 | Folder folder("sink.dummy.instance1"); | 231 | auto folder = ApplicationDomainType::createEntity<Folder>("sink.dummy.instance1"); |
232 | Sink::Store::create<Folder>(folder).exec().waitForFinished(); | 232 | VERIFYEXEC(Sink::Store::create<Folder>(folder)); |
233 | 233 | auto subfolder = ApplicationDomainType::createEntity<Folder>("sink.dummy.instance1"); | |
234 | Sink::Query query; | 234 | subfolder.setParent(folder.identifier()); |
235 | query.resourceFilter("sink.dummy.instance1"); | 235 | VERIFYEXEC(Sink::Store::create<Folder>(subfolder)); |
236 | |||
237 | // Ensure all local data is processed | 236 | // Ensure all local data is processed |
238 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); | 237 | VERIFYEXEC(Sink::ResourceControl::flushMessageQueue(QByteArrayList() << "sink.dummy.instance1")); |
239 | |||
240 | auto model = Sink::Store::loadModel<Folder>(query); | ||
241 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | ||
242 | QCOMPARE(model->rowCount(), 1); | ||
243 | |||
244 | auto folderEntity = model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Folder::Ptr>(); | ||
245 | QVERIFY(!folderEntity->identifier().isEmpty()); | ||
246 | |||
247 | Folder subfolder("sink.dummy.instance1"); | ||
248 | subfolder.setProperty("parent", folderEntity->identifier()); | ||
249 | Sink::Store::create<Folder>(subfolder).exec().waitForFinished(); | ||
250 | } | 238 | } |
251 | 239 | ||
252 | // Test | 240 | // Test |
@@ -271,14 +259,14 @@ private slots: | |||
271 | // Setup | 259 | // Setup |
272 | { | 260 | { |
273 | Mail mail("sink.dummy.instance1"); | 261 | Mail mail("sink.dummy.instance1"); |
274 | mail.setProperty("uid", "test1"); | 262 | mail.setUid("test1"); |
275 | mail.setProperty("sender", "doe@example.org"); | 263 | mail.setProperty("sender", "doe@example.org"); |
276 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 264 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
277 | } | 265 | } |
278 | 266 | ||
279 | { | 267 | { |
280 | Mail mail("sink.dummy.instance1"); | 268 | Mail mail("sink.dummy.instance1"); |
281 | mail.setProperty("uid", "test2"); | 269 | mail.setUid("test2"); |
282 | mail.setProperty("sender", "doe@example.org"); | 270 | mail.setProperty("sender", "doe@example.org"); |
283 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 271 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
284 | } | 272 | } |
@@ -319,8 +307,8 @@ private slots: | |||
319 | QVERIFY(!folderEntity->identifier().isEmpty()); | 307 | QVERIFY(!folderEntity->identifier().isEmpty()); |
320 | 308 | ||
321 | Mail mail("sink.dummy.instance1"); | 309 | Mail mail("sink.dummy.instance1"); |
322 | mail.setProperty("uid", "test1"); | 310 | mail.setUid("test1"); |
323 | mail.setProperty("folder", folderEntity->identifier()); | 311 | mail.setFolder(folderEntity->identifier()); |
324 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 312 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
325 | } | 313 | } |
326 | 314 | ||
@@ -363,18 +351,18 @@ private slots: | |||
363 | QVERIFY(!folderEntity->identifier().isEmpty()); | 351 | QVERIFY(!folderEntity->identifier().isEmpty()); |
364 | 352 | ||
365 | Mail mail("sink.dummy.instance1"); | 353 | Mail mail("sink.dummy.instance1"); |
366 | mail.setProperty("uid", "test1"); | 354 | mail.setUid("test1"); |
367 | mail.setProperty("folder", folderEntity->identifier()); | 355 | mail.setFolder(folderEntity->identifier()); |
368 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 356 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
369 | 357 | ||
370 | Mail mail1("sink.dummy.instance1"); | 358 | Mail mail1("sink.dummy.instance1"); |
371 | mail1.setProperty("uid", "test1"); | 359 | mail1.setUid("test1"); |
372 | mail1.setProperty("folder", "foobar"); | 360 | mail1.setFolder("foobar"); |
373 | Sink::Store::create<Mail>(mail1).exec().waitForFinished(); | 361 | Sink::Store::create<Mail>(mail1).exec().waitForFinished(); |
374 | 362 | ||
375 | Mail mail2("sink.dummy.instance1"); | 363 | Mail mail2("sink.dummy.instance1"); |
376 | mail2.setProperty("uid", "test2"); | 364 | mail2.setUid("test2"); |
377 | mail2.setProperty("folder", folderEntity->identifier()); | 365 | mail2.setFolder(folderEntity->identifier()); |
378 | Sink::Store::create<Mail>(mail2).exec().waitForFinished(); | 366 | Sink::Store::create<Mail>(mail2).exec().waitForFinished(); |
379 | } | 367 | } |
380 | 368 | ||
@@ -417,23 +405,23 @@ private slots: | |||
417 | const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); | 405 | const auto date = QDateTime(QDate(2015, 7, 7), QTime(12, 0)); |
418 | { | 406 | { |
419 | Mail mail("sink.dummy.instance1"); | 407 | Mail mail("sink.dummy.instance1"); |
420 | mail.setProperty("uid", "testSecond"); | 408 | mail.setUid("testSecond"); |
421 | mail.setProperty("folder", folderEntity->identifier()); | 409 | mail.setFolder(folderEntity->identifier()); |
422 | mail.setProperty("date", date.addDays(-1)); | 410 | mail.setExtractedDate(date.addDays(-1)); |
423 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 411 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
424 | } | 412 | } |
425 | { | 413 | { |
426 | Mail mail("sink.dummy.instance1"); | 414 | Mail mail("sink.dummy.instance1"); |
427 | mail.setProperty("uid", "testLatest"); | 415 | mail.setUid("testLatest"); |
428 | mail.setProperty("folder", folderEntity->identifier()); | 416 | mail.setFolder(folderEntity->identifier()); |
429 | mail.setProperty("date", date); | 417 | mail.setExtractedDate(date); |
430 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 418 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
431 | } | 419 | } |
432 | { | 420 | { |
433 | Mail mail("sink.dummy.instance1"); | 421 | Mail mail("sink.dummy.instance1"); |
434 | mail.setProperty("uid", "testLast"); | 422 | mail.setUid("testLast"); |
435 | mail.setProperty("folder", folderEntity->identifier()); | 423 | mail.setFolder(folderEntity->identifier()); |
436 | mail.setProperty("date", date.addDays(-2)); | 424 | mail.setExtractedDate(date.addDays(-2)); |
437 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); | 425 | Sink::Store::create<Mail>(mail).exec().waitForFinished(); |
438 | } | 426 | } |
439 | } | 427 | } |