changeset 5697:f375e9983943 find-refactoring

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Jul 2024 11:55:27 +0200
parents 0f8b6214308a
children 075558c95cbb
files OrthancServer/Sources/Database/FindRequest.cpp OrthancServer/Sources/Database/FindRequest.h OrthancServer/Sources/ResourceFinder.cpp
diffstat 3 files changed, 43 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindRequest.cpp	Fri Jul 12 10:56:33 2024 +0200
+++ b/OrthancServer/Sources/Database/FindRequest.cpp	Fri Jul 12 11:55:27 2024 +0200
@@ -34,7 +34,8 @@
 {
   FindRequest::ParentSpecification& FindRequest::GetParentSpecification(ResourceType level)
   {
-    if (!IsResourceLevelAboveOrEqual(level, level_))
+    if (!IsResourceLevelAboveOrEqual(level, level_) ||
+        level == level_)
     {
       throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
@@ -58,7 +59,8 @@
 
   FindRequest::ChildrenSpecification& FindRequest::GetChildrenSpecification(ResourceType level)
   {
-    if (!IsResourceLevelAboveOrEqual(level_, level))
+    if (!IsResourceLevelAboveOrEqual(level_, level) ||
+        level == level_)
     {
       throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
--- a/OrthancServer/Sources/Database/FindRequest.h	Fri Jul 12 10:56:33 2024 +0200
+++ b/OrthancServer/Sources/Database/FindRequest.h	Fri Jul 12 11:55:27 2024 +0200
@@ -431,7 +431,8 @@
     bool IsRetrieveOneInstanceIdentifier() const
     {
       return (retrieveOneInstanceIdentifier_ ||
-              GetChildrenSpecification(ResourceType_Instance).IsRetrieveIdentifiers());
+              (level_ != ResourceType_Instance &&
+               GetChildrenSpecification(ResourceType_Instance).IsRetrieveIdentifiers()));
     }
   };
 }
--- a/OrthancServer/Sources/ResourceFinder.cpp	Fri Jul 12 10:56:33 2024 +0200
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Fri Jul 12 11:55:27 2024 +0200
@@ -624,8 +624,8 @@
     {
       if (request_.GetLevel() == ResourceType_Patient)
       {
-        request_.GetParentSpecification(ResourceType_Patient).SetRetrieveMainDicomTags(true);
-        request_.GetParentSpecification(ResourceType_Patient).SetRetrieveMetadata(true);
+        request_.SetRetrieveMainDicomTags(true);
+        request_.SetRetrieveMetadata(true);
         requestedPatientTags_.insert(tag);
       }
       else
@@ -634,8 +634,19 @@
          * This comes from the fact that patient-level tags are copied
          * at the study level, as implemented by "ResourcesContent::AddResource()".
          **/
-        request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
-        request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true);
+        requestedStudyTags_.insert(tag);
+
+        if (request_.GetLevel() == ResourceType_Study)
+        {
+          request_.SetRetrieveMainDicomTags(true);
+          request_.SetRetrieveMetadata(true);
+        }
+        else
+        {
+          request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
+          request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true);
+        }
+
         requestedStudyTags_.insert(tag);
       }
 
@@ -652,8 +663,17 @@
       }
       else
       {
-        request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
-        request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true);
+        if (request_.GetLevel() == ResourceType_Study)
+        {
+          request_.SetRetrieveMainDicomTags(true);
+          request_.SetRetrieveMetadata(true);
+        }
+        else
+        {
+          request_.GetParentSpecification(ResourceType_Study).SetRetrieveMainDicomTags(true);
+          request_.GetParentSpecification(ResourceType_Study).SetRetrieveMetadata(true);
+        }
+
         requestedStudyTags_.insert(tag);
       }
 
@@ -671,8 +691,17 @@
       }
       else
       {
-        request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true);
-        request_.GetParentSpecification(ResourceType_Series).SetRetrieveMetadata(true);
+        if (request_.GetLevel() == ResourceType_Series)
+        {
+          request_.SetRetrieveMainDicomTags(true);
+          request_.SetRetrieveMetadata(true);
+        }
+        else
+        {
+          request_.GetParentSpecification(ResourceType_Series).SetRetrieveMainDicomTags(true);
+          request_.GetParentSpecification(ResourceType_Series).SetRetrieveMetadata(true);
+        }
+
         requestedSeriesTags_.insert(tag);
       }