comparison OrthancServer/ServerContext.cpp @ 1008:187ed107a59f lua-scripting

modify command
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Jul 2014 18:14:24 +0200
parents 871c49c9b11d
children 26642cecd36d
comparison
equal deleted inserted replaced
1007:871c49c9b11d 1008:187ed107a59f
43 #include <EmbeddedResources.h> 43 #include <EmbeddedResources.h>
44 #include <dcmtk/dcmdata/dcfilefo.h> 44 #include <dcmtk/dcmdata/dcfilefo.h>
45 45
46 46
47 #include "Scheduler/DeleteInstanceCommand.h" 47 #include "Scheduler/DeleteInstanceCommand.h"
48 #include "Scheduler/ModifyInstanceCommand.h"
48 #include "Scheduler/StoreScuCommand.h" 49 #include "Scheduler/StoreScuCommand.h"
49 #include "Scheduler/StorePeerCommand.h" 50 #include "Scheduler/StorePeerCommand.h"
50 51
51 52
52 53
148 OrthancPeerParameters parameters; 149 OrthancPeerParameters parameters;
149 Configuration::GetOrthancPeer(parameters, peer); 150 Configuration::GetOrthancPeer(parameters, peer);
150 return new StorePeerCommand(context, parameters); 151 return new StorePeerCommand(context, parameters);
151 } 152 }
152 153
154 if (operation == "modify")
155 {
156 LOG(INFO) << "Lua script to modify instance " << parameters["instance"].asString();
157 std::auto_ptr<ModifyInstanceCommand> command(new ModifyInstanceCommand(context));
158
159 if (parameters.isMember("replacements"))
160 {
161 const Json::Value& replacements = parameters["replacements"];
162 if (replacements.type() != Json::objectValue)
163 {
164 throw OrthancException(ErrorCode_BadParameterType);
165 }
166
167 Json::Value::Members members = replacements.getMemberNames();
168 for (Json::Value::Members::const_iterator
169 it = members.begin(); it != members.end(); ++it)
170 {
171 command->GetModification().Replace(FromDcmtkBridge::ParseTag(*it),
172 replacements[*it].asString());
173 }
174
175 // TODO OTHER PARAMETERS OF MODIFY
176 }
177
178 return command.release();
179 }
180
153 throw OrthancException(ErrorCode_ParameterOutOfRange); 181 throw OrthancException(ErrorCode_ParameterOutOfRange);
154 } 182 }
155 183
156 184
157 void ServerContext::ApplyOnStoredInstance(const std::string& instanceId, 185 void ServerContext::ApplyOnStoredInstance(const std::string& instanceId,
206 } 234 }
207 else 235 else
208 { 236 {
209 throw OrthancException(ErrorCode_InternalError); 237 throw OrthancException(ErrorCode_InternalError);
210 } 238 }
239
240 /*
241 TODO
242 if (previousCommand != NULL)
243 {
244 previousCommand->ConnectNext(command);
245 }*/
211 246
212 previousCommand = &command; 247 previousCommand = &command;
213 } 248 }
214 249
215 job.SetDescription(std::string("Lua script: ") + ON_STORED_INSTANCE); 250 job.SetDescription(std::string("Lua script: ") + ON_STORED_INSTANCE);