diff options
Diffstat (limited to 'sinksh/syntax_modules/sink_create.cpp')
-rw-r--r-- | sinksh/syntax_modules/sink_create.cpp | 25 |
1 files changed, 25 insertions, 0 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 | ||
142 | bool 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 | ||
143 | Syntax::List syntax() | 167 | Syntax::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; |