diff OrthancServer/Sources/Database/FindResponse.cpp @ 5621:732ec9feeea8 find-refactoring

introduction of FindRequest::ChildrenRetrieveSpecification
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 11 May 2024 15:43:07 +0200
parents 1864b16bc7b1
children 3f13db27b399
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindResponse.cpp	Sat May 11 15:11:22 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.cpp	Sat May 11 15:43:07 2024 +0200
@@ -493,11 +493,11 @@
 
     for (size_t i = 0; i < 4; i++)
     {
+      const char* level = EnumerationToString(levels[i]);
+
       if (levels[i] != request.GetLevel() &&
           IsResourceLevelAboveOrEqual(levels[i], request.GetLevel()))
       {
-        const char* level = EnumerationToString(levels[i]);
-
         if (request.GetParentRetrieveSpecification(levels[i]).IsRetrieveMainDicomTags())
         {
           DicomMap m;
@@ -510,17 +510,28 @@
           DebugMetadata(target[level]["Metadata"], GetMetadata(levels[i]));
         }
       }
-    }
 
-    if (request.IsRetrieveChildrenIdentifiers())
-    {
-      Json::Value v = Json::arrayValue;
-      for (std::set<std::string>::const_iterator it = childrenIdentifiers_.begin();
-           it != childrenIdentifiers_.end(); ++it)
+      if (levels[i] != request.GetLevel() &&
+          IsResourceLevelAboveOrEqual(request.GetLevel(), levels[i]))
       {
-        v.append(*it);
+        if (request.GetChildrenRetrieveSpecification(levels[i]).IsRetrieveIdentifiers())
+        {
+          if (levels[i] != GetChildResourceType(request.GetLevel()))
+          {
+            throw OrthancException(ErrorCode_NotImplemented);  // TODO-FIND
+          }
+          else
+          {
+            Json::Value v = Json::arrayValue;
+            for (std::set<std::string>::const_iterator it = childrenIdentifiers_.begin();
+                 it != childrenIdentifiers_.end(); ++it)
+            {
+              v.append(*it);
+            }
+            target[level]["Identifiers"] = v;
+          }
+        }
       }
-      target["Children"] = v;
     }
 
     if (request.IsRetrieveLabels())