changeset 5582:17da828f9443 find-refactoring

removed FindResponse::Item::level_
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 27 Apr 2024 21:42:32 +0200
parents 4ad301c35f6e
children 74cc31c8db2b
files OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/Database/FindResponse.cpp OrthancServer/Sources/Database/FindResponse.h OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp
diffstat 5 files changed, 6 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Sat Apr 27 15:02:24 2024 +0200
+++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Sat Apr 27 21:42:32 2024 +0200
@@ -62,9 +62,7 @@
           OrthancIdentifiers identifiers;
           identifiers.SetLevel(request.GetLevel(), *it);
 
-          response.Add(new FindResponse::Item(request.GetResponseContent(),
-                                              request.GetLevel(), 
-                                              identifiers));
+          response.Add(new FindResponse::Item(request.GetResponseContent(), identifiers));
         }
       }
       else
@@ -81,11 +79,6 @@
       {
         const FindResponse::Item& item = response.GetItem(i);
 
-        if (item.GetLevel() != request.GetLevel())
-        {
-          throw OrthancException(ErrorCode_InternalError);
-        }
-
         if (request.HasResponseContent(FindRequest::ResponseContent_MainDicomTags)
             && !item.HasDicomMap())
         {
--- a/OrthancServer/Sources/Database/FindResponse.cpp	Sat Apr 27 15:02:24 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.cpp	Sat Apr 27 21:42:32 2024 +0200
@@ -118,7 +118,6 @@
                            ResourceType level,
                            DicomMap* dicomMap /* takes ownership */) :
     responseContent_(responseContent),
-    level_(level),
     dicomMap_(dicomMap)
   {
     if (dicomMap == NULL)
--- a/OrthancServer/Sources/Database/FindResponse.h	Sat Apr 27 15:02:24 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.h	Sat Apr 27 21:42:32 2024 +0200
@@ -83,7 +83,6 @@
     {
     private:
       FindRequest::ResponseContent          responseContent_;  // TODO REMOVE  // what has been requested
-      ResourceType                          level_;   // TODO REMOVE
       OrthancIdentifiers                    identifiers_;
       std::unique_ptr<DicomMap>             dicomMap_;
       std::list<std::string>                children_;
@@ -94,10 +93,8 @@
 
     public:
       Item(FindRequest::ResponseContent responseContent,
-           ResourceType level,
            const OrthancIdentifiers& identifiers) :
         responseContent_(responseContent),
-        level_(level),
         identifiers_(identifiers)
       {
       }
@@ -106,11 +103,6 @@
            ResourceType level,
            DicomMap* dicomMap /* takes ownership */);
 
-      ResourceType GetLevel() const
-      {
-        return level_;
-      }
-
       const OrthancIdentifiers& GetIdentifiers() const
       {
         return identifiers_;
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Sat Apr 27 15:02:24 2024 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Sat Apr 27 21:42:32 2024 +0200
@@ -1176,8 +1176,7 @@
             OrthancIdentifiers id;
             id.SetLevel(request.GetLevel(), statement.ColumnString(0));
 
-            FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(),
-                                                              request.GetLevel(), id);
+            FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(), id);
             response.Add(item);
           }
         }
@@ -1205,8 +1204,7 @@
               OrthancIdentifiers id;
               id.SetLevel(request.GetLevel(), resourceId);
 
-              FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(),
-                                                                request.GetLevel(), id);
+              FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(), id);
               items[resourceId] = item;
               response.Add(item);
             }
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Sat Apr 27 15:02:24 2024 +0200
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Sat Apr 27 21:42:32 2024 +0200
@@ -3866,7 +3866,7 @@
   ExpandedResource::ExpandedResource(const FindRequest& request,
                                      const FindResponse::Item& item) :
     id_(item.GetIdentifiers().GetLevel(request.GetLevel())),
-    level_(item.GetLevel()),
+    level_(request.GetLevel()),
     isStable_(false),
     expectedNumberOfInstances_(0),
     fileSize_(0),
@@ -3907,14 +3907,14 @@
       {
         lastUpdate_ = value;
       }
-      if (item.GetLevel() == ResourceType_Series)
+      if (request.GetLevel() == ResourceType_Series)
       {
         if (item.LookupMetadata(value, MetadataType_Series_ExpectedNumberOfInstances))
         {
           expectedNumberOfInstances_ = boost::lexical_cast<int>(value);
         }
       }
-      if (item.GetLevel() == ResourceType_Instance)
+      if (request.GetLevel() == ResourceType_Instance)
       {
         if (item.LookupMetadata(value, MetadataType_Instance_IndexInSeries))
         {