changeset 5779:35271fc53028 find-refactoring

fix calls to FindRequest::IsRetrieveOneInstanceMetadataAndAttachments()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 13 Sep 2024 17:32:26 +0200
parents f679ae844839
children dc06dbca0d32
files OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Fri Sep 13 17:28:06 2024 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Fri Sep 13 17:32:26 2024 +0200
@@ -1437,7 +1437,15 @@
         dbRequest.mutable_find()->set_retrieve_labels(request.IsRetrieveLabels());
         dbRequest.mutable_find()->set_retrieve_attachments(request.IsRetrieveAttachments());
         dbRequest.mutable_find()->set_retrieve_parent_identifier(request.IsRetrieveParentIdentifier());
-        dbRequest.mutable_find()->set_retrieve_one_instance_metadata_and_attachments(request.IsRetrieveOneInstanceMetadataAndAttachments());
+
+        if (request.GetLevel() == ResourceType_Instance)
+        {
+          dbRequest.mutable_find()->set_retrieve_one_instance_metadata_and_attachments(false);
+        }
+        else
+        {
+          dbRequest.mutable_find()->set_retrieve_one_instance_metadata_and_attachments(request.IsRetrieveOneInstanceMetadataAndAttachments());
+        }
 
         if (request.GetLevel() == ResourceType_Study ||
             request.GetLevel() == ResourceType_Series ||
@@ -1541,7 +1549,8 @@
             Convert(*target, ResourceType_Instance, source.children_instances_content());
           }
 
-          if (request.IsRetrieveOneInstanceMetadataAndAttachments())
+          if (request.GetLevel() != ResourceType_Instance &&
+              request.IsRetrieveOneInstanceMetadataAndAttachments())
           {
             std::map<MetadataType, std::string> metadata;
             for (int i = 0; i < source.one_instance_metadata().size(); i++)