# HG changeset patch # User Sebastien Jodogne # Date 1546684771 -3600 # Node ID fb8ee0786b1e84e0a93a24adda21ddf7c5d07fce # Parent d498ece73562b1bac80a64320668c77c0b079d95 new extension for database plugin SDK: setResourcesContent diff -r d498ece73562 -r fb8ee0786b1e OrthancServer/IDatabaseWrapper.h --- a/OrthancServer/IDatabaseWrapper.h Fri Jan 04 17:48:34 2019 +0100 +++ b/OrthancServer/IDatabaseWrapper.h Sat Jan 05 11:39:31 2019 +0100 @@ -232,6 +232,10 @@ const std::string& series, const std::string& instance) = 0; + // It is guaranteed that the resources to be modified have no main + // DICOM tags, and no DICOM identifiers associated with + // them. However, some metadata might be already existing, and + // have to be overwritten. virtual void SetResourcesContent(const ResourcesContent& content) = 0; }; } diff -r d498ece73562 -r fb8ee0786b1e OrthancServer/ServerToolbox.cpp --- a/OrthancServer/ServerToolbox.cpp Fri Jan 04 17:48:34 2019 +0100 +++ b/OrthancServer/ServerToolbox.cpp Sat Jan 05 11:39:31 2019 +0100 @@ -100,10 +100,12 @@ void ResourcesContent::EncodeForPlugins( - std::vector& tags, + std::vector& identifierTags, + std::vector& mainDicomTags, std::vector& metadata) const { - tags.reserve(tags_.size()); + identifierTags.reserve(tags_.size()); + mainDicomTags.reserve(tags_.size()); metadata.reserve(metadata_.size()); for (std::list::const_iterator @@ -111,11 +113,18 @@ { OrthancPluginResourcesContentTags tmp; tmp.resource = it->resourceId_; - tmp.isIdentifier = it->isIdentifier_; tmp.group = it->tag_.GetGroup(); tmp.element = it->tag_.GetElement(); tmp.value = it->value_.c_str(); - tags.push_back(tmp); + + if (it->isIdentifier_) + { + identifierTags.push_back(tmp); + } + else + { + mainDicomTags.push_back(tmp); + } } for (std::list::const_iterator @@ -128,7 +137,7 @@ metadata.push_back(tmp); } - assert(tags.size() == tags_.size() && + assert(identifierTags.size() + mainDicomTags.size() == tags_.size() && metadata.size() == metadata_.size()); } diff -r d498ece73562 -r fb8ee0786b1e OrthancServer/ServerToolbox.h --- a/OrthancServer/ServerToolbox.h Fri Jan 04 17:48:34 2019 +0100 +++ b/OrthancServer/ServerToolbox.h Sat Jan 05 11:39:31 2019 +0100 @@ -127,8 +127,10 @@ // WARNING: The resulting C structure will contain pointers to the // current object. Don't delete or modify it! - void EncodeForPlugins(std::vector& tags, - std::vector& metadata) const; + void EncodeForPlugins( + std::vector& identifierTags, + std::vector& mainDicomTags, + std::vector& metadata) const; }; diff -r d498ece73562 -r fb8ee0786b1e Plugins/Engine/OrthancPluginDatabase.cpp --- a/Plugins/Engine/OrthancPluginDatabase.cpp Fri Jan 04 17:48:34 2019 +0100 +++ b/Plugins/Engine/OrthancPluginDatabase.cpp Sat Jan 05 11:39:31 2019 +0100 @@ -1281,4 +1281,29 @@ ForwardAnswers(result); } } + + + void OrthancPluginDatabase::SetResourcesContent(const Orthanc::ResourcesContent& content) + { + if (extensions_.setResourcesContent == NULL) + { + ISetResourcesContent::Apply(*this, content); + } + else + { + std::vector identifierTags; + std::vector mainDicomTags; + std::vector metadata; + content.EncodeForPlugins(identifierTags, mainDicomTags, metadata); + + CheckSuccess(extensions_.setResourcesContent( + payload_, + identifierTags.size(), + (identifierTags.empty() ? NULL : &identifierTags[0]), + mainDicomTags.size(), + (mainDicomTags.empty() ? NULL : &mainDicomTags[0]), + metadata.size(), + (metadata.empty() ? NULL : &metadata[0]))); + } + } } diff -r d498ece73562 -r fb8ee0786b1e Plugins/Engine/OrthancPluginDatabase.h --- a/Plugins/Engine/OrthancPluginDatabase.h Fri Jan 04 17:48:34 2019 +0100 +++ b/Plugins/Engine/OrthancPluginDatabase.h Sat Jan 05 11:39:31 2019 +0100 @@ -352,10 +352,7 @@ ORTHANC_OVERRIDE; virtual void SetResourcesContent(const Orthanc::ResourcesContent& content) - ORTHANC_OVERRIDE - { - ISetResourcesContent::Apply(*this, content); - } + ORTHANC_OVERRIDE; }; } diff -r d498ece73562 -r fb8ee0786b1e Plugins/Include/orthanc/OrthancCDatabasePlugin.h --- a/Plugins/Include/orthanc/OrthancCDatabasePlugin.h Fri Jan 04 17:48:34 2019 +0100 +++ b/Plugins/Include/orthanc/OrthancCDatabasePlugin.h Sat Jan 05 11:39:31 2019 +0100 @@ -158,7 +158,6 @@ typedef struct /* New in Orthanc 1.5.2 */ { int64_t resource; - uint8_t isIdentifier; uint16_t group; uint16_t element; const char* value; @@ -789,9 +788,11 @@ OrthancPluginErrorCode (*setResourcesContent) ( /* inputs */ void* payload, - uint32_t countTags, + uint32_t countIdentifierTags, + const OrthancPluginResourcesContentTags* identifierTags, + uint32_t countMainDicomTags, + const OrthancPluginResourcesContentTags* mainDicomTags, uint32_t countMetadata, - const OrthancPluginResourcesContentTags* tags, const OrthancPluginResourcesContentMetadata* metadata); } OrthancPluginDatabaseExtensions;