Mercurial > hg > orthanc
changeset 5678:e47ac5e133b1
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Jul 2024 08:56:50 +0200 |
parents | f690568f0325 |
children | 527918e9c5d9 68fc5af30c03 |
files | OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.h |
diffstat | 2 files changed, 41 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- 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<DatabaseConstraint>& 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<DatabaseConstraint>& 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<DatabaseConstraint> 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);
--- 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<ITransactionContextFactory> factory_; unsigned int maxRetries_; - void NormalizeLookup(std::vector<DatabaseConstraint>& target, - const DatabaseLookup& source, - ResourceType level) const; - void ApplyInternal(IReadOnlyOperations* readOperations, IReadWriteOperations* writeOperations);