changeset 5583:74cc31c8db2b find-refactoring

removed FindResponse::Item::responseContent_
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 27 Apr 2024 22:15:37 +0200
parents 17da828f9443
children fc3914c07dd3
files OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/Database/FindRequest.h OrthancServer/Sources/Database/FindResponse.cpp OrthancServer/Sources/Database/FindResponse.h OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp
diffstat 8 files changed, 25 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Sat Apr 27 22:15:37 2024 +0200
@@ -62,7 +62,7 @@
           OrthancIdentifiers identifiers;
           identifiers.SetLevel(request.GetLevel(), *it);
 
-          response.Add(new FindResponse::Item(request.GetResponseContent(), identifiers));
+          response.Add(new FindResponse::Item(identifiers));
         }
       }
       else
--- a/OrthancServer/Sources/Database/FindRequest.h	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/Database/FindRequest.h	Sat Apr 27 22:15:37 2024 +0200
@@ -80,6 +80,7 @@
 
     class Key
     {
+    private:
       KeyType                       type_;
       boost::shared_ptr<DicomTag>   dicomTag_;
       MetadataType                  metadata_;
@@ -90,14 +91,14 @@
       // these are however only populated in StatelessDatabaseOperations -> we had to add the normalized lookup arg to ExecuteFind
 
     public:
-      Key(const DicomTag& dicomTag) :
+      explicit Key(const DicomTag& dicomTag) :
         type_(KeyType_DicomTag),
         dicomTag_(new DicomTag(dicomTag)),
         metadata_(MetadataType_EndUser)
       {
       }
 
-      Key(MetadataType metadata) :
+      explicit Key(MetadataType metadata) :
         type_(KeyType_Metadata),
         metadata_(metadata)
       {
@@ -123,6 +124,7 @@
 
     class Ordering : public boost::noncopyable
     {
+    private:
       OrderingDirection   direction_;
       Key                 key_;
 
@@ -134,7 +136,6 @@
       {
       }
 
-    public:
       KeyType GetKeyType() const
       {
         return key_.GetType();
@@ -354,7 +355,7 @@
     bool IsCompatibleLevel(ResourceType levelOfInterest) const;
 
   public:
-    FindRequest(ResourceType level);
+    explicit FindRequest(ResourceType level);
 
     ~FindRequest();
 
--- a/OrthancServer/Sources/Database/FindResponse.cpp	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.cpp	Sat Apr 27 22:15:37 2024 +0200
@@ -114,10 +114,8 @@
   }
 
 
-  FindResponse::Item::Item(FindRequest::ResponseContent responseContent,
-                           ResourceType level,
+  FindResponse::Item::Item(ResourceType level,
                            DicomMap* dicomMap /* takes ownership */) :
-    responseContent_(responseContent),
     dicomMap_(dicomMap)
   {
     if (dicomMap == NULL)
--- a/OrthancServer/Sources/Database/FindResponse.h	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/Database/FindResponse.h	Sat Apr 27 22:15:37 2024 +0200
@@ -82,7 +82,6 @@
     class Item : public boost::noncopyable
     {
     private:
-      FindRequest::ResponseContent          responseContent_;  // TODO REMOVE  // what has been requested
       OrthancIdentifiers                    identifiers_;
       std::unique_ptr<DicomMap>             dicomMap_;
       std::list<std::string>                children_;
@@ -92,15 +91,12 @@
       std::map<FileContentType, FileInfo>   attachments_;
 
     public:
-      Item(FindRequest::ResponseContent responseContent,
-           const OrthancIdentifiers& identifiers) :
-        responseContent_(responseContent),
+      explicit Item(const OrthancIdentifiers& identifiers) :
         identifiers_(identifiers)
       {
       }
 
-      Item(FindRequest::ResponseContent responseContent,
-           ResourceType level,
+      Item(ResourceType level,
            DicomMap* dicomMap /* takes ownership */);
 
       const OrthancIdentifiers& GetIdentifiers() const
@@ -108,16 +104,6 @@
         return identifiers_;
       }
 
-      FindRequest::ResponseContent GetResponseContent() const
-      {
-        return responseContent_;
-      }
-
-      bool HasResponseContent(FindRequest::ResponseContent content) const
-      {
-        return (responseContent_ & content) == content;
-      }
-
       void AddDicomTag(uint16_t group, uint16_t element, const std::string& value, bool isBinary);
 
       void AddMetadata(MetadataType metadata,
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Sat Apr 27 22:15:37 2024 +0200
@@ -1176,7 +1176,7 @@
             OrthancIdentifiers id;
             id.SetLevel(request.GetLevel(), statement.ColumnString(0));
 
-            FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(), id);
+            FindResponse::Item* item = new FindResponse::Item(id);
             response.Add(item);
           }
         }
@@ -1204,7 +1204,7 @@
               OrthancIdentifiers id;
               id.SetLevel(request.GetLevel(), resourceId);
 
-              FindResponse::Item* item = new FindResponse::Item(request.GetResponseContent(), id);
+              FindResponse::Item* item = new FindResponse::Item(id);
               items[resourceId] = item;
               response.Add(item);
             }
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Sat Apr 27 22:15:37 2024 +0200
@@ -3872,22 +3872,22 @@
     fileSize_(0),
     indexInSeries_(0)
   {
-    if (item.HasResponseContent(FindRequest::ResponseContent_MainDicomTags))
+    if (request.HasResponseContent(FindRequest::ResponseContent_MainDicomTags))
     {
       tags_.Assign(item.GetDicomMap());
     }
 
-    if (item.HasResponseContent(FindRequest::ResponseContent_Children))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Children))
     {
       childrenIds_ = item.GetChildren();
     }
 
-    if (item.HasResponseContent(FindRequest::ResponseContent_Parent))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Parent))
     {
       parentId_ = item.GetIdentifiers().GetLevel(GetParentResourceType(request.GetLevel()));
     }
 
-    if (item.HasResponseContent(FindRequest::ResponseContent_Metadata))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Metadata))
     {
       metadata_ = item.GetMetadata();
       std::string value;
@@ -3923,12 +3923,12 @@
       }
     }
 
-    if (item.HasResponseContent(FindRequest::ResponseContent_Labels))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Labels))
     {
       labels_ = item.GetLabels();
     }
 
-    if (item.HasResponseContent(FindRequest::ResponseContent_Attachments))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Attachments))
     {
       FileInfo attachment;
       if (item.LookupAttachment(attachment, FileContentType_Dicom))
@@ -3938,7 +3938,7 @@
       }
     }
 
-    if (item.HasResponseContent(FindRequest::ResponseContent_ChildrenMetadata))
+    if (request.HasResponseContent(FindRequest::ResponseContent_ChildrenMetadata))
     {
       // TODO-FIND: the status_ is normally obtained from transaction.GetSeriesStatus(internalId, i)
       // but, that's an heavy operation for something that is rarely used -> we should have dedicated SQL code 
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Sat Apr 27 22:15:37 2024 +0200
@@ -323,7 +323,7 @@
       {
         for (size_t i = 0; i < response.GetSize(); i++)
         {
-          context.AppendFindResponse(answer, resourceType, response.GetItem(i), format, requestedTags, true /* allowStorageAccess */);
+          context.AppendFindResponse(answer, request, response.GetItem(i), format, requestedTags, true /* allowStorageAccess */);
         }
       }
 
--- a/OrthancServer/Sources/ServerContext.cpp	Sat Apr 27 21:42:32 2024 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Sat Apr 27 22:15:37 2024 +0200
@@ -2725,26 +2725,26 @@
                                          bool allowStorageAccess)
   {
     // convert to ExpandedResource to re-use the serialization code TODO-FIND: check if this is the right way to do.  shouldn't we copy the code and finally get rid of ExpandedResource ? 
-    ExpandedResource resource(request.GetLevel(), item);
+    ExpandedResource resource(request, item);
 
     ExpandResourceFlags expandFlags = ExpandResourceFlags_None;
-    if (item.HasResponseContent(FindRequest::ResponseContent_Children))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Children))
     {
       expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeChildren);
     }
-    if (item.HasResponseContent(FindRequest::ResponseContent_Metadata))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Metadata))
     {
       expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeAllMetadata | ExpandResourceFlags_IncludeMetadata );
     }
-    if (item.HasResponseContent(FindRequest::ResponseContent_MainDicomTags))
+    if (request.HasResponseContent(FindRequest::ResponseContent_MainDicomTags))
     {
       expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeMainDicomTags);
     }
-    if (item.HasResponseContent(FindRequest::ResponseContent_IsStable))
+    if (request.HasResponseContent(FindRequest::ResponseContent_IsStable))
     {
       expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeIsStable);
     }
-    if (item.HasResponseContent(FindRequest::ResponseContent_Labels))
+    if (request.HasResponseContent(FindRequest::ResponseContent_Labels))
     {
       expandFlags = static_cast<ExpandResourceFlags>(expandFlags | ExpandResourceFlags_IncludeLabels);
     }