Mercurial > hg > orthanc
changeset 2626:e09021ddc00d jobs
cleanup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 May 2018 11:25:33 +0200 |
parents | 5469dda691cd |
children | 00b6a7f935fc |
files | OrthancServer/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h |
diffstat | 3 files changed, 51 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri May 25 10:54:33 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri May 25 11:25:33 2018 +0200 @@ -607,7 +607,7 @@ ***************************************************************************/ static bool GetInstancesToExport(Json::Value& otherArguments, - std::list<std::string>& instances, + SetOfInstancesJob& job, const std::string& remote, RestApiPostCall& call) { @@ -681,15 +681,8 @@ { context.GetIndex().LogExportedResource(stripped, remote); } - - std::list<std::string> tmp; - context.GetIndex().GetChildInstances(tmp, stripped); - for (std::list<std::string>::const_iterator - it = tmp.begin(); it != tmp.end(); ++it) - { - instances.push_back(*it); - } + context.AddChildInstances(job, stripped); } return true; @@ -698,7 +691,6 @@ static void SubmitJob(RestApiPostCall& call, const Json::Value& request, - const std::list<std::string>& instances, SetOfInstancesJob* jobRaw) { std::auto_ptr<SetOfInstancesJob> job(jobRaw); @@ -715,13 +707,6 @@ int priority = Toolbox::GetJsonIntegerField(request, "Priority", 0); job->SetPermissive(permissive); - job->Reserve(instances.size()); - - for (std::list<std::string>::const_iterator - it = instances.begin(); it != instances.end(); ++it) - { - job->AddInstance(*it); - } if (asynchronous) { @@ -752,32 +737,30 @@ std::string remote = call.GetUriComponent("id", ""); Json::Value request; - std::list<std::string> instances; - if (!GetInstancesToExport(request, instances, remote, call)) - { - return; - } + std::auto_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context)); - std::string localAet = Toolbox::GetJsonStringField - (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); - std::string moveOriginatorAET = Toolbox::GetJsonStringField - (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle()); - int moveOriginatorID = Toolbox::GetJsonIntegerField - (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */); + if (GetInstancesToExport(request, *job, remote, call)) + { + std::string localAet = Toolbox::GetJsonStringField + (request, "LocalAet", context.GetDefaultLocalApplicationEntityTitle()); + std::string moveOriginatorAET = Toolbox::GetJsonStringField + (request, "MoveOriginatorAet", context.GetDefaultLocalApplicationEntityTitle()); + int moveOriginatorID = Toolbox::GetJsonIntegerField + (request, "MoveOriginatorID", 0 /* By default, not a C-MOVE */); - RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote); + RemoteModalityParameters p = Configuration::GetModalityUsingSymbolicName(remote); - std::auto_ptr<DicomModalityStoreJob> job(new DicomModalityStoreJob(context)); - job->SetDescription("REST API"); - job->SetLocalAet(localAet); - job->SetRemoteModality(p); + job->SetDescription("REST API"); + job->SetLocalAet(localAet); + job->SetRemoteModality(p); - if (moveOriginatorID != 0) - { - job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID); + if (moveOriginatorID != 0) + { + job->SetMoveOriginator(moveOriginatorAET, moveOriginatorID); + } + + SubmitJob(call, request, job.release()); } - - SubmitJob(call, request, instances, job.release()); } @@ -898,20 +881,18 @@ std::string remote = call.GetUriComponent("id", ""); Json::Value request; - std::list<std::string> instances; - if (!GetInstancesToExport(request, instances, remote, call)) - { - return; - } + std::auto_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context)); - WebServiceParameters peer; - Configuration::GetOrthancPeer(peer, remote); - - std::auto_ptr<OrthancPeerStoreJob> job(new OrthancPeerStoreJob(context)); - job->SetDescription("REST API"); - job->SetPeer(peer); - - SubmitJob(call, request, instances, job.release()); + if (GetInstancesToExport(request, *job, remote, call)) + { + WebServiceParameters peer; + Configuration::GetOrthancPeer(peer, remote); + + job->SetDescription("REST API"); + job->SetPeer(peer); + + SubmitJob(call, request, job.release()); + } }
--- a/OrthancServer/ServerContext.cpp Fri May 25 10:54:33 2018 +0200 +++ b/OrthancServer/ServerContext.cpp Fri May 25 11:25:33 2018 +0200 @@ -671,4 +671,19 @@ } } + + void ServerContext::AddChildInstances(SetOfInstancesJob& job, + const std::string& publicId) + { + std::list<std::string> instances; + GetIndex().GetChildInstances(instances, publicId); + + job.Reserve(job.GetInstancesCount() + instances.size()); + + for (std::list<std::string>::const_iterator + it = instances.begin(); it != instances.end(); ++it) + { + job.AddInstance(*it); + } + } }
--- a/OrthancServer/ServerContext.h Fri May 25 10:54:33 2018 +0200 +++ b/OrthancServer/ServerContext.h Fri May 25 11:25:33 2018 +0200 @@ -44,6 +44,7 @@ #include "../Core/DicomParsing/ParsedDicomFile.h" #include "../Core/FileStorage/IStorageArea.h" #include "../Core/JobsEngine/JobsEngine.h" +#include "../Core/JobsEngine/SetOfInstancesJob.h" #include "../Core/MultiThreading/SharedMessageQueue.h" #include "../Core/RestApi/RestApiOutput.h" #include "../Plugins/Engine/OrthancPlugins.h" @@ -290,5 +291,8 @@ #endif bool HasPlugins() const; + + void AddChildInstances(SetOfInstancesJob& job, + const std::string& publicId); }; }