changeset 5776:de33982a0bf4 find-refactoring

wip: started implementing Find in PostgreSQL
author Alain Mazy <am@orthanc.team>
date Fri, 13 Sep 2024 11:57:14 +0200
parents 9af45c841f59
children 92298bfc5451
files OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp OrthancServer/Sources/Database/FindRequest.cpp OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.h OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp
diffstat 6 files changed, 14 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Thu Sep 12 10:03:17 2024 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Fri Sep 13 11:57:14 2024 +0200
@@ -1577,8 +1577,6 @@
 
           response.Add(target.release());
         }
-
-        throw OrthancException(ErrorCode_NotImplemented);
       }
       else
       {
--- a/OrthancServer/Sources/Database/FindRequest.cpp	Thu Sep 12 10:03:17 2024 +0200
+++ b/OrthancServer/Sources/Database/FindRequest.cpp	Fri Sep 13 11:57:14 2024 +0200
@@ -261,13 +261,6 @@
 
   bool FindRequest::IsRetrieveOneInstanceMetadataAndAttachments() const
   {
-    if (level_ == ResourceType_Instance)
-    {
-      throw OrthancException(ErrorCode_BadSequenceOfCalls);
-    }
-    else
-    {
-      return retrieveOneInstanceMetadataAndAttachments_;
-    }
+    return retrieveOneInstanceMetadataAndAttachments_;
   }
 }
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Thu Sep 12 10:03:17 2024 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Fri Sep 13 11:57:14 2024 +0200
@@ -1806,6 +1806,7 @@
     dbCapabilities_.SetFlushToDisk(true);
     dbCapabilities_.SetLabelsSupport(true);
     dbCapabilities_.SetHasExtendedChanges(true);
+    dbCapabilities_.SetHasFindSupport(true);
     db_.Open(path);
   }
 
@@ -1819,6 +1820,7 @@
     dbCapabilities_.SetFlushToDisk(true);
     dbCapabilities_.SetLabelsSupport(true);
     dbCapabilities_.SetHasExtendedChanges(true);
+    dbCapabilities_.SetHasFindSupport(true);
     db_.OpenInMemory();
   }
 
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Thu Sep 12 10:03:17 2024 +0200
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Fri Sep 13 11:57:14 2024 +0200
@@ -3716,6 +3716,12 @@
     return db_.GetDatabaseCapabilities().HasExtendedChanges();
   }
 
+  bool StatelessDatabaseOperations::HasFindSupport()
+  {
+    boost::shared_lock<boost::shared_mutex> lock(mutex_);
+    return db_.GetDatabaseCapabilities().HasFindSupport();
+  }
+
   void StatelessDatabaseOperations::ExecuteFind(FindResponse& response,
                                                 const FindRequest& request)
   {
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h	Thu Sep 12 10:03:17 2024 +0200
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h	Fri Sep 13 11:57:14 2024 +0200
@@ -679,6 +679,8 @@
 
     bool HasExtendedChanges();
 
+    bool HasFindSupport();
+    
     void GetExportedResources(Json::Value& target,
                               int64_t since,
                               uint32_t limit);
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Thu Sep 12 10:03:17 2024 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Fri Sep 13 11:57:14 2024 +0200
@@ -94,6 +94,7 @@
     static const char* const HAS_LABELS = "HasLabels";
     static const char* const CAPABILITIES = "Capabilities";
     static const char* const HAS_EXTENDED_CHANGES = "HasExtendedChanges";
+    static const char* const HAS_EXTENDED_FIND = "HasExtendedFind";
 
     if (call.IsDocumentation())
     {
@@ -141,7 +142,7 @@
         .SetAnswerField(HAS_LABELS, RestApiCallDocumentation::Type_Boolean,
                         "Whether the database back-end supports labels (new in Orthanc 1.12.0)")
         .SetAnswerField(CAPABILITIES, RestApiCallDocumentation::Type_JsonObject,
-                        "Whether the back-end supports optional features like 'HasExtendedChanges' (new in Orthanc 1.12.5) ")
+                        "Whether the back-end supports optional features like 'HasExtendedChanges', 'HasExtendedFind' (new in Orthanc 1.12.5) ")
         .SetHttpGetSample("https://orthanc.uclouvain.be/demo/system", true);
       return;
     }
@@ -202,6 +203,7 @@
     result[HAS_LABELS] = OrthancRestApi::GetIndex(call).HasLabelsSupport();
     result[CAPABILITIES] = Json::objectValue;
     result[CAPABILITIES][HAS_EXTENDED_CHANGES] = OrthancRestApi::GetIndex(call).HasExtendedChanges();
+    result[CAPABILITIES][HAS_EXTENDED_FIND] = OrthancRestApi::GetIndex(call).HasFindSupport();
     
     call.GetOutput().AnswerJson(result);
   }