changeset 2876:ae8e72009e64

notes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Oct 2018 20:09:35 +0200
parents edfd98a2b6c4
children fae500411605
files OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/OrthancRestApi/OrthancRestResources.cpp OrthancServer/ServerContext.cpp OrthancServer/ServerContext.h
diffstat 4 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Tue Oct 09 16:44:28 2018 +0200
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Tue Oct 09 20:09:35 2018 +0200
@@ -588,7 +588,7 @@
      * Build up the query object.
      **/
 
-    LookupResource finder(level);
+    LookupResource lookup(level);
 
     const bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false);
 
@@ -623,7 +623,7 @@
           sensitive = caseSensitivePN;
         }
 
-        finder.AddDicomConstraint(tag, value, sensitive);
+        lookup.AddDicomConstraint(tag, value, sensitive);
       }
       else
       {
@@ -637,10 +637,12 @@
      * Run the query.
      **/
 
-    size_t maxResults = (level == ResourceType_Instance) ? maxInstances_ : maxResults_;
+    size_t limit = (level == ResourceType_Instance) ? maxInstances_ : maxResults_;
 
+    // TODO - Use ServerContext::Apply() at this point, in order to
+    // share the code with the "/tools/find" REST URI
     std::vector<std::string> resources, instances;
-    context_.GetIndex().FindCandidates(resources, instances, finder);
+    context_.GetIndex().FindCandidates(resources, instances, lookup);
 
     LOG(INFO) << "Number of candidate resources after fast DB filtering: " << resources.size();
 
@@ -654,10 +656,10 @@
       Json::Value dicom;
       context_.ReadDicomAsJson(dicom, instances[i]);
       
-      if (finder.IsMatch(dicom))
+      if (lookup.IsMatch(dicom))
       {
-        if (maxResults != 0 &&
-            answers.GetSize() >= maxResults)
+        if (limit != 0 &&
+            answers.GetSize() >= limit)
         {
           complete = false;
           break;
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Tue Oct 09 16:44:28 2018 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Tue Oct 09 20:09:35 2018 +0200
@@ -1334,9 +1334,10 @@
                                  request["Query"][members[i]].asString(),
                                  caseSensitive);
       }
-      
+
+      bool isComplete;
       std::list<std::string> resources;
-      context.Apply(resources, query, since, limit);
+      context.Apply(isComplete, resources, query, since, limit);
       AnswerListOfResources(call.GetOutput(), context.GetIndex(),
                             resources, query.GetLevel(), expand);
     }
--- a/OrthancServer/ServerContext.cpp	Tue Oct 09 16:44:28 2018 +0200
+++ b/OrthancServer/ServerContext.cpp	Tue Oct 09 20:09:35 2018 +0200
@@ -766,12 +766,14 @@
   }
 
 
-  void ServerContext::Apply(std::list<std::string>& result,
+  void ServerContext::Apply(bool& isComplete, 
+                            std::list<std::string>& result,
                             const ::Orthanc::LookupResource& lookup,
                             size_t since,
                             size_t limit)
   {
     result.clear();
+    isComplete = true;
 
     std::vector<std::string> resources, instances;
     GetIndex().FindCandidates(resources, instances, lookup);
@@ -781,6 +783,8 @@
     size_t skipped = 0;
     for (size_t i = 0; i < instances.size(); i++)
     {
+      // TODO - Don't read the full JSON from the disk if only "main
+      // DICOM tags" are to be returned
       Json::Value dicom;
       ReadDicomAsJson(dicom, instances[i]);
       
@@ -793,6 +797,7 @@
         else if (limit != 0 &&
                  result.size() >= limit)
         {
+          isComplete = false;
           return;  // too many results
         }
         else
--- a/OrthancServer/ServerContext.h	Tue Oct 09 16:44:28 2018 +0200
+++ b/OrthancServer/ServerContext.h	Tue Oct 09 20:09:35 2018 +0200
@@ -321,7 +321,8 @@
 
     void Stop();
 
-    void Apply(std::list<std::string>& result,
+    void Apply(bool& isComplete, 
+               std::list<std::string>& result,
                const ::Orthanc::LookupResource& lookup,
                size_t since,
                size_t limit);