changeset 5823:a856763e5736 attach-custom-data

fix SDK for custom-data in attachments
author Alain Mazy <am@orthanc.team>
date Wed, 02 Oct 2024 09:39:58 +0200
parents ca5622c27d6c
children 79ac3924eff8
files OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h OrthancServer/Plugins/Samples/AdvancedStorage/Plugin.cpp
diffstat 4 files changed, 13 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Tue Oct 01 16:01:50 2024 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Wed Oct 02 09:39:58 2024 +0200
@@ -472,6 +472,7 @@
       request.mutable_add_attachment()->mutable_attachment()->set_compression_type(attachment.GetCompressionType());
       request.mutable_add_attachment()->mutable_attachment()->set_compressed_size(attachment.GetCompressedSize());
       request.mutable_add_attachment()->mutable_attachment()->set_compressed_hash(attachment.GetCompressedMD5());        
+      request.mutable_add_attachment()->mutable_attachment()->set_custom_data(attachment.GetCustomData());        // new in 1.12.6
       request.mutable_add_attachment()->set_revision(revision);
 
       ExecuteTransaction(DatabasePluginMessages::OPERATION_ADD_ATTACHMENT, request);
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Tue Oct 01 16:01:50 2024 +0200
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancCDatabasePlugin.h	Wed Oct 02 09:39:58 2024 +0200
@@ -95,18 +95,6 @@
 
   typedef struct
   {
-    const char* uuid;
-    int32_t     contentType;
-    uint64_t    uncompressedSize;
-    const char* uncompressedHash;
-    int32_t     compressionType;
-    uint64_t    compressedSize;
-    const char* compressedHash;
-    const char* customData;
-  } OrthancPluginAttachment2;
-
-  typedef struct
-  {
     uint16_t     group;
     uint16_t     element;
     const char*  value;
@@ -320,19 +308,6 @@
     context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
   }
 
-  ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerAttachment2(
-    OrthancPluginContext*          context,
-    OrthancPluginDatabaseContext*  database,
-    const OrthancPluginAttachment2* attachment)
-  {
-    _OrthancPluginDatabaseAnswer params;
-    memset(&params, 0, sizeof(params));
-    params.database = database;
-    params.type = _OrthancPluginDatabaseAnswerType_Attachment2;
-    params.valueGeneric = attachment;
-    context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
-  }
-
   ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseAnswerResource(
     OrthancPluginContext*          context,
     OrthancPluginDatabaseContext*  database,
@@ -393,19 +368,6 @@
     context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
   }
 
-  ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalDeletedAttachment2(
-    OrthancPluginContext*          context,
-    OrthancPluginDatabaseContext*  database,
-    const OrthancPluginAttachment2* attachment)
-  {
-    _OrthancPluginDatabaseAnswer params;
-    memset(&params, 0, sizeof(params));
-    params.database = database;
-    params.type = _OrthancPluginDatabaseAnswerType_DeletedAttachment2;
-    params.valueGeneric = attachment;
-    context->InvokeService(context, _OrthancPluginService_DatabaseAnswer, &params);
-  }
-
   ORTHANC_PLUGIN_INLINE void OrthancPluginDatabaseSignalDeletedResource(
     OrthancPluginContext*          context,
     OrthancPluginDatabaseContext*  database,
--- a/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h	Tue Oct 01 16:01:50 2024 +0200
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancCPlugin.h	Wed Oct 02 09:39:58 2024 +0200
@@ -121,7 +121,7 @@
 
 #define ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER     1
 #define ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER     12
-#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER  5
+#define ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER  6
 
 
 #if !defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE)
--- a/OrthancServer/Plugins/Samples/AdvancedStorage/Plugin.cpp	Tue Oct 01 16:01:50 2024 +0200
+++ b/OrthancServer/Plugins/Samples/AdvancedStorage/Plugin.cpp	Wed Oct 02 09:39:58 2024 +0200
@@ -704,15 +704,17 @@
             "Enable": false,
 
             // Enables/disables support for multiple StorageDirectories
+            // Note: when saving a file, the plugin stores only the storage-id in the SQL DB
             "MultipleStorages" : {
               "Storages" : {
-                // The storgae ids below may never change since they are stored in DB
-                // The storage path may change in case you move your data from one place to the other
+                // Only the storage id is stored in the SQL DB for each file, not the storage path.
+                // Therefore, storage path may change in case you move your data from one place to another.
+                // The storgae ids may never change since they are stored in DB; you can only add new ones.
                 "1" : "/var/lib/orthanc/db",
                 "2" : "/mnt/disk2/orthanc"
               },
 
-              // the storage on which new data is stored.
+              // The storage on which new data is stored.
               // There's currently no automatic changes of disks
               "CurrentStorage" : "2",
             },
@@ -753,12 +755,14 @@
             // - To prevent files from being overwritten, it is very important that their path is unique !
             //   Therefore, your NamingScheme must always include:
             //   - either the file {UUID} (this is mandatory in this Beta version !!!!!)
-            //   - maybe later:   at least a patient identifier {PatientID} or {OrthancPatientID},
+            //   - MAYBE IN A LATER BETA VERSION: at least a patient identifier {PatientID} or {OrthancPatientID},
             //     a study identifier {StudyInstanceUID} or {OrthancStudyID},
             //     a series identifier {SeriesInstanceUID} or {OrthancSeriesID},
             //     an instance identifier {SOPInstanceUID} or {OrthancInstanceID}
             // - The NamingScheme defines a RELATIVE path to either the "StorageDirectory" of Orthanc or one of
             //   the "MultipleStorages" of this plugin.
+            // - The path generated from the NamingScheme is stored in the SQL DB.  Therefore, you may change the
+            //   NamingScheme at any time and you'll still be able to access previously saved files.
             "NamingScheme" : "OrthancDefault",
 
             // Defines the maximum length for path used in the storage.  If a file is longer
@@ -774,6 +778,9 @@
             // legacy structure.  With this option, you can define a root folder for these 
             // non DICOM attachments
             // e.g: "OtherAttachmentsPrefix": "_attachments"
+            // Notes:
+            // - When using a prefix, the path is saved in the SQL DB.  Therefore, you may change the OtherAttachmentsPrefix
+            // at any time and you'll still be able to access previously saved files.
             "OtherAttachmentsPrefix": "",
           }
         }