From f7a42de9bfd6e34f1dc46da433d3f45976b1cd0e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 15 Feb 2017 16:21:06 +0100 Subject: PropertyParser to properly parse different property types. --- sinksh/syntax_modules/sink_create.cpp | 6 +++--- sinksh/syntax_modules/sink_list.cpp | 6 +++--- sinksh/syntax_modules/sink_modify.cpp | 9 +++++---- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'sinksh/syntax_modules') diff --git a/sinksh/syntax_modules/sink_create.cpp b/sinksh/syntax_modules/sink_create.cpp index 9f5d010..f18a990 100644 --- a/sinksh/syntax_modules/sink_create.cpp +++ b/sinksh/syntax_modules/sink_create.cpp @@ -25,12 +25,11 @@ #include "common/resource.h" #include "common/storage.h" -#include "common/domain/event.h" -#include "common/domain/folder.h" #include "common/resourceconfig.h" #include "common/log.h" #include "common/storage.h" #include "common/definitions.h" +#include "common/propertyparser.h" #include "sinksh_utils.h" #include "state.h" @@ -62,7 +61,8 @@ bool create(const QStringList &allArgs, State &state) auto map = SinkshUtils::keyValueMapFromArgs(args); for (auto i = map.begin(); i != map.end(); ++i) { - object->setProperty(i.key().toLatin1(), i.value()); + const auto property = i.key().toLatin1(); + object->setProperty(property, Sink::PropertyParser::parse(type.toLatin1(), property, i.value())); } auto result = store.create(*object).exec(); diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp index 837f60d..d63749b 100644 --- a/sinksh/syntax_modules/sink_list.cpp +++ b/sinksh/syntax_modules/sink_list.cpp @@ -25,13 +25,12 @@ #include "common/resource.h" #include "common/storage.h" -#include "common/domain/event.h" -#include "common/domain/folder.h" #include "common/resourceconfig.h" #include "common/log.h" #include "common/storage.h" #include "common/definitions.h" #include "common/store.h" +#include "common/propertyparser.h" #include "sinksh_utils.h" #include "state.h" @@ -109,7 +108,8 @@ bool list(const QStringList &args_, State &state) if (options.options.contains("filter")) { for (const auto &f : options.options.value("filter")) { auto filter = f.split("="); - query.filter(filter.at(0).toLatin1(), QVariant::fromValue(Sink::ApplicationDomain::Reference{filter.at(1).toLatin1()})); + const auto property = filter.value(0).toLatin1(); + query.filter(property, Sink::PropertyParser::parse(type.toLatin1(), property, filter.value(1))); } } if (options.options.contains("id")) { diff --git a/sinksh/syntax_modules/sink_modify.cpp b/sinksh/syntax_modules/sink_modify.cpp index 4d637d8..2579550 100644 --- a/sinksh/syntax_modules/sink_modify.cpp +++ b/sinksh/syntax_modules/sink_modify.cpp @@ -25,12 +25,11 @@ #include "common/resource.h" #include "common/storage.h" -#include "common/domain/event.h" -#include "common/domain/folder.h" #include "common/resourceconfig.h" #include "common/log.h" #include "common/storage.h" #include "common/definitions.h" +#include "common/propertyparser.h" #include "sinksh_utils.h" #include "state.h" @@ -65,7 +64,8 @@ bool modify(const QStringList &args, State &state) auto map = SinkshUtils::keyValueMapFromArgs(args); for (auto i = map.begin(); i != map.end(); ++i) { - object->setProperty(i.key().toLatin1(), i.value()); + const auto property = i.key().toLatin1(); + object->setProperty(property, Sink::PropertyParser::parse(type.toLatin1(), property, i.value())); } auto result = store.modify(*object).exec(); @@ -91,7 +91,8 @@ bool resource(const QStringList &args, State &state) auto map = SinkshUtils::keyValueMapFromArgs(args); for (auto i = map.begin(); i != map.end(); ++i) { - object->setProperty(i.key().toLatin1(), i.value()); + const auto property = i.key().toLatin1(); + object->setProperty(property, Sink::PropertyParser::parse("resource", property, i.value())); } auto result = store.modify(*object).exec(); -- cgit v1.2.3