diff OrthancServer/Search/SetOfResources.cpp @ 1753:faf2ecab3472 db-changes

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 27 Oct 2015 20:31:34 +0100
parents fb569ee09a69
children b1291df2f780
line wrap: on
line diff
--- a/OrthancServer/Search/SetOfResources.cpp	Tue Oct 27 17:45:05 2015 +0100
+++ b/OrthancServer/Search/SetOfResources.cpp	Tue Oct 27 20:31:34 2015 +0100
@@ -75,23 +75,26 @@
       throw OrthancException(ErrorCode_BadSequenceOfCalls);
     }
 
-    std::auto_ptr<Resources> children(new Resources);
+    if (resources_.get() != NULL)
+    {
+      std::auto_ptr<Resources> children(new Resources);
 
-    for (Resources::const_iterator it = resources_->begin(); 
-         it != resources_->end(); ++it)
-    {
-      std::list<int64_t> tmp;
-      database_.GetChildrenInternalId(tmp, *it);
+      for (Resources::const_iterator it = resources_->begin(); 
+           it != resources_->end(); ++it)
+      {
+        std::list<int64_t> tmp;
+        database_.GetChildrenInternalId(tmp, *it);
 
-      for (std::list<int64_t>::const_iterator
-             child = tmp.begin(); child != tmp.end(); ++child)
-      {
-        children->insert(*child);
+        for (std::list<int64_t>::const_iterator
+               child = tmp.begin(); child != tmp.end(); ++child)
+        {
+          children->insert(*child);
+        }
       }
+
+      resources_ = children;
     }
 
-    resources_ = children;
-
     switch (level_)
     {
       case ResourceType_Patient:
@@ -150,24 +153,4 @@
       }
     }
   }
-
-
-  bool SetOfResources::Flatten(std::list<int64_t>& result,
-                               size_t maxResults)
-  {
-    Flatten(result);
-
-    if (maxResults != 0 &&
-        result.size() > maxResults)
-    {
-      std::list<int64_t>::iterator cut = result.begin();
-      std::advance(cut, maxResults);
-      result.erase(cut, result.end());
-      return false;
-    }
-    else
-    {
-      return true;
-    }
-  }
 }