# HG changeset patch # User Sebastien Jodogne # Date 1720508210 -7200 # Node ID e47ac5e133b1d67db275e5458c2482e2c94c17e1 # Parent f690568f03255630f39d6b7b84594ec398fa4547 refactoring diff -r f690568f0325 -r e47ac5e133b1 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Jul 05 19:18:23 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Jul 09 08:56:50 2024 +0200 @@ -377,15 +377,6 @@ } } - public: - MainDicomTagsRegistry() - { - LoadTags(ResourceType_Patient); - LoadTags(ResourceType_Study); - LoadTags(ResourceType_Series); - LoadTags(ResourceType_Instance); - } - void LookupTag(ResourceType& level, DicomTagType& type, const DicomTag& tag) const @@ -404,6 +395,44 @@ type = it->second.GetType(); } } + + public: + MainDicomTagsRegistry() + { + LoadTags(ResourceType_Patient); + LoadTags(ResourceType_Study); + LoadTags(ResourceType_Series); + LoadTags(ResourceType_Instance); + } + + void NormalizeLookup(std::vector& target, + const DatabaseLookup& source, + ResourceType queryLevel) const + { + target.clear(); + target.reserve(source.GetConstraintsCount()); + + for (size_t i = 0; i < source.GetConstraintsCount(); i++) + { + ResourceType level; + DicomTagType type; + + LookupTag(level, type, source.GetConstraint(i).GetTag()); + + if (type == DicomTagType_Identifier || + type == DicomTagType_Main) + { + // Use the fact that patient-level tags are copied at the study level + if (level == ResourceType_Patient && + queryLevel != ResourceType_Patient) + { + level = ResourceType_Study; + } + + target.push_back(source.GetConstraint(i).ConvertToDatabaseConstraint(level, type)); + } + } + } }; @@ -471,38 +500,6 @@ } - void StatelessDatabaseOperations::NormalizeLookup(std::vector& target, - const DatabaseLookup& source, - ResourceType queryLevel) const - { - assert(mainDicomTagsRegistry_.get() != NULL); - - target.clear(); - target.reserve(source.GetConstraintsCount()); - - for (size_t i = 0; i < source.GetConstraintsCount(); i++) - { - ResourceType level; - DicomTagType type; - - mainDicomTagsRegistry_->LookupTag(level, type, source.GetConstraint(i).GetTag()); - - if (type == DicomTagType_Identifier || - type == DicomTagType_Main) - { - // Use the fact that patient-level tags are copied at the study level - if (level == ResourceType_Patient && - queryLevel != ResourceType_Patient) - { - level = ResourceType_Study; - } - - target.push_back(source.GetConstraint(i).ConvertToDatabaseConstraint(level, type)); - } - } - } - - class StatelessDatabaseOperations::Transaction : public boost::noncopyable { private: @@ -2036,7 +2033,9 @@ } std::vector normalized; - NormalizeLookup(normalized, lookup, queryLevel); + + assert(mainDicomTagsRegistry_.get() != NULL); + mainDicomTagsRegistry_->NormalizeLookup(normalized, lookup, queryLevel); Operations operations; operations.Apply(*this, (instancesId != NULL), normalized, queryLevel, labels, labelsConstraint, limit); diff -r f690568f0325 -r e47ac5e133b1 OrthancServer/Sources/Database/StatelessDatabaseOperations.h --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Fri Jul 05 19:18:23 2024 +0200 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Tue Jul 09 08:56:50 2024 +0200 @@ -556,10 +556,6 @@ std::unique_ptr factory_; unsigned int maxRetries_; - void NormalizeLookup(std::vector& target, - const DatabaseLookup& source, - ResourceType level) const; - void ApplyInternal(IReadOnlyOperations* readOperations, IReadWriteOperations* writeOperations);