summaryrefslogtreecommitdiffstats
path: root/common/domain/typeimplementations.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-08 14:27:25 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-08 14:34:54 +0200
commit778b01181604dc2eae2013f2dc37db6d647b526a (patch)
tree739050aa453fe8adf140d8e6e65b870a10d8a39d /common/domain/typeimplementations.cpp
parent3657dcd309f30b704801dcaf3e43b71ef703c0de (diff)
downloadsink-778b01181604dc2eae2013f2dc37db6d647b526a.tar.gz
sink-778b01181604dc2eae2013f2dc37db6d647b526a.zip
Gather required databases from index definitions.
Diffstat (limited to 'common/domain/typeimplementations.cpp')
-rw-r--r--common/domain/typeimplementations.cpp78
1 files changed, 60 insertions, 18 deletions
diff --git a/common/domain/typeimplementations.cpp b/common/domain/typeimplementations.cpp
index a87e73d..4e61bad 100644
--- a/common/domain/typeimplementations.cpp
+++ b/common/domain/typeimplementations.cpp
@@ -28,6 +28,7 @@
28#include "entity_generated.h" 28#include "entity_generated.h"
29#include "mail/threadindexer.h" 29#include "mail/threadindexer.h"
30#include "domainadaptor.h" 30#include "domainadaptor.h"
31#include "typeimplementations_p.h"
31 32
32using namespace Sink; 33using namespace Sink;
33using namespace Sink::ApplicationDomain; 34using namespace Sink::ApplicationDomain;
@@ -35,22 +36,43 @@ using namespace Sink::ApplicationDomain;
35#define SINK_REGISTER_SERIALIZER(MAPPER, ENTITYTYPE, PROPERTY, LOWERCASEPROPERTY) \ 36#define SINK_REGISTER_SERIALIZER(MAPPER, ENTITYTYPE, PROPERTY, LOWERCASEPROPERTY) \
36 MAPPER.addMapping<ENTITYTYPE::PROPERTY, Sink::ApplicationDomain::Buffer::ENTITYTYPE, Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder>(&Sink::ApplicationDomain::Buffer::ENTITYTYPE::LOWERCASEPROPERTY, &Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder::add_##LOWERCASEPROPERTY); 37 MAPPER.addMapping<ENTITYTYPE::PROPERTY, Sink::ApplicationDomain::Buffer::ENTITYTYPE, Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder>(&Sink::ApplicationDomain::Buffer::ENTITYTYPE::LOWERCASEPROPERTY, &Sink::ApplicationDomain::Buffer::ENTITYTYPE##Builder::add_##LOWERCASEPROPERTY);
37 38
39typedef IndexConfig<Mail,
40 ValueIndex<Mail::Date>,
41 ValueIndex<Mail::Folder>,
42 ValueIndex<Mail::ParentMessageId>,
43 ValueIndex<Mail::MessageId>,
44 SortedIndex<Mail::Folder, Mail::Date>,
45 SecondaryIndex<Mail::MessageId, Mail::ThreadId>,
46 SecondaryIndex<Mail::ThreadId, Mail::MessageId>,
47 CustomSecondaryIndex<Mail::MessageId, Mail::ThreadId, ThreadIndexer>
48 > MailIndexConfig;
49
50typedef IndexConfig<Folder,
51 ValueIndex<Folder::Name>,
52 ValueIndex<Folder::Parent>
53 > FolderIndexConfig;
54
55typedef IndexConfig<Contact,
56 ValueIndex<Contact::Uid>
57 > ContactIndexConfig;
58
59typedef IndexConfig<Addressbook,
60 ValueIndex<Addressbook::Parent>
61 > AddressbookIndexConfig;
62
63typedef IndexConfig<Event,
64 ValueIndex<Event::Uid>
65 > EventIndexConfig;
66
38 67
39void TypeImplementation<Mail>::configure(TypeIndex &index) 68void TypeImplementation<Mail>::configure(TypeIndex &index)
40{ 69{
41 // index.addProperty<Mail::Sender>(); 70 MailIndexConfig::configure(index);
42 /* index.addProperty<QByteArray>(Mail::SenderName::name); */ 71}
43 /* index->addProperty<QString>(Mail::Subject::name); */
44 /* index->addFulltextProperty<QString>(Mail::Subject::name); */
45 index.addProperty<Mail::Date>();
46 index.addProperty<Mail::Folder>();
47 index.addPropertyWithSorting<Mail::Folder, Mail::Date>();
48 index.addProperty<Mail::ParentMessageId>();
49 index.addProperty<Mail::MessageId>();
50 72
51 index.addSecondaryPropertyIndexer<Mail::MessageId, Mail::ThreadId, ThreadIndexer>(); 73QMap<QByteArray, int> TypeImplementation<Mail>::typeDatabases()
52 index.addSecondaryProperty<Mail::MessageId, Mail::ThreadId>(); 74{
53 index.addSecondaryProperty<Mail::ThreadId, Mail::MessageId>(); 75 return merge(QMap<QByteArray, int>{{QByteArray{Mail::name} + ".main", 0}}, MailIndexConfig::databases());
54} 76}
55 77
56void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper) 78void TypeImplementation<Mail>::configure(IndexPropertyMapper &indexPropertyMapper)
@@ -85,10 +107,15 @@ void TypeImplementation<Mail>::configure(PropertyMapper &propertyMapper)
85 SINK_REGISTER_SERIALIZER(propertyMapper, Mail, ParentMessageId, parentMessageId); 107 SINK_REGISTER_SERIALIZER(propertyMapper, Mail, ParentMessageId, parentMessageId);
86} 108}
87 109
110
88void TypeImplementation<Folder>::configure(TypeIndex &index) 111void TypeImplementation<Folder>::configure(TypeIndex &index)
89{ 112{
90 index.addProperty<QByteArray>(Folder::Parent::name); 113 FolderIndexConfig::configure(index);
91 index.addProperty<QString>(Folder::Name::name); 114}
115
116QMap<QByteArray, int> TypeImplementation<Folder>::typeDatabases()
117{
118 return merge(QMap<QByteArray, int>{{QByteArray{Folder::name} + ".main", 0}}, FolderIndexConfig::databases());
92} 119}
93 120
94void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper) 121void TypeImplementation<Folder>::configure(PropertyMapper &propertyMapper)
@@ -108,7 +135,12 @@ void TypeImplementation<Folder>::configure(IndexPropertyMapper &)
108 135
109void TypeImplementation<Contact>::configure(TypeIndex &index) 136void TypeImplementation<Contact>::configure(TypeIndex &index)
110{ 137{
111 index.addProperty<QByteArray>(Contact::Uid::name); 138 ContactIndexConfig::configure(index);
139}
140
141QMap<QByteArray, int> TypeImplementation<Contact>::typeDatabases()
142{
143 return merge(QMap<QByteArray, int>{{QByteArray{Contact::name} + ".main", 0}}, ContactIndexConfig::databases());
112} 144}
113 145
114void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper) 146void TypeImplementation<Contact>::configure(PropertyMapper &propertyMapper)
@@ -130,8 +162,12 @@ void TypeImplementation<Contact>::configure(IndexPropertyMapper &)
130 162
131void TypeImplementation<Addressbook>::configure(TypeIndex &index) 163void TypeImplementation<Addressbook>::configure(TypeIndex &index)
132{ 164{
133 index.addProperty<QByteArray>(Addressbook::Parent::name); 165 AddressbookIndexConfig::configure(index);
134 index.addProperty<QString>(Addressbook::Name::name); 166}
167
168QMap<QByteArray, int> TypeImplementation<Addressbook>::typeDatabases()
169{
170 return merge(QMap<QByteArray, int>{{QByteArray{Addressbook::name} + ".main", 0}}, AddressbookIndexConfig::databases());
135} 171}
136 172
137void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper) 173void TypeImplementation<Addressbook>::configure(PropertyMapper &propertyMapper)
@@ -148,7 +184,12 @@ void TypeImplementation<Addressbook>::configure(IndexPropertyMapper &)
148 184
149void TypeImplementation<Event>::configure(TypeIndex &index) 185void TypeImplementation<Event>::configure(TypeIndex &index)
150{ 186{
151 index.addProperty<QByteArray>(Event::Uid::name); 187 EventIndexConfig::configure(index);
188}
189
190QMap<QByteArray, int> TypeImplementation<Event>::typeDatabases()
191{
192 return merge(QMap<QByteArray, int>{{QByteArray{Event::name} + ".main", 0}}, EventIndexConfig::databases());
152} 193}
153 194
154void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper) 195void TypeImplementation<Event>::configure(PropertyMapper &propertyMapper)
@@ -163,3 +204,4 @@ void TypeImplementation<Event>::configure(IndexPropertyMapper &)
163{ 204{
164 205
165} 206}
207