Changeset View
Changeset View
Standalone View
Standalone View
common/store.cpp
Show First 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 107 | } else { | |||
---|---|---|---|---|---|
112 | resourceQuery.request<ApplicationDomain::SinkResource::Capabilities>(); | 112 | resourceQuery.request<ApplicationDomain::SinkResource::Capabilities>(); | ||
113 | if (query.liveQuery()) { | 113 | if (query.liveQuery()) { | ||
114 | SinkTraceCtx(ctx) << "Listening for new resources."; | 114 | SinkTraceCtx(ctx) << "Listening for new resources."; | ||
115 | resourceQuery.setFlags(Query::LiveQuery); | 115 | resourceQuery.setFlags(Query::LiveQuery); | ||
116 | } | 116 | } | ||
117 | 117 | | |||
118 | //Filter resources by available content types (unless the query already specifies a capability filter) | 118 | //Filter resources by available content types (unless the query already specifies a capability filter) | ||
119 | auto resourceFilter = query.getResourceFilter(); | 119 | auto resourceFilter = query.getResourceFilter(); | ||
120 | if (!resourceFilter.propertyFilter.contains(ApplicationDomain::SinkResource::Capabilities::name)) { | 120 | if (!resourceFilter.propertyFilter.contains({ApplicationDomain::SinkResource::Capabilities::name})) { | ||
121 | resourceFilter.propertyFilter.insert(ApplicationDomain::SinkResource::Capabilities::name, Query::Comparator{ApplicationDomain::getTypeName<DomainType>(), Query::Comparator::Contains}); | 121 | resourceFilter.propertyFilter.insert({ApplicationDomain::SinkResource::Capabilities::name}, Query::Comparator{ApplicationDomain::getTypeName<DomainType>(), Query::Comparator::Contains}); | ||
122 | } | 122 | } | ||
123 | resourceQuery.setFilter(resourceFilter); | 123 | resourceQuery.setFilter(resourceFilter); | ||
124 | resourceQuery.requestedProperties << resourceFilter.propertyFilter.keys(); | 124 | for (auto const &properties : resourceFilter.propertyFilter.keys()) { | ||
125 | resourceQuery.requestedProperties << properties; | ||||
126 | } | ||||
125 | 127 | | |||
126 | auto result = facade->load(resourceQuery, resourceCtx); | 128 | auto result = facade->load(resourceQuery, resourceCtx); | ||
127 | auto emitter = result.second; | 129 | auto emitter = result.second; | ||
128 | emitter->onAdded([=](const ApplicationDomain::SinkResource::Ptr &resource) { | 130 | emitter->onAdded([=](const ApplicationDomain::SinkResource::Ptr &resource) { | ||
129 | SinkTraceCtx(resourceCtx) << "Found new resources: " << resource->identifier(); | 131 | SinkTraceCtx(resourceCtx) << "Found new resources: " << resource->identifier(); | ||
130 | const auto resourceType = ResourceConfig::getResourceType(resource->identifier()); | 132 | const auto resourceType = ResourceConfig::getResourceType(resource->identifier()); | ||
131 | Q_ASSERT(!resourceType.isEmpty()); | 133 | Q_ASSERT(!resourceType.isEmpty()); | ||
132 | queryResource<DomainType>(resourceType, resource->identifier(), query, aggregatingEmitter, ctx).exec(); | 134 | queryResource<DomainType>(resourceType, resource->identifier(), query, aggregatingEmitter, ctx).exec(); | ||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Line(s) | |||||
398 | { | 400 | { | ||
399 | return synchronize(Sink::SyncScope{query}); | 401 | return synchronize(Sink::SyncScope{query}); | ||
400 | } | 402 | } | ||
401 | 403 | | |||
402 | KAsync::Job<void> Store::synchronize(const Sink::SyncScope &scope) | 404 | KAsync::Job<void> Store::synchronize(const Sink::SyncScope &scope) | ||
403 | { | 405 | { | ||
404 | auto resourceFilter = scope.getResourceFilter(); | 406 | auto resourceFilter = scope.getResourceFilter(); | ||
405 | //Filter resources by type by default | 407 | //Filter resources by type by default | ||
406 | if (!resourceFilter.propertyFilter.contains(ApplicationDomain::SinkResource::Capabilities::name) && !scope.type().isEmpty()) { | 408 | if (!resourceFilter.propertyFilter.contains({ApplicationDomain::SinkResource::Capabilities::name}) && !scope.type().isEmpty()) { | ||
407 | resourceFilter.propertyFilter.insert(ApplicationDomain::SinkResource::Capabilities::name, Query::Comparator{scope.type(), Query::Comparator::Contains}); | 409 | resourceFilter.propertyFilter.insert({ApplicationDomain::SinkResource::Capabilities::name}, Query::Comparator{scope.type(), Query::Comparator::Contains}); | ||
408 | } | 410 | } | ||
409 | Sink::Query query; | 411 | Sink::Query query; | ||
410 | query.setFilter(resourceFilter); | 412 | query.setFilter(resourceFilter); | ||
411 | SinkLog() << "Synchronizing all resource matching: " << query; | 413 | SinkLog() << "Synchronizing all resource matching: " << query; | ||
412 | return fetchAll<ApplicationDomain::SinkResource>(query) | 414 | return fetchAll<ApplicationDomain::SinkResource>(query) | ||
413 | .template each([scope](const ApplicationDomain::SinkResource::Ptr &resource) -> KAsync::Job<void> { | 415 | .template each([scope](const ApplicationDomain::SinkResource::Ptr &resource) -> KAsync::Job<void> { | ||
414 | return synchronize(resource->identifier(), scope); | 416 | return synchronize(resource->identifier(), scope); | ||
415 | }); | 417 | }); | ||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |