summaryrefslogtreecommitdiffstats
path: root/sinksh/syntax_modules
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-15 10:44:25 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-12-15 10:44:25 +0100
commitd09517a4d4fcdf496c0298ef8b8f54f3c9120293 (patch)
tree7b35e8ebe88ae5ff47387deb428c3ff8da42d28e /sinksh/syntax_modules
parent4e9f8f2590f55b39b9ff70d2c375fc2d25d2500d (diff)
downloadsink-d09517a4d4fcdf496c0298ef8b8f54f3c9120293.tar.gz
sink-d09517a4d4fcdf496c0298ef8b8f54f3c9120293.zip
sinksh fixes
Diffstat (limited to 'sinksh/syntax_modules')
-rw-r--r--sinksh/syntax_modules/sink_create.cpp25
-rw-r--r--sinksh/syntax_modules/sink_list.cpp15
2 files changed, 39 insertions, 1 deletions
diff --git a/sinksh/syntax_modules/sink_create.cpp b/sinksh/syntax_modules/sink_create.cpp
index 4fedff4..95a4cce 100644
--- a/sinksh/syntax_modules/sink_create.cpp
+++ b/sinksh/syntax_modules/sink_create.cpp
@@ -139,6 +139,30 @@ bool account(const QStringList &args, State &state)
139 return true; 139 return true;
140} 140}
141 141
142bool identity(const QStringList &args, State &state)
143{
144 auto &store = SinkshUtils::getStore("identity");
145
146 auto map = SinkshUtils::keyValueMapFromArgs(args);
147
148 auto identifier = map.take("identifier").toLatin1();
149
150 auto object = ApplicationDomain::ApplicationDomainType::createEntity<ApplicationDomain::Identity>("", identifier);
151
152 for (auto i = map.begin(); i != map.end(); ++i) {
153 object.setProperty(i.key().toLatin1(), i.value());
154 }
155
156 auto result = store.create(object).exec();
157 result.waitForFinished();
158 if (result.errorCode()) {
159 state.printError(QObject::tr("An error occurred while creating the entity: %1").arg(result.errorMessage()),
160 "sink_create_e" + QString::number(result.errorCode()));
161 }
162
163 return true;
164}
165
142 166
143Syntax::List syntax() 167Syntax::List syntax()
144{ 168{
@@ -147,6 +171,7 @@ Syntax::List syntax()
147 Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create); 171 Syntax create("create", QObject::tr("Create items in a resource"), &SinkCreate::create);
148 create.children << Syntax("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource); 172 create.children << Syntax("resource", QObject::tr("Creates a new resource"), &SinkCreate::resource);
149 create.children << Syntax("account", QObject::tr("Creates a new account"), &SinkCreate::account); 173 create.children << Syntax("account", QObject::tr("Creates a new account"), &SinkCreate::account);
174 create.children << Syntax("identity", QObject::tr("Creates a new identity"), &SinkCreate::identity);
150 175
151 syntax << create; 176 syntax << create;
152 return syntax; 177 return syntax;
diff --git a/sinksh/syntax_modules/sink_list.cpp b/sinksh/syntax_modules/sink_list.cpp
index bb2f1fe..8507d48 100644
--- a/sinksh/syntax_modules/sink_list.cpp
+++ b/sinksh/syntax_modules/sink_list.cpp
@@ -82,7 +82,20 @@ bool list(const QStringList &args, State &state)
82 line << o.resourceInstanceIdentifier(); 82 line << o.resourceInstanceIdentifier();
83 line << o.identifier(); 83 line << o.identifier();
84 for (const auto &prop: query.requestedProperties) { 84 for (const auto &prop: query.requestedProperties) {
85 line << o.getProperty(prop).toString(); 85 const auto value = o.getProperty(prop);
86 if (value.isValid()) {
87 if (value.canConvert<QString>()) {
88 line << value.toString();
89 } else if (value.canConvert<QByteArray>()) {
90 line << value.toByteArray();
91 } else if (value.canConvert<QByteArrayList>()) {
92 line << value.value<QByteArrayList>().join(", ");
93 } else {
94 line << QString("Unprintable type: %1").arg(value.typeName());
95 }
96 } else {
97 line << QString{};
98 }
86 } 99 }
87 state.stageTableLine(line); 100 state.stageTableLine(line);
88 } 101 }