changeset 553:7f45f23b10d0 find-refactoring

integration mainline->find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Sep 2024 15:27:52 +0200
parents 9ed9a91bde33 (current diff) 987460ae14c9 (diff)
children 1a74fc1bea2d
files Framework/Plugins/DatabaseBackendAdapterV4.cpp Framework/Plugins/DatabaseConstraint.cpp Framework/Plugins/DatabaseConstraint.h Framework/Plugins/IDatabaseBackend.h Framework/Plugins/ISqlLookupFormatter.cpp Framework/Plugins/ISqlLookupFormatter.h Framework/Plugins/IndexBackend.cpp Framework/Plugins/IndexBackend.h
diffstat 10 files changed, 132 insertions(+), 132 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV2.cpp	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV2.cpp	Mon Sep 09 15:27:52 2024 +0200
@@ -1413,16 +1413,16 @@
     {
       DatabaseBackendAdapterV2::Adapter::DatabaseAccessor accessor(*adapter);
 
-      Orthanc::DatabaseConstraints lookup;
+      DatabaseConstraints lookup;
 
       for (uint32_t i = 0; i < constraintsCount; i++)
       {
-        lookup.AddConstraint(new Orthanc::DatabaseConstraint(constraints[i]));
+        lookup.AddConstraint(new DatabaseConstraint(constraints[i]));
       }
         
       std::set<std::string> noLabel;
       adapter->GetBackend().LookupResources(*output, accessor.GetManager(), lookup, queryLevel, noLabel,
-                                            Orthanc::LabelsConstraint_All, limit, (requestSomeInstance != 0));
+                                            LabelsConstraint_All, limit, (requestSomeInstance != 0));
       
       return OrthancPluginErrorCode_Success;
     }
--- a/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV3.cpp	Mon Sep 09 15:27:52 2024 +0200
@@ -1640,16 +1640,16 @@
     {
       t->GetOutput().Clear();
 
-      Orthanc::DatabaseConstraints lookup;
+      DatabaseConstraints lookup;
 
       for (uint32_t i = 0; i < constraintsCount; i++)
       {
-        lookup.AddConstraint(new Orthanc::DatabaseConstraint(constraints[i]));
+        lookup.AddConstraint(new DatabaseConstraint(constraints[i]));
       }
         
       std::set<std::string> noLabel;
       t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, noLabel,
-                                      Orthanc::LabelsConstraint_All, limit, (requestSomeInstanceId != 0));
+                                      LabelsConstraint_All, limit, (requestSomeInstanceId != 0));
       return OrthancPluginErrorCode_Success;
     }
     ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Mon Sep 09 15:27:52 2024 +0200
@@ -550,7 +550,7 @@
     std::vector<const char*> values;
     values.reserve(countValues);
 
-    Orthanc::DatabaseConstraints lookup;
+    DatabaseConstraints lookup;
 
     for (int i = 0; i < request.lookup().size(); i++)
     {
@@ -613,7 +613,7 @@
         }
       }
 
-      lookup.AddConstraint(new Orthanc::DatabaseConstraint(c));
+      lookup.AddConstraint(new DatabaseConstraint(c));
     }
 
     assert(values.size() == countValues);
@@ -625,19 +625,19 @@
       labels.insert(request.labels(i));
     }
 
-    Orthanc::LabelsConstraint labelsConstraint;
+    LabelsConstraint labelsConstraint;
     switch (request.labels_constraint())
     {
       case Orthanc::DatabasePluginMessages::LABELS_CONSTRAINT_ALL:
-        labelsConstraint = Orthanc::LabelsConstraint_All;
+        labelsConstraint = LabelsConstraint_All;
         break;
             
       case Orthanc::DatabasePluginMessages::LABELS_CONSTRAINT_ANY:
-        labelsConstraint = Orthanc::LabelsConstraint_Any;
+        labelsConstraint = LabelsConstraint_Any;
         break;
             
       case Orthanc::DatabasePluginMessages::LABELS_CONSTRAINT_NONE:
-        labelsConstraint = Orthanc::LabelsConstraint_None;
+        labelsConstraint = LabelsConstraint_None;
         break;
             
       default:
--- a/Framework/Plugins/DatabaseConstraint.cpp	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/DatabaseConstraint.cpp	Mon Sep 09 15:27:52 2024 +0200
@@ -36,50 +36,50 @@
 #include <cassert>
 
 
-namespace Orthanc
+namespace OrthancDatabases
 {
   namespace Plugins
   {
-    OrthancPluginResourceType Convert(ResourceType type)
+    OrthancPluginResourceType Convert(Orthanc::ResourceType type)
     {
       switch (type)
       {
-        case ResourceType_Patient:
+        case Orthanc::ResourceType_Patient:
           return OrthancPluginResourceType_Patient;
 
-        case ResourceType_Study:
+        case Orthanc::ResourceType_Study:
           return OrthancPluginResourceType_Study;
 
-        case ResourceType_Series:
+        case Orthanc::ResourceType_Series:
           return OrthancPluginResourceType_Series;
 
-        case ResourceType_Instance:
+        case Orthanc::ResourceType_Instance:
           return OrthancPluginResourceType_Instance;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
     }
 
 
-    ResourceType Convert(OrthancPluginResourceType type)
+    Orthanc::ResourceType Convert(OrthancPluginResourceType type)
     {
       switch (type)
       {
         case OrthancPluginResourceType_Patient:
-          return ResourceType_Patient;
+          return Orthanc::ResourceType_Patient;
 
         case OrthancPluginResourceType_Study:
-          return ResourceType_Study;
+          return Orthanc::ResourceType_Study;
 
         case OrthancPluginResourceType_Series:
-          return ResourceType_Series;
+          return Orthanc::ResourceType_Series;
 
         case OrthancPluginResourceType_Instance:
-          return ResourceType_Instance;
+          return Orthanc::ResourceType_Instance;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
     }
 
@@ -105,7 +105,7 @@
           return OrthancPluginConstraintType_List;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
     }
 #endif
@@ -132,14 +132,14 @@
           return ConstraintType_List;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
     }
 #endif
   }
 
-  DatabaseConstraint::DatabaseConstraint(ResourceType level,
-                                         const DicomTag& tag,
+  DatabaseConstraint::DatabaseConstraint(Orthanc::ResourceType level,
+                                         const Orthanc::DicomTag& tag,
                                          bool isIdentifier,
                                          ConstraintType type,
                                          const std::vector<std::string>& values,
@@ -156,7 +156,7 @@
     if (type != ConstraintType_List &&
         values_.size() != 1)
     {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
   }
 
@@ -173,7 +173,7 @@
     if (constraintType_ != ConstraintType_List &&
         constraint.valuesCount != 1)
     {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
 
     values_.resize(constraint.valuesCount);
@@ -198,23 +198,23 @@
     switch (constraint.type())
     {
       case Orthanc::DatabasePluginMessages::CONSTRAINT_EQUAL:
-        constraintType_ = Orthanc::ConstraintType_Equal;
+        constraintType_ = ConstraintType_Equal;
         break;
 
       case Orthanc::DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL:
-        constraintType_ = Orthanc::ConstraintType_SmallerOrEqual;
+        constraintType_ = ConstraintType_SmallerOrEqual;
         break;
 
       case Orthanc::DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL:
-        constraintType_ = Orthanc::ConstraintType_GreaterOrEqual;
+        constraintType_ = ConstraintType_GreaterOrEqual;
         break;
 
       case Orthanc::DatabasePluginMessages::CONSTRAINT_WILDCARD:
-        constraintType_ = Orthanc::ConstraintType_Wildcard;
+        constraintType_ = ConstraintType_Wildcard;
         break;
 
       case Orthanc::DatabasePluginMessages::CONSTRAINT_LIST:
-        constraintType_ = Orthanc::ConstraintType_List;
+        constraintType_ = ConstraintType_List;
         break;
 
       default:
@@ -224,7 +224,7 @@
     if (constraintType_ != ConstraintType_List &&
         constraint.values().size() != 1)
     {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
 
     values_.resize(constraint.values().size());
@@ -241,7 +241,7 @@
   {
     if (index >= values_.size())
     {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
     else
     {
@@ -254,7 +254,7 @@
   {
     if (values_.size() != 1)
     {
-      throw OrthancException(ErrorCode_BadSequenceOfCalls);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
     }
     else
     {
@@ -305,7 +305,7 @@
   {
     if (constraint == NULL)
     {
-      throw OrthancException(ErrorCode_NullPointer);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
     }
     else
     {
@@ -318,7 +318,7 @@
   {
     if (index >= constraints_.size())
     {
-      throw OrthancException(ErrorCode_ParameterOutOfRange);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
     else
     {
@@ -378,7 +378,7 @@
         }
 
         default:
-          throw OrthancException(ErrorCode_InternalError);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
       }
 
       s += "\n";
--- a/Framework/Plugins/DatabaseConstraint.h	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/DatabaseConstraint.h	Mon Sep 09 15:27:52 2024 +0200
@@ -36,7 +36,7 @@
 
 #include <deque>
 
-namespace Orthanc
+namespace OrthancDatabases
 {
   enum ConstraintType
   {
@@ -49,9 +49,9 @@
 
   namespace Plugins
   {
-    OrthancPluginResourceType Convert(ResourceType type);
+    OrthancPluginResourceType Convert(Orthanc::ResourceType type);
 
-    ResourceType Convert(OrthancPluginResourceType type);
+    Orthanc::ResourceType Convert(OrthancPluginResourceType type);
 
 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
     OrthancPluginConstraintType Convert(ConstraintType constraint);
@@ -66,8 +66,8 @@
   class DatabaseConstraint : public boost::noncopyable
   {
   private:
-    ResourceType              level_;
-    DicomTag                  tag_;
+    Orthanc::ResourceType     level_;
+    Orthanc::DicomTag         tag_;
     bool                      isIdentifier_;
     ConstraintType            constraintType_;
     std::vector<std::string>  values_;
@@ -75,8 +75,8 @@
     bool                      mandatory_;
 
   public:
-    DatabaseConstraint(ResourceType level,
-                       const DicomTag& tag,
+    DatabaseConstraint(Orthanc::ResourceType level,
+                       const Orthanc::DicomTag& tag,
                        bool isIdentifier,
                        ConstraintType type,
                        const std::vector<std::string>& values,
@@ -91,12 +91,12 @@
     explicit DatabaseConstraint(const Orthanc::DatabasePluginMessages::DatabaseConstraint& constraint);
 #endif
 
-    ResourceType GetLevel() const
+    Orthanc::ResourceType GetLevel() const
     {
       return level_;
     }
 
-    const DicomTag& GetTag() const
+    const Orthanc::DicomTag& GetTag() const
     {
       return tag_;
     }
@@ -130,7 +130,7 @@
       return mandatory_;
     }
 
-    bool IsMatch(const DicomMap& dicom) const;
+    bool IsMatch(const Orthanc::DicomMap& dicom) const;
 
 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
     void EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
--- a/Framework/Plugins/IDatabaseBackend.h	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/IDatabaseBackend.h	Mon Sep 09 15:27:52 2024 +0200
@@ -285,10 +285,10 @@
 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
     virtual void LookupResources(IDatabaseBackendOutput& output,
                                  DatabaseManager& manager,
-                                 const Orthanc::DatabaseConstraints& lookup,
+                                 const DatabaseConstraints& lookup,
                                  OrthancPluginResourceType queryLevel,
-                                 const std::set<std::string>& labels,         // New in Orthanc 1.12.0
-                                 Orthanc::LabelsConstraint labelsConstraint,  // New in Orthanc 1.12.0
+                                 const std::set<std::string>& labels,     // New in Orthanc 1.12.0
+                                 LabelsConstraint labelsConstraint,       // New in Orthanc 1.12.0
                                  uint32_t limit,
                                  bool requestSomeInstance) = 0;
 #endif
--- a/Framework/Plugins/ISqlLookupFormatter.cpp	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/ISqlLookupFormatter.cpp	Mon Sep 09 15:27:52 2024 +0200
@@ -40,26 +40,26 @@
 #include <list>
 
 
-namespace Orthanc
+namespace OrthancDatabases
 {
-  static std::string FormatLevel(ResourceType level)
+  static std::string FormatLevel(Orthanc::ResourceType level)
   {
     switch (level)
     {
-      case ResourceType_Patient:
+      case Orthanc::ResourceType_Patient:
         return "patients";
 
-      case ResourceType_Study:
+      case Orthanc::ResourceType_Study:
         return "studies";
 
-      case ResourceType_Series:
+      case Orthanc::ResourceType_Series:
         return "series";
 
-      case ResourceType_Instance:
+      case Orthanc::ResourceType_Instance:
         return "instances";
 
       default:
-        throw OrthancException(ErrorCode_InternalError);
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
     }
   }
 
@@ -96,7 +96,7 @@
             break;
 
           default:
-            throw OrthancException(ErrorCode_InternalError);
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
         }
 
         std::string parameter = formatter.GenerateParameter(constraint.GetSingleValue());
@@ -331,7 +331,7 @@
             break;
 
           default:
-            throw OrthancException(ErrorCode_InternalError);
+            throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
         }
 
         std::string parameter = formatter.GenerateParameter(constraint.GetSingleValue());
@@ -366,7 +366,7 @@
         }
 
         std::string values;
-        Toolbox::JoinStrings(values, comparisonValues, ", ");
+        Orthanc::Toolbox::JoinStrings(values, comparisonValues, ", ");
 
         if (constraint.IsCaseSensitive())
         {
@@ -469,21 +469,21 @@
   }
 
 
-  void ISqlLookupFormatter::GetLookupLevels(ResourceType& lowerLevel,
-                                            ResourceType& upperLevel,
-                                            const ResourceType& queryLevel,
+  void ISqlLookupFormatter::GetLookupLevels(Orthanc::ResourceType& lowerLevel,
+                                            Orthanc::ResourceType& upperLevel,
+                                            const Orthanc::ResourceType& queryLevel,
                                             const DatabaseConstraints& lookup)
   {
-    assert(ResourceType_Patient < ResourceType_Study &&
-           ResourceType_Study < ResourceType_Series &&
-           ResourceType_Series < ResourceType_Instance);
+    assert(Orthanc::ResourceType_Patient < Orthanc::ResourceType_Study &&
+           Orthanc::ResourceType_Study < Orthanc::ResourceType_Series &&
+           Orthanc::ResourceType_Series < Orthanc::ResourceType_Instance);
 
     lowerLevel = queryLevel;
     upperLevel = queryLevel;
 
     for (size_t i = 0; i < lookup.GetSize(); i++)
     {
-      ResourceType level = lookup.GetConstraint(i).GetLevel();
+      Orthanc::ResourceType level = lookup.GetConstraint(i).GetLevel();
 
       if (level < upperLevel)
       {
@@ -501,12 +501,12 @@
   void ISqlLookupFormatter::Apply(std::string& sql,
                                   ISqlLookupFormatter& formatter,
                                   const DatabaseConstraints& lookup,
-                                  ResourceType queryLevel,
+                                  Orthanc::ResourceType queryLevel,
                                   const std::set<std::string>& labels,
                                   LabelsConstraint labelsConstraint,
                                   size_t limit)
   {
-    ResourceType lowerLevel, upperLevel;
+    Orthanc::ResourceType lowerLevel, upperLevel;
     GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup);
 
     assert(upperLevel <= queryLevel &&
@@ -547,17 +547,17 @@
     for (int level = queryLevel - 1; level >= upperLevel; level--)
     {
       sql += (" INNER JOIN Resources " +
-              FormatLevel(static_cast<ResourceType>(level)) + " ON " +
-              FormatLevel(static_cast<ResourceType>(level)) + ".internalId=" +
-              FormatLevel(static_cast<ResourceType>(level + 1)) + ".parentId");
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + " ON " +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + ".internalId=" +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level + 1)) + ".parentId");
     }
 
     for (int level = queryLevel + 1; level <= lowerLevel; level++)
     {
       sql += (" INNER JOIN Resources " +
-              FormatLevel(static_cast<ResourceType>(level)) + " ON " +
-              FormatLevel(static_cast<ResourceType>(level - 1)) + ".internalId=" +
-              FormatLevel(static_cast<ResourceType>(level)) + ".parentId");
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + " ON " +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level - 1)) + ".internalId=" +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + ".parentId");
     }
 
     std::list<std::string> where;
@@ -595,7 +595,7 @@
           break;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
 
       where.push_back("(SELECT COUNT(1) FROM Labels AS selectedLabels WHERE selectedLabels.id = " + FormatLevel(queryLevel) +
@@ -612,7 +612,7 @@
 
 
 #if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1
-  static ResourceType DetectLevel(const Orthanc::DatabasePluginMessages::Find_Request& request)
+  static Orthanc::ResourceType DetectLevel(const Orthanc::DatabasePluginMessages::Find_Request& request)
   {
     // This corresponds to "Orthanc::OrthancIdentifiers()::DetectLevel()" in the Orthanc core
     if (!request.orthanc_id_patient().empty() &&
@@ -620,26 +620,26 @@
         request.orthanc_id_series().empty() &&
         request.orthanc_id_instance().empty())
     {
-      return ResourceType_Patient;
+      return Orthanc::ResourceType_Patient;
     }
     else if (!request.orthanc_id_study().empty() &&
              request.orthanc_id_series().empty() &&
              request.orthanc_id_instance().empty())
     {
-      return ResourceType_Study;
+      return Orthanc::ResourceType_Study;
     }
     else if (!request.orthanc_id_series().empty() &&
              request.orthanc_id_instance().empty())
     {
-      return ResourceType_Series;
+      return Orthanc::ResourceType_Series;
     }
     else if (!request.orthanc_id_instance().empty())
     {
-      return ResourceType_Instance;
+      return Orthanc::ResourceType_Instance;
     }
     else
     {
-      throw OrthancException(ErrorCode_InternalError);
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
     }
   }
 
@@ -648,7 +648,7 @@
                                   const Orthanc::DatabasePluginMessages::Find_Request& request)
   {
     const bool escapeBrackets = formatter.IsEscapeBrackets();
-    ResourceType queryLevel = OrthancDatabases::MessagesToolbox::Convert(request.level());
+    Orthanc::ResourceType queryLevel = OrthancDatabases::MessagesToolbox::Convert(request.level());
     const std::string& strQueryLevel = FormatLevel(queryLevel);
 
     DatabaseConstraints constraints;
@@ -658,7 +658,7 @@
       constraints.AddConstraint(new DatabaseConstraint(request.dicom_tag_constraints(i)));
     }
 
-    ResourceType lowerLevel, upperLevel;
+    Orthanc::ResourceType lowerLevel, upperLevel;
     GetLookupLevels(lowerLevel, upperLevel, queryLevel, constraints);
 
     assert(upperLevel <= queryLevel &&
@@ -689,35 +689,35 @@
         throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
       }
 
-      ResourceType topParentLevel = DetectLevel(request);
+      Orthanc::ResourceType topParentLevel = DetectLevel(request);
       const std::string& strTopParentLevel = FormatLevel(topParentLevel);
 
       std::string publicId;
       switch (topParentLevel)
       {
-        case ResourceType_Patient:
+        case Orthanc::ResourceType_Patient:
           publicId = request.orthanc_id_patient();
           break;
 
-        case ResourceType_Study:
+        case Orthanc::ResourceType_Study:
           publicId = request.orthanc_id_study();
           break;
 
-        case ResourceType_Series:
+        case Orthanc::ResourceType_Series:
           publicId = request.orthanc_id_series();
           break;
 
-        case ResourceType_Instance:
+        case Orthanc::ResourceType_Instance:
           publicId = request.orthanc_id_instance();
           break;
 
         default:
-          throw OrthancException(ErrorCode_InternalError);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
       }
 
       if (publicId.empty())
       {
-        throw OrthancException(ErrorCode_InternalError);
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
       }
 
       comparisons = " AND " + strTopParentLevel + ".publicId = " + formatter.GenerateParameter(publicId);
@@ -725,9 +725,9 @@
       for (int level = queryLevel; level > topParentLevel; level--)
       {
         sql += (" INNER JOIN Resources " +
-                FormatLevel(static_cast<ResourceType>(level - 1)) + " ON " +
-                FormatLevel(static_cast<ResourceType>(level - 1)) + ".internalId=" +
-                FormatLevel(static_cast<ResourceType>(level)) + ".parentId");
+                FormatLevel(static_cast<Orthanc::ResourceType>(level - 1)) + " ON " +
+                FormatLevel(static_cast<Orthanc::ResourceType>(level - 1)) + ".internalId=" +
+                FormatLevel(static_cast<Orthanc::ResourceType>(level)) + ".parentId");
       }
     }
     else
@@ -759,17 +759,17 @@
     for (int level = queryLevel - 1; level >= upperLevel; level--)
     {
       sql += (" INNER JOIN Resources " +
-              FormatLevel(static_cast<ResourceType>(level)) + " ON " +
-              FormatLevel(static_cast<ResourceType>(level)) + ".internalId=" +
-              FormatLevel(static_cast<ResourceType>(level + 1)) + ".parentId");
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + " ON " +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + ".internalId=" +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level + 1)) + ".parentId");
     }
 
     for (int level = queryLevel + 1; level <= lowerLevel; level++)
     {
       sql += (" INNER JOIN Resources " +
-              FormatLevel(static_cast<ResourceType>(level)) + " ON " +
-              FormatLevel(static_cast<ResourceType>(level - 1)) + ".internalId=" +
-              FormatLevel(static_cast<ResourceType>(level)) + ".parentId");
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + " ON " +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level - 1)) + ".internalId=" +
+              FormatLevel(static_cast<Orthanc::ResourceType>(level)) + ".parentId");
     }
 
     std::list<std::string> where;
@@ -808,7 +808,7 @@
           break;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
 
       where.push_back("(SELECT COUNT(1) FROM Labels AS selectedLabels WHERE selectedLabels.id = " + strQueryLevel +
@@ -829,13 +829,13 @@
   void ISqlLookupFormatter::ApplySingleLevel(std::string& sql,
                                              ISqlLookupFormatter& formatter,
                                              const DatabaseConstraints& lookup,
-                                             ResourceType queryLevel,
+                                             Orthanc::ResourceType queryLevel,
                                              const std::set<std::string>& labels,
                                              LabelsConstraint labelsConstraint,
                                              size_t limit
                                              )
   {
-    ResourceType lowerLevel, upperLevel;
+    Orthanc::ResourceType lowerLevel, upperLevel;
     GetLookupLevels(lowerLevel, upperLevel, queryLevel, lookup);
 
     assert(upperLevel == queryLevel &&
@@ -923,7 +923,7 @@
           break;
 
         default:
-          throw OrthancException(ErrorCode_ParameterOutOfRange);
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
       }
 
       sql += (" AND internalId " + inOrNotIn + " (SELECT id"
--- a/Framework/Plugins/ISqlLookupFormatter.h	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/ISqlLookupFormatter.h	Mon Sep 09 15:27:52 2024 +0200
@@ -35,7 +35,7 @@
 #include <boost/noncopyable.hpp>
 #include <vector>
 
-namespace Orthanc
+namespace OrthancDatabases
 {
   class DatabaseConstraints;
   class FindRequest;
@@ -56,7 +56,7 @@
 
     virtual std::string GenerateParameter(const std::string& value) = 0;
 
-    virtual std::string FormatResourceType(ResourceType level) = 0;
+    virtual std::string FormatResourceType(Orthanc::ResourceType level) = 0;
 
     virtual std::string FormatWildcardEscape() = 0;
 
@@ -69,15 +69,15 @@
      **/
     virtual bool IsEscapeBrackets() const = 0;
 
-    static void GetLookupLevels(ResourceType& lowerLevel,
-                                ResourceType& upperLevel,
-                                const ResourceType& queryLevel,
+    static void GetLookupLevels(Orthanc::ResourceType& lowerLevel,
+                                Orthanc::ResourceType& upperLevel,
+                                const Orthanc::ResourceType& queryLevel,
                                 const DatabaseConstraints& lookup);
 
     static void Apply(std::string& sql,
                       ISqlLookupFormatter& formatter,
                       const DatabaseConstraints& lookup,
-                      ResourceType queryLevel,
+                      Orthanc::ResourceType queryLevel,
                       const std::set<std::string>& labels,  // New in Orthanc 1.12.0
                       LabelsConstraint labelsConstraint,    // New in Orthanc 1.12.0
                       size_t limit);
@@ -85,7 +85,7 @@
     static void ApplySingleLevel(std::string& sql,
                                  ISqlLookupFormatter& formatter,
                                  const DatabaseConstraints& lookup,
-                                 ResourceType queryLevel,
+                                 Orthanc::ResourceType queryLevel,
                                  const std::set<std::string>& labels,  // New in Orthanc 1.12.0
                                  LabelsConstraint labelsConstraint,    // New in Orthanc 1.12.0
                                  size_t limit);
--- a/Framework/Plugins/IndexBackend.cpp	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/IndexBackend.cpp	Mon Sep 09 15:27:52 2024 +0200
@@ -2127,7 +2127,7 @@
 
 
 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
-  class IndexBackend::LookupFormatter : public Orthanc::ISqlLookupFormatter
+  class IndexBackend::LookupFormatter : public ISqlLookupFormatter
   {
   private:
     Dialect     dialect_;
@@ -2158,7 +2158,7 @@
 
     virtual std::string FormatResourceType(Orthanc::ResourceType level)
     {
-      return boost::lexical_cast<std::string>(Orthanc::Plugins::Convert(level));
+      return boost::lexical_cast<std::string>(Plugins::Convert(level));
     }
 
     virtual std::string FormatWildcardEscape()
@@ -2244,24 +2244,24 @@
   // New primitive since Orthanc 1.5.2
   void IndexBackend::LookupResources(IDatabaseBackendOutput& output,
                                      DatabaseManager& manager,
-                                     const Orthanc::DatabaseConstraints& lookup,
+                                     const DatabaseConstraints& lookup,
                                      OrthancPluginResourceType queryLevel_,
                                      const std::set<std::string>& labels,
-                                     Orthanc::LabelsConstraint labelsConstraint,
+                                     LabelsConstraint labelsConstraint,
                                      uint32_t limit,
                                      bool requestSomeInstance)
   {
     LookupFormatter formatter(manager.GetDialect());
-    Orthanc::ResourceType queryLevel = Orthanc::Plugins::Convert(queryLevel_);
+    Orthanc::ResourceType queryLevel = Plugins::Convert(queryLevel_);
     Orthanc::ResourceType lowerLevel, upperLevel;
-    Orthanc::ISqlLookupFormatter::GetLookupLevels(lowerLevel, upperLevel,  queryLevel, lookup);
+    ISqlLookupFormatter::GetLookupLevels(lowerLevel, upperLevel,  queryLevel, lookup);
 
     std::string sql;
     bool enableNewStudyCode = true;
 
     if (enableNewStudyCode && lowerLevel == queryLevel && upperLevel == queryLevel)
     {
-      Orthanc::ISqlLookupFormatter::ApplySingleLevel(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit);
+      ISqlLookupFormatter::ApplySingleLevel(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit);
 
       if (requestSomeInstance)
       {
@@ -2310,7 +2310,7 @@
     }
     else
     {
-      Orthanc::ISqlLookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit);      
+      ISqlLookupFormatter::Apply(sql, formatter, lookup, queryLevel, labels, labelsConstraint, limit);
 
       if (requestSomeInstance)
       {
@@ -2945,7 +2945,7 @@
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0)
     if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 12, 0) == 1)
     {
-      OrthancDatabases::DatabaseBackendAdapterV4::Register(backend, countConnections, maxDatabaseRetries);
+      DatabaseBackendAdapterV4::Register(backend, countConnections, maxDatabaseRetries);
       return;
     }
 #  endif
@@ -2955,14 +2955,14 @@
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
     if (OrthancPluginCheckVersionAdvanced(backend->GetContext(), 1, 9, 2) == 1)
     {
-      OrthancDatabases::DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries);
+      DatabaseBackendAdapterV3::Register(backend, countConnections, maxDatabaseRetries);
       return;
     }
 #  endif
 #endif
 
     LOG(WARNING) << "Performance warning: Your version of the Orthanc core or SDK doesn't support multiple readers/writers";
-    OrthancDatabases::DatabaseBackendAdapterV2::Register(backend);
+    DatabaseBackendAdapterV2::Register(backend);
   }
 
 
@@ -3005,17 +3005,17 @@
 
   void IndexBackend::Finalize()
   {
-    OrthancDatabases::DatabaseBackendAdapterV2::Finalize();
+    DatabaseBackendAdapterV2::Finalize();
 
 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
-    OrthancDatabases::DatabaseBackendAdapterV3::Finalize();
+    DatabaseBackendAdapterV3::Finalize();
 #  endif
 #endif
 
 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)         // Macro introduced in Orthanc 1.3.1
 #  if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0)
-    OrthancDatabases::DatabaseBackendAdapterV4::Finalize();
+    DatabaseBackendAdapterV4::Finalize();
 #  endif
 #endif
   }
--- a/Framework/Plugins/IndexBackend.h	Mon Sep 09 15:04:48 2024 +0200
+++ b/Framework/Plugins/IndexBackend.h	Mon Sep 09 15:27:52 2024 +0200
@@ -312,10 +312,10 @@
     // New primitive since Orthanc 1.5.2
     virtual void LookupResources(IDatabaseBackendOutput& output,
                                  DatabaseManager& manager,
-                                 const Orthanc::DatabaseConstraints& lookup,
+                                 const DatabaseConstraints& lookup,
                                  OrthancPluginResourceType queryLevel,
                                  const std::set<std::string>& labels,
-                                 Orthanc::LabelsConstraint labelsConstraint,
+                                 LabelsConstraint labelsConstraint,
                                  uint32_t limit,
                                  bool requestSomeInstance) ORTHANC_OVERRIDE;
 #endif