changeset 5580:df7324d6e728 find-refactoring

removed redundant FindResponse::parent_
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 27 Apr 2024 12:14:53 +0200
parents 77570cce8855
children 4ad301c35f6e
files OrthancServer/Sources/Database/FindResponse.h OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp
diffstat 3 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/FindResponse.h	Sat Apr 27 11:31:39 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.h	Sat Apr 27 12:14:53 2024 +0200
@@ -84,8 +84,7 @@
     private:
       FindRequest::ResponseContent          responseContent_;    // what has been requested
       ResourceType                          level_;
-      std::string                           parent_;    // TODO-FIND: Remove this, as it is redundant with "identifiers_"
-      OrthancIdentifiers                    identifiers_;  // TODO-FIND: not convenient to use here.  A simple resourceId seems enough
+      OrthancIdentifiers                    identifiers_;
       std::unique_ptr<DicomMap>             dicomMap_;
       std::list<std::string>                children_;
       std::string                           childInstanceId_;
@@ -162,16 +161,6 @@
         return children_;
       }
 
-      void SetParent(const std::string& parent)
-      {
-        parent_ = parent;
-      }
-
-      const std::string& GetParent() const
-      {
-        return parent_;
-      }
-
       void AddLabel(const std::string& label)
       {
         labels_.insert(label);
@@ -204,6 +193,12 @@
         return false;
       }
 
+      void SetIdentifier(ResourceType level,
+                         const std::string& id)
+      {
+        identifiers_.SetLevel(level, id);
+      }
+
       // TODO-FIND: add other getters and setters
     };
 
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Sat Apr 27 11:31:39 2024 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Sat Apr 27 12:14:53 2024 +0200
@@ -1257,7 +1257,7 @@
             while (statement.Step())
             {
               const std::string& resourceId = statement.ColumnString(0);
-              items[resourceId]->SetParent(statement.ColumnString(1));
+              items[resourceId]->SetIdentifier(GetParentResourceType(request.GetLevel()), statement.ColumnString(1));
             }
           }
 
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Sat Apr 27 11:31:39 2024 +0200
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Sat Apr 27 12:14:53 2024 +0200
@@ -3884,7 +3884,7 @@
 
     if (item.HasResponseContent(FindRequest::ResponseContent_Parent))
     {
-      parentId_ = item.GetParent();
+      parentId_ = item.GetIdentifiers().GetLevel(GetParentResourceType(level));
     }
 
     if (item.HasResponseContent(FindRequest::ResponseContent_Metadata))