Mercurial > hg > orthanc
changeset 5684:9b3816c21008 find-refactoring
integration mainline->find-refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Jul 2024 11:39:07 +0200 |
parents | fd4c5e064cbe (current diff) 0c218d90096e (diff) |
children | f0f7d15d195e |
files | OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h |
diffstat | 5 files changed, 24 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Jul 09 11:17:34 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Jul 09 11:39:07 2024 +0200 @@ -3502,6 +3502,8 @@ } } + std::set<std::string> labels; + if (request.isMember(KEY_LABELS)) // New in Orthanc 1.12.0 { for (Json::Value::ArrayIndex i = 0; i < request[KEY_LABELS].size(); i++) @@ -3512,27 +3514,27 @@ } else { - query.AddLabel(request[KEY_LABELS][i].asString()); + labels.insert(request[KEY_LABELS][i].asString()); } } } - query.SetLabelsConstraint(LabelsConstraint_All); + LabelsConstraint labelsConstraint = LabelsConstraint_All; if (request.isMember(KEY_LABELS_CONSTRAINT)) { const std::string& s = request[KEY_LABELS_CONSTRAINT].asString(); if (s == "All") { - query.SetLabelsConstraint(LabelsConstraint_All); + labelsConstraint = LabelsConstraint_All; } else if (s == "Any") { - query.SetLabelsConstraint(LabelsConstraint_Any); + labelsConstraint = LabelsConstraint_Any; } else if (s == "None") { - query.SetLabelsConstraint(LabelsConstraint_None); + labelsConstraint = LabelsConstraint_None; } else { @@ -3541,7 +3543,7 @@ } FindVisitor visitor(OrthancRestApi::GetDicomFormat(request, DicomToJsonFormat_Human), context.GetFindStorageAccessMode()); - context.Apply(visitor, query, level, since, limit); + context.Apply(visitor, query, level, labels, labelsConstraint, since, limit); visitor.Answer(call.GetOutput(), context, level, expand, requestedTags); } }
--- a/OrthancServer/Sources/Search/DatabaseLookup.cpp Tue Jul 09 11:17:34 2024 +0200 +++ b/OrthancServer/Sources/Search/DatabaseLookup.cpp Tue Jul 09 11:39:07 2024 +0200 @@ -369,14 +369,4 @@ return clone.release(); } - - - void DatabaseLookup::AddLabel(const std::string& label) - { - if (!label.empty()) - { - ServerToolbox::CheckValidLabel(label); - labels_.insert(label); - } - } }
--- a/OrthancServer/Sources/Search/DatabaseLookup.h Tue Jul 09 11:17:34 2024 +0200 +++ b/OrthancServer/Sources/Search/DatabaseLookup.h Tue Jul 09 11:39:07 2024 +0200 @@ -23,7 +23,6 @@ #pragma once -#include "../Search/ISqlLookupFormatter.h" #include "DicomTagConstraint.h" class DcmItem; @@ -34,8 +33,6 @@ { private: std::vector<DicomTagConstraint*> constraints_; - std::set<std::string> labels_; - LabelsConstraint labelsConstraint_; void AddDicomConstraintInternal(const DicomTag& tag, ValueRepresentation vr, @@ -46,11 +43,6 @@ void AddConstraintInternal(DicomTagConstraint* constraint); // Takes ownership public: - DatabaseLookup() : - labelsConstraint_(LabelsConstraint_All) - { - } - ~DatabaseLookup(); DatabaseLookup* Clone() const; @@ -97,22 +89,5 @@ bool HasTag(const DicomTag& tag) const; void RemoveConstraint(const DicomTag& tag); - - void AddLabel(const std::string& label); - - void SetLabelsConstraint(LabelsConstraint constraint) - { - labelsConstraint_ = constraint; - } - - const std::set<std::string>& GetLabels() const - { - return labels_; - } - - LabelsConstraint GetLabelsConstraint() const - { - return labelsConstraint_; - } }; }
--- a/OrthancServer/Sources/ServerContext.cpp Tue Jul 09 11:17:34 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Tue Jul 09 11:39:07 2024 +0200 @@ -1534,6 +1534,8 @@ void ServerContext::Apply(ILookupVisitor& visitor, const DatabaseLookup& lookup, ResourceType queryLevel, + const std::set<std::string>& labels, + LabelsConstraint labelsConstraint, size_t since, size_t limit) { @@ -1566,8 +1568,8 @@ ResourceFinder finder(queryLevel, false /* TODO-FIND: don't expand for now */); finder.SetLimits(0, lookupLimit); finder.SetDatabaseLookup(*fastLookup); - finder.SetLabels(lookup.GetLabels()); - finder.SetLabelsConstraint(lookup.GetLabelsConstraint()); + finder.SetLabels(labels); + finder.SetLabelsConstraint(labelsConstraint); if (queryLevel != ResourceType_Instance) { @@ -1601,8 +1603,7 @@ * VERSION IN ORTHANC <= 1.12.4 **/ - GetIndex().ApplyLookupResources(resources, &instances, *fastLookup, queryLevel, - lookup.GetLabels(), lookup.GetLabelsConstraint(), lookupLimit); + GetIndex().ApplyLookupResources(resources, &instances, *fastLookup, queryLevel, labels, labelsConstraint, lookupLimit); } bool complete = (databaseLimit == 0 ||
--- a/OrthancServer/Sources/ServerContext.h Tue Jul 09 11:17:34 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.h Tue Jul 09 11:39:07 2024 +0200 @@ -445,9 +445,20 @@ void Apply(ILookupVisitor& visitor, const DatabaseLookup& lookup, ResourceType queryLevel, + const std::set<std::string>& labels, + LabelsConstraint labelsConstraint, size_t since, size_t limit); + void Apply(ILookupVisitor& visitor, + const DatabaseLookup& lookup, + ResourceType queryLevel, + size_t since, + size_t limit) + { + Apply(visitor, lookup, queryLevel, std::set<std::string>(), LabelsConstraint_All, since, limit); + } + bool LookupOrReconstructMetadata(std::string& target, const std::string& publicId, ResourceType level,