changeset 3374:d0d6bd633e4c

Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 14 May 2019 16:38:02 +0200
parents fe73717105b6
children 73d60d80a74a
files Core/JobsEngine/SetOfInstancesJob.cpp Core/JobsEngine/SetOfInstancesJob.h NEWS OrthancServer/OrthancRestApi/OrthancRestModalities.cpp
diffstat 4 files changed, 27 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Core/JobsEngine/SetOfInstancesJob.cpp	Tue May 14 11:01:17 2019 +0200
+++ b/Core/JobsEngine/SetOfInstancesJob.cpp	Tue May 14 16:38:02 2019 +0200
@@ -193,17 +193,22 @@
   }
 
 
+  static const char* KEY_TRAILING_STEP = "TrailingStep";
+  static const char* KEY_FAILED_INSTANCES = "FailedInstances";
+  static const char* KEY_PARENT_RESOURCES = "ParentResources";
+
   void SetOfInstancesJob::GetPublicContent(Json::Value& target)
   {
     SetOfCommandsJob::GetPublicContent(target);
     target["InstancesCount"] = static_cast<uint32_t>(GetInstancesCount());
     target["FailedInstancesCount"] = static_cast<uint32_t>(failedInstances_.size());
-  }    
-
 
+    if (!parentResources_.empty())
+    {
+      SerializationToolbox::WriteSetOfStrings(target, parentResources_, KEY_PARENT_RESOURCES);
+    }
+  }
 
-  static const char* KEY_TRAILING_STEP = "TrailingStep";
-  static const char* KEY_FAILED_INSTANCES = "FailedInstances";
 
   bool SetOfInstancesJob::Serialize(Json::Value& target) 
   {
@@ -211,6 +216,7 @@
     {
       target[KEY_TRAILING_STEP] = hasTrailingStep_;
       SerializationToolbox::WriteSetOfStrings(target, failedInstances_, KEY_FAILED_INSTANCES);
+      SerializationToolbox::WriteSetOfStrings(target, parentResources_, KEY_PARENT_RESOURCES);
       return true;
     }
     else
@@ -225,6 +231,12 @@
   {
     SerializationToolbox::ReadSetOfStrings(failedInstances_, source, KEY_FAILED_INSTANCES);
 
+    if (source.isMember(KEY_PARENT_RESOURCES))
+    {
+      // Backward compatibility with Orthanc <= 1.5.6
+      SerializationToolbox::ReadSetOfStrings(parentResources_, source, KEY_PARENT_RESOURCES);
+    }
+    
     if (source.isMember(KEY_TRAILING_STEP))
     {
       hasTrailingStep_ = SerializationToolbox::ReadBoolean(source, KEY_TRAILING_STEP);
--- a/Core/JobsEngine/SetOfInstancesJob.h	Tue May 14 11:01:17 2019 +0200
+++ b/Core/JobsEngine/SetOfInstancesJob.h	Tue May 14 16:38:02 2019 +0200
@@ -49,6 +49,7 @@
     
     bool                   hasTrailingStep_;
     std::set<std::string>  failedInstances_;
+    std::set<std::string>  parentResources_;
 
   protected:
     virtual bool HandleInstance(const std::string& instance) = 0;
@@ -63,6 +64,13 @@
 
     SetOfInstancesJob(const Json::Value& source);  // Unserialization
 
+    // Only used for reporting in the public content
+    // https://groups.google.com/d/msg/orthanc-users/9GCV88GLEzw/6wAgP_PRAgAJ
+    void AddParentResource(const std::string& resource)
+    {
+      parentResources_.insert(resource);
+    }
+    
     void AddInstance(const std::string& instance);
 
     void AddTrailingStep(); 
--- a/NEWS	Tue May 14 11:01:17 2019 +0200
+++ b/NEWS	Tue May 14 16:38:02 2019 +0200
@@ -7,6 +7,7 @@
 
 * "/modalities/{id}/query": New argument "Normalize" can be set to "false"
   to bypass the automated correction of outgoing C-FIND queries
+* Reporting of "ParentResources" in "DicomModalityStore" and "DicomModalityStore" jobs
 
 Maintenance
 -----------
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue May 14 11:01:17 2019 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue May 14 16:38:02 2019 +0200
@@ -927,6 +927,8 @@
                                "This string is not a valid Orthanc identifier: " + stripped);
       }
 
+      job.AddParentResource(stripped);  // New in Orthanc 1.5.7
+      
       context.AddChildInstances(job, stripped);
 
       if (logExportedResources)