From 63919d3040295415306267df7b66e7a5e2c9395f Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 8 Jun 2015 10:47:57 +0200 Subject: Differentiate between resource name and instance identifier --- common/clientapi.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'common/clientapi.h') diff --git a/common/clientapi.h b/common/clientapi.h index 38ec1ee..4948c59 100644 --- a/common/clientapi.h +++ b/common/clientapi.h @@ -193,6 +193,13 @@ public: return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/akonadi2/storage"; } + static QByteArray resourceName(const QByteArray &instanceIdentifier) + { + auto split = instanceIdentifier.split('.'); + split.removeLast(); + return split.join('.'); + } + /** * Asynchronusly load a dataset */ @@ -209,7 +216,7 @@ public: KAsync::iterate(query.resources) .template each([query, resultSet](const QByteArray &resource, KAsync::Future &future) { //TODO pass resource identifier to factory - auto facade = FacadeFactory::instance().getFacade(resource); + auto facade = FacadeFactory::instance().getFacade(resourceName(resource)); if (facade) { facade->load(query, resultSet).template then([&future](){future.setFinished();}).exec(); //Keep the facade alive for the lifetime of the resultSet. @@ -254,7 +261,7 @@ public: template static void create(const DomainType &domainObject, const QByteArray &resourceIdentifier) { //Potentially move to separate thread as well - auto facade = FacadeFactory::instance().getFacade(resourceIdentifier); + auto facade = FacadeFactory::instance().getFacade(resourceName(resourceIdentifier)); facade->create(domainObject).exec().waitForFinished(); //TODO return job? } @@ -267,7 +274,7 @@ public: template static void modify(const DomainType &domainObject, const QByteArray &resourceIdentifier) { //Potentially move to separate thread as well - auto facade = FacadeFactory::instance().getFacade(resourceIdentifier); + auto facade = FacadeFactory::instance().getFacade(resourceName(resourceIdentifier)); facade->modify(domainObject).exec().waitForFinished(); //TODO return job? } @@ -278,7 +285,7 @@ public: template static void remove(const DomainType &domainObject, const QByteArray &resourceIdentifier) { //Potentially move to separate thread as well - auto facade = FacadeFactory::instance().getFacade(resourceIdentifier); + auto facade = FacadeFactory::instance().getFacade(resourceName(resourceIdentifier)); facade->remove(domainObject).exec().waitForFinished(); //TODO return job? } -- cgit v1.2.3