# HG changeset patch # User Alain Mazy # Date 1727854820 -7200 # Node ID 991b9b285e1a21954d1a358b4f1f2fe346252b28 # Parent b0533b703c2c7c03aa45e4d7d100ab2219a9ebb0 fix custom-data handling diff -r b0533b703c2c -r 991b9b285e1a Framework/Plugins/DatabaseBackendAdapterV4.cpp --- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp Tue Oct 01 16:02:48 2024 +0200 +++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp Wed Oct 02 09:40:20 2024 +0200 @@ -225,6 +225,9 @@ attachment->set_compression_type(compressionType); attachment->set_compressed_size(compressedSize); attachment->set_compressed_hash(compressedHash); +#if ORTHANC_PLUGINS_HAS_ATTACHMENTS_CUSTOM_DATA == 1 + attachment->set_custom_data(customData); +#endif } virtual void SignalDeletedResource(const std::string& publicId, @@ -288,6 +291,9 @@ lookupAttachment_->mutable_attachment()->set_compression_type(compressionType); lookupAttachment_->mutable_attachment()->set_compressed_size(compressedSize); lookupAttachment_->mutable_attachment()->set_compressed_hash(compressedHash); +#if ORTHANC_PLUGINS_HAS_ATTACHMENTS_CUSTOM_DATA==1 + lookupAttachment_->mutable_attachment()->set_custom_data(customData); +#endif } else { @@ -684,6 +690,9 @@ case Orthanc::DatabasePluginMessages::OPERATION_ADD_ATTACHMENT: { +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) + backend.AddAttachment(response, manager, request.add_attachment()); +#else OrthancPluginAttachment attachment; attachment.uuid = request.add_attachment().attachment().uuid().c_str(); attachment.contentType = request.add_attachment().attachment().content_type(); @@ -694,9 +703,9 @@ attachment.compressedHash = request.add_attachment().attachment().compressed_hash().c_str(); backend.AddAttachment(manager, request.add_attachment().id(), attachment, request.add_attachment().revision()); +#endif break; } - case Orthanc::DatabasePluginMessages::OPERATION_CLEAR_CHANGES: { backend.ClearChanges(manager); diff -r b0533b703c2c -r 991b9b285e1a Framework/Plugins/IDatabaseBackend.h --- a/Framework/Plugins/IDatabaseBackend.h Tue Oct 01 16:02:48 2024 +0200 +++ b/Framework/Plugins/IDatabaseBackend.h Wed Oct 02 09:40:20 2024 +0200 @@ -66,13 +66,20 @@ const OrthancPluginAttachment& attachment, int64_t revision) = 0; -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) + // New in Orthanc 1.12.6 + virtual void AddAttachment(Orthanc::DatabasePluginMessages::TransactionResponse& response, + DatabaseManager& manager, + const Orthanc::DatabasePluginMessages::AddAttachment_Request& request) = 0; +#endif - virtual void AddAttachment2(DatabaseManager& manager, - int64_t id, - const OrthancPluginAttachment2& attachment, - int64_t revision) = 0; -#endif +// #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) + +// virtual void AddAttachment2(DatabaseManager& manager, +// int64_t id, +// const OrthancPluginAttachment2& attachment, +// int64_t revision) = 0; +// #endif virtual void AttachChild(DatabaseManager& manager, int64_t parent, @@ -406,5 +413,6 @@ DatabaseManager& manager, const Orthanc::DatabasePluginMessages::Find_Request& request) = 0; #endif + }; } diff -r b0533b703c2c -r 991b9b285e1a Framework/Plugins/IndexBackend.cpp --- a/Framework/Plugins/IndexBackend.cpp Tue Oct 01 16:02:48 2024 +0200 +++ b/Framework/Plugins/IndexBackend.cpp Wed Oct 02 09:40:20 2024 +0200 @@ -400,17 +400,38 @@ attachment.compressionType, attachment.compressedSize, attachment.compressedHash, "", revision); } -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) - void IndexBackend::AddAttachment2(DatabaseManager& manager, - int64_t id, - const OrthancPluginAttachment2& attachment, - int64_t revision) +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) + void IndexBackend::AddAttachment(Orthanc::DatabasePluginMessages::TransactionResponse& response, + DatabaseManager& manager, + const Orthanc::DatabasePluginMessages::AddAttachment_Request& request) { assert(HasRevisionsSupport() && HasAttachmentCustomDataSupport()); // all plugins supports these features now - ExecuteAddAttachment(manager, id, attachment.uuid, attachment.contentType, attachment.uncompressedSize, attachment.uncompressedHash, - attachment.compressionType, attachment.compressedSize, attachment.compressedHash, attachment.customData, revision); + ExecuteAddAttachment(manager, + request.id(), + request.attachment().uuid().c_str(), + request.attachment().content_type(), + request.attachment().uncompressed_size(), + request.attachment().uncompressed_hash().c_str(), + request.attachment().compression_type(), + request.attachment().compressed_size(), + request.attachment().compressed_hash().c_str(), + request.attachment().custom_data().c_str(), + request.revision()); } #endif + + +// #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) +// void IndexBackend::AddAttachment2(DatabaseManager& manager, +// int64_t id, +// const OrthancPluginAttachment2& attachment, +// int64_t revision) +// { +// assert(HasRevisionsSupport() && HasAttachmentCustomDataSupport()); // all plugins supports these features now +// ExecuteAddAttachment(manager, id, attachment.uuid, attachment.contentType, attachment.uncompressedSize, attachment.uncompressedHash, +// attachment.compressionType, attachment.compressedSize, attachment.compressedHash, attachment.customData, revision); +// } +// #endif void IndexBackend::AttachChild(DatabaseManager& manager, int64_t parent, diff -r b0533b703c2c -r 991b9b285e1a Framework/Plugins/IndexBackend.h --- a/Framework/Plugins/IndexBackend.h Tue Oct 01 16:02:48 2024 +0200 +++ b/Framework/Plugins/IndexBackend.h Wed Oct 02 09:40:20 2024 +0200 @@ -91,14 +91,21 @@ const OrthancPluginAttachment& attachment, int64_t revision) ORTHANC_OVERRIDE; -#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) +#if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) + // New in Orthanc 1.12.6 + virtual void AddAttachment(Orthanc::DatabasePluginMessages::TransactionResponse& response, + DatabaseManager& manager, + const Orthanc::DatabasePluginMessages::AddAttachment_Request& request) ORTHANC_OVERRIDE; +#endif - virtual void AddAttachment2(DatabaseManager& manager, - int64_t id, - const OrthancPluginAttachment2& attachment, - int64_t revision) ORTHANC_OVERRIDE; +// #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) -#endif +// virtual void AddAttachment2(DatabaseManager& manager, +// int64_t id, +// const OrthancPluginAttachment2& attachment, +// int64_t revision) ORTHANC_OVERRIDE; + +// #endif virtual void AttachChild(DatabaseManager& manager, int64_t parent, diff -r b0533b703c2c -r 991b9b285e1a Framework/Plugins/MessagesToolbox.h --- a/Framework/Plugins/MessagesToolbox.h Tue Oct 01 16:02:48 2024 +0200 +++ b/Framework/Plugins/MessagesToolbox.h Wed Oct 02 09:40:20 2024 +0200 @@ -59,6 +59,15 @@ #endif +#define ORTHANC_PLUGINS_HAS_ATTACHMENTS_CUSTOM_DATA 0 + +#if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) +# if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 6) +# undef ORTHANC_PLUGINS_HAS_ATTACHMENTS_CUSTOM_DATA +# define ORTHANC_PLUGINS_HAS_ATTACHMENTS_CUSTOM_DATA 1 +# endif +#endif + #include diff -r b0533b703c2c -r 991b9b285e1a PostgreSQL/NEWS --- a/PostgreSQL/NEWS Tue Oct 01 16:02:48 2024 +0200 +++ b/PostgreSQL/NEWS Wed Oct 02 09:40:20 2024 +0200 @@ -1,9 +1,14 @@ Pending changes in the mainline =============================== -DB schema revision: 2 +DB schema revision: 3 + Minimum plugin SDK (for build): 1.12.3 +Optimal plugin SDK: 1.12.6 + Minimum Orthanc runtime: 1.12.3 +Optimal Orthanc runtime: 1.12.6 + * Fix updates from plugin version 3.3 to latest version * Added support for ExtendedChanges: