changeset 3072:1b05fd072c57 db-changes

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Jan 2019 11:47:58 +0100
parents 2df061cf2fec
children 0e9d1731b1b0
files OrthancServer/Search/DatabaseLookup.cpp OrthancServer/Search/HierarchicalMatcher.cpp
diffstat 2 files changed, 23 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Search/DatabaseLookup.cpp	Wed Jan 02 11:26:27 2019 +0100
+++ b/OrthancServer/Search/DatabaseLookup.cpp	Wed Jan 02 11:47:58 2019 +0100
@@ -99,19 +99,13 @@
     {
       assert(constraints_[i] != NULL);
 
-      DcmTagKey tag = ToDcmtkBridge::Convert(constraints_[i]->GetTag());
+      const bool isOptionalConstraint = !constraints_[i]->IsMandatory();
+      const DcmTagKey tag = ToDcmtkBridge::Convert(constraints_[i]->GetTag());
 
       DcmElement* element = NULL;
       if (!item.findAndGetElement(tag, element).good())
       {
-        if (constraints_[i]->IsMandatory())
-        {
-          return false;
-        }
-        else
-        {
-          return true;
-        }
+        return isOptionalConstraint;
       }
 
       if (element == NULL)
@@ -122,11 +116,16 @@
       std::set<DicomTag> ignoreTagLength;
       std::auto_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement
                                       (*element, DicomToJsonFlags_None, 
-                                       ORTHANC_MAXIMUM_TAG_LENGTH, encoding, ignoreTagLength));
+                                       0, encoding, ignoreTagLength));
 
-      if (value->IsNull() ||
-          value->IsBinary() ||
-          !constraints_[i]->IsMatch(value->GetContent()))
+      // WARNING: Also modify "HierarchicalMatcher::Setup()" if modifying this code
+      if (value.get() == NULL ||
+          value->IsNull())
+      {
+        return isOptionalConstraint;        
+      }
+      else if (value->IsBinary() ||
+               !constraints_[i]->IsMatch(value->GetContent()))
       {
         return false;
       }
--- a/OrthancServer/Search/HierarchicalMatcher.cpp	Wed Jan 02 11:26:27 2019 +0100
+++ b/OrthancServer/Search/HierarchicalMatcher.cpp	Wed Jan 02 11:47:58 2019 +0100
@@ -117,14 +117,20 @@
       }
       else
       {
+        flatTags_.insert(tag);
+
         std::set<DicomTag> ignoreTagLength;
         std::auto_ptr<DicomValue> value(FromDcmtkBridge::ConvertLeafElement
                                         (*element, DicomToJsonFlags_None, 
-                                         ORTHANC_MAXIMUM_TAG_LENGTH, encoding, ignoreTagLength));
+                                         0, encoding, ignoreTagLength));
 
-        flatTags_.insert(tag);
-        
-        if (value->IsBinary())
+        // WARNING: Also modify "DatabaseLookup::IsMatch()" if modifying this code
+        if (value.get() == NULL ||
+            value->IsNull())
+        {
+          // This is an universal constraint
+        }
+        else if (value->IsBinary())
         {
           if (!value->GetContent().empty())
           {
@@ -133,8 +139,7 @@
                          << "It will be ignored.";
           }
         }
-        else if (value->IsNull() ||
-                 value->GetContent().empty())
+        else if (value->GetContent().empty())
         {
           // This is an universal matcher
         }