diff OrthancServer/OrthancMoveRequestHandler.cpp @ 2625:5469dda691cd jobs

new configuration option: SynchronousCMove
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 May 2018 10:54:33 +0200
parents 714dcddeb65f
children 00504dcc996f
line wrap: on
line diff
--- a/OrthancServer/OrthancMoveRequestHandler.cpp	Thu May 24 21:44:22 2018 +0200
+++ b/OrthancServer/OrthancMoveRequestHandler.cpp	Fri May 25 10:54:33 2018 +0200
@@ -60,7 +60,7 @@
 
     public:
       SynchronousMove(ServerContext& context,
-                      const std::string& aet,
+                      const std::string& targetAet,
                       const std::string& publicId,
                       const std::string& originatorAet,
                       uint16_t originatorId) :
@@ -70,7 +70,7 @@
         originatorAet_(originatorAet),
         originatorId_(originatorId)
       {
-        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\"";
+        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << targetAet << "\"";
 
         std::list<std::string> tmp;
         context_.GetIndex().GetChildInstances(tmp, publicId);
@@ -81,7 +81,7 @@
           instances_.push_back(*it);
         }
 
-        remote_ = Configuration::GetModalityUsingAet(aet);
+        remote_ = Configuration::GetModalityUsingAet(targetAet);
       }
 
       virtual unsigned int GetSubOperationCount() const
@@ -122,7 +122,7 @@
       
     public:
       AsynchronousMove(ServerContext& context,
-                       const std::string& aet,
+                       const std::string& targetAet,
                        const std::string& publicId,
                        const std::string& originatorAet,
                        uint16_t originatorId) :
@@ -130,12 +130,12 @@
         job_(new DicomModalityStoreJob(context)),
         position_(0)
       {
-        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\"";
+        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << targetAet << "\"";
 
         job_->SetDescription("C-MOVE");
         job_->SetPermissive(true);
         job_->SetLocalAet(context.GetDefaultLocalApplicationEntityTitle());
-        job_->SetRemoteModality(Configuration::GetModalityUsingAet(aet));
+        job_->SetRemoteModality(Configuration::GetModalityUsingAet(targetAet));
 
         if (originatorId != 0)
         {
@@ -232,6 +232,25 @@
   }
 
 
+  static IMoveRequestIterator* CreateIterator(ServerContext& context,
+                                              const std::string& targetAet,
+                                              const std::string& publicId,
+                                              const std::string& originatorAet,
+                                              uint16_t originatorId)
+  {
+    bool synchronous = Configuration::GetGlobalBoolParameter("SynchronousCMove", false);
+
+    if (synchronous)
+    {
+      return new SynchronousMove(context, targetAet, publicId, originatorAet, originatorId);
+    }
+    else
+    {
+      return new AsynchronousMove(context, targetAet, publicId, originatorAet, originatorId);
+    }
+  }
+
+
   IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& targetAet,
                                                           const DicomMap& input,
                                                           const std::string& originatorIp,
@@ -254,7 +273,6 @@
       }
     }
 
-
     /**
      * Retrieve the query level.
      **/
@@ -278,8 +296,7 @@
           LookupIdentifier(publicId, ResourceType_Study, input) ||
           LookupIdentifier(publicId, ResourceType_Patient, input))
       {
-        return new AsynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
-        //return new SynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
+        return CreateIterator(context_, targetAet, publicId, originatorAet, originatorId);
       }
       else
       {
@@ -300,8 +317,7 @@
 
     if (LookupIdentifier(publicId, level, input))
     {
-      return new AsynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
-      //return new SynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
+      return CreateIterator(context_, targetAet, publicId, originatorAet, originatorId);
     }
     else
     {