comparison OrthancServer/OrthancRestApi/OrthancRestSystem.cpp @ 2616:2f3007bf0708 jobs

event queues in Lua, serialization of sequence of operations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 May 2018 12:25:37 +0200
parents 6f9225dcfc32
children 912a767911b0
comparison
equal deleted inserted replaced
2614:3200223f9ade 2616:2f3007bf0708
122 122
123 std::string command; 123 std::string command;
124 call.BodyToString(command); 124 call.BodyToString(command);
125 125
126 { 126 {
127 LuaScripting::Locker locker(context.GetLuaScripting()); 127 LuaScripting::Lock lock(context.GetLuaEventHandler());
128 locker.GetLua().Execute(result, command); 128 lock.GetLua().Execute(result, command);
129 } 129 }
130 130
131 call.GetOutput().AnswerBuffer(result, "text/plain"); 131 call.GetOutput().AnswerBuffer(result, "text/plain");
132 } 132 }
133 133
274 // Jobs information ------------------------------------------------------ 274 // Jobs information ------------------------------------------------------
275 275
276 static void ListJobs(RestApiGetCall& call) 276 static void ListJobs(RestApiGetCall& call)
277 { 277 {
278 bool expand = call.HasArgument("expand"); 278 bool expand = call.HasArgument("expand");
279 bool internal = call.HasArgument("internal");
279 280
280 Json::Value v = Json::arrayValue; 281 Json::Value v = Json::arrayValue;
281 282
282 std::set<std::string> jobs; 283 std::set<std::string> jobs;
283 OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().ListJobs(jobs); 284 OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().ListJobs(jobs);
289 { 290 {
290 JobInfo info; 291 JobInfo info;
291 if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, *it)) 292 if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, *it))
292 { 293 {
293 Json::Value tmp; 294 Json::Value tmp;
294 info.Serialize(tmp, false); 295 info.Serialize(tmp, internal);
295 v.append(tmp); 296 v.append(tmp);
296 } 297 }
297 } 298 }
298 else 299 else
299 { 300 {
305 } 306 }
306 307
307 static void GetJobInfo(RestApiGetCall& call) 308 static void GetJobInfo(RestApiGetCall& call)
308 { 309 {
309 std::string id = call.GetUriComponent("id", ""); 310 std::string id = call.GetUriComponent("id", "");
311 bool internal = call.HasArgument("internal");
310 312
311 JobInfo info; 313 JobInfo info;
312 if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, id)) 314 if (OrthancRestApi::GetContext(call).GetJobsEngine().GetRegistry().GetJobInfo(info, id))
313 { 315 {
314 Json::Value json; 316 Json::Value json;
315 info.Serialize(json, false); 317 info.Serialize(json, internal);
316 call.GetOutput().AnswerJson(json); 318 call.GetOutput().AnswerJson(json);
317 } 319 }
318 } 320 }
319 321
320 322