changeset 5193:1a878922404b db-protobuf

removed unused IDatabaseWrapper::IsExistingResource()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 27 Mar 2023 16:50:48 +0200
parents af66a8e93ccf
children e9f3bddd30cc
files OrthancServer/CMakeLists.txt OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto OrthancServer/Sources/Database/IDatabaseWrapper.h OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp
diffstat 6 files changed, 150 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/CMakeLists.txt	Mon Mar 27 10:04:08 2023 +0200
+++ b/OrthancServer/CMakeLists.txt	Mon Mar 27 16:50:48 2023 +0200
@@ -41,8 +41,6 @@
 set(ENABLE_LUA ON)
 set(ENABLE_OPENSSL_ENGINES ON)  # OpenSSL engines are necessary for PKCS11
 set(ENABLE_PNG ON)
-set(ENABLE_PROTOBUF ON)
-set(ENABLE_PROTOBUF_COMPILER ON)
 set(ENABLE_PUGIXML ON)
 set(ENABLE_SQLITE ON)
 set(ENABLE_WEB_CLIENT ON)
@@ -71,6 +69,11 @@
 ## Configuration of the Orthanc framework
 #####################################################################
 
+if (ENABLE_PLUGINS)
+  set(ENABLE_PROTOBUF ON)
+  set(ENABLE_PROTOBUF_COMPILER ON)
+endif()
+
 include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/VisualStudioPrecompiledHeaders.cmake)
 include(${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake)
 
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Mar 27 10:04:08 2023 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp	Mon Mar 27 16:50:48 2023 +0200
@@ -1021,14 +1021,6 @@
     }
 
 
-    virtual bool IsExistingResource(int64_t internalId) ORTHANC_OVERRIDE
-    {
-      int32_t existing;
-      CheckSuccess(that_.backend_.isExistingResource(&existing, that_.payload_, internalId));
-      return (existing != 0);
-    }
-
-
     virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE
     {
       int32_t isProtected;
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp	Mon Mar 27 10:04:08 2023 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV3.cpp	Mon Mar 27 16:50:48 2023 +0200
@@ -594,15 +594,6 @@
     }
 
     
-    virtual bool IsExistingResource(int64_t internalId) ORTHANC_OVERRIDE
-    {
-      uint8_t b;
-      CheckSuccess(that_.backend_.isExistingResource(transaction_, &b, internalId));
-      CheckNoEvent();
-      return (b != 0);
-    }
-
-    
     virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE
     {
       uint8_t b;
--- a/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto	Mon Mar 27 10:04:08 2023 +0200
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto	Mon Mar 27 16:50:48 2023 +0200
@@ -1,7 +1,147 @@
-syntax = "proto2";
+syntax = "proto3";
+
+package Orthanc.DatabasePluginMessages;
+
+
+message FileInfo {
+  string  uuid = 1;
+  int32   content_type = 2;      // opaque "FileContentType" in Orthanc
+  uint64  uncompressedSize = 3;
+  string  uncompressedHash = 4;
+  int32   compression = 5;       // opaque "CompressionType" in Orthanc
+  uint64  compressedSize = 6;
+  string  compressedHash = 7;
+}
+
+
+/**
+ * Database-level operations
+ **/
+
+enum DatabaseOperation {
+  OPERATION_OPEN = 0;
+  OPERATION_CLOSE = 1;
+}
+
+message RequestDatabase {
+  sfixed64          database = 1;
+  DatabaseOperation operation = 2;
+}
+
+message ResponseDatabase {
+  int32 error_code = 1;
+}
+
+
+/**
+ * Transaction-level operations
+ **/
 
-message Point {
-  required int32 x = 1;
-  required int32 y = 2;
-  optional string label = 3;
+enum TransactionOperation {
+  OPERATION_ROLLBACK = 0;
+  OPERATION_COMMIT = 1;
+  OPERATION_ADD_ATTACHMENT = 2;
+  OPERATION_OPERATION_CLEAR_CHANGES = 3;
+  OPERATION_CLEAR_EXPORTED_RESOURCES = 4;
+  OPERATION_DELETE_ATTACHMENT = 5;
+  OPERATION_DELETE_METADATA = 6;
+  OPERATION_DELETE_RESOURCE = 7;
+  OPERATION_GET_ALL_METADATA = 8;
+  OPERATION_GET_ALL_PUBLIC_IDS = 9;
+  OPERATION_GET_ALL_PUBLIC_IDS_LIMITS = 10;
+  OPERATION_GET_CHANGES = 11;
+  OPERATION_GET_CHILDREN_INTERNAL_ID = 12;
+  OPERATION_GET_CHILDREN_PUBLIC_ID = 13;
+  OPERATION_GET_EXPORTED_RESOURCES = 14;
+  OPERATION_GET_LAST_CHANGE = 15;
+  OPERATION_GET_LAST_EXPORTEDRESOURCE = 16;
+  OPERATION_GET_MAIN_DICOM_TAGS = 17;
+  OPERATION_GET_PUBLIC_ID = 18;
+  OPERATION_GET_RESOURCES_COUNT = 19;
+  OPERATION_GET_RESOURCE_TYPE = 20;
+  OPERATION_GET_TOTAL_COMPRESSED_SIZE = 21;
+  OPERATION_GET_TOTAL_UNCOMPRESSED_SIZE = 22;
+  OPERATION_IS_PROTECTED_PATIENT = 23;
+  OPERATION_LIST_AVAILABLE_ATTACHMENTS = 24;
+  OPERATION_LOG_CHANGE = 25;
+  OPERATION_LOG_EXPORTEDRESOURCE = 26;
+  OPERATION_LOOKUP_ATTACHMENT = 27;
+  OPERATION_LOOKUP_GLOBAL_PROPERTY = 28;
+  OPERATION_LOOKUP_METADATA = 29;
+  OPERATION_LOOKUP_PARENT = 30;
+  OPERATION_LOOKUP_RESOURCE = 31;
+  OPERATION_SELECT_PATIENT_TO_RECYCLE = 32;
+  OPERATION_SELECT_PATIENT_TO_RECYCLE_WITH_AVOID = 33;
+  OPERATION_SET_GLOBAL_PROPERTY = 34;
+  OPERATION_CLEAR_MAIN_DICOM_TAGS = 35;
+  OPERATION_SET_METADATA = 36;
+  OPERATION_SET_PROTECTED_PATIENT = 37;
+  OPERATION_IS_DISK_SIZE_ABOVE = 38;
+  OPERATION_APPLY_LOOKUP_RESOURCES = 39;
+  OPERATION_CREATE_INSTANCE = 40;
+  OPERATION_SET_RESOURCES_CONTENT = 41;
+  OPERATION_GET_CHILDREN_METADATA = 42;
+  OPERATION_GET_LAST_CHANGE_INDEX = 43;
+  OPERATION_LOOKUP_RESOURCE_AND_PARENT = 44;
+}
+
+message Rollback {
+  message Request {
+  }
+  message Response {
+  }
 }
+
+message Commit {
+  message Request {
+    int64 fileSizeDelta = 1;
+  }
+  message Response {
+  }
+}
+
+message AddAttachment {
+  message Request {
+    int64 id = 1;
+    FileInfo attachment = 2;
+    int64 revision = 3;
+  }
+  message Response {
+  }
+}
+
+message ClearChanges {
+  message Request {
+  }
+  message Response {
+  }
+}
+
+message GetAllPublicIds {
+  message Request {
+  }
+  message Response {
+    repeated string ids = 1;
+  }
+}
+
+message RequestTransaction {
+  sfixed64             transaction = 1;
+  TransactionOperation operation = 2;
+
+  Rollback.Request         rollback = 100;
+  Commit.Request           commit = 101;
+  AddAttachment.Request    add_attachment = 102;
+  ClearChanges.Request     clear_changes = 103;
+  GetAllPublicIds.Request  get_all_public_ids = 1000;
+}
+
+message ResponseTransaction {
+  int32 error_code = 1;
+
+  Rollback.Response         rollback = 100;
+  Commit.Response           commit = 101;
+  AddAttachment.Response    add_attachment = 102;
+  ClearChanges.Response     clear_changes = 103;
+  GetAllPublicIds.Response  get_all_public_ids = 1000;
+}
--- a/OrthancServer/Sources/Database/IDatabaseWrapper.h	Mon Mar 27 10:04:08 2023 +0200
+++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h	Mon Mar 27 16:50:48 2023 +0200
@@ -130,8 +130,6 @@
     
       virtual uint64_t GetTotalUncompressedSize() = 0;
 
-      virtual bool IsExistingResource(int64_t internalId) = 0;
-
       virtual bool IsProtectedPatient(int64_t internalId) = 0;
 
       virtual void ListAvailableAttachments(std::set<FileContentType>& target,
--- a/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Mon Mar 27 10:04:08 2023 +0200
+++ b/OrthancServer/Sources/Database/SQLiteDatabaseWrapper.cpp	Mon Mar 27 16:50:48 2023 +0200
@@ -731,15 +731,6 @@
     }
 
 
-    virtual bool IsExistingResource(int64_t internalId) ORTHANC_OVERRIDE
-    {
-      SQLite::Statement s(db_, SQLITE_FROM_HERE, 
-                          "SELECT * FROM Resources WHERE internalId=?");
-      s.BindInt64(0, internalId);
-      return s.Step();
-    }
-
-
     virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE
     {
       SQLite::Statement s(db_, SQLITE_FROM_HERE,