Mercurial > hg > orthanc
changeset 5683:0c218d90096e
moved handling of labels out of DatabaseLookup
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Jul 2024 11:33:37 +0200 |
parents | 68fc5af30c03 |
children | 9b3816c21008 13b1ff603b37 |
files | OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp OrthancServer/Sources/Search/DatabaseLookup.cpp OrthancServer/Sources/Search/DatabaseLookup.h OrthancServer/Sources/ServerContext.cpp OrthancServer/Sources/ServerContext.h |
diffstat | 5 files changed, 22 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Jul 09 10:09:57 2024 +0200 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp Tue Jul 09 11:33:37 2024 +0200 @@ -3324,6 +3324,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++) @@ -3334,27 +3336,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 { @@ -3363,7 +3365,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 10:09:57 2024 +0200 +++ b/OrthancServer/Sources/Search/DatabaseLookup.cpp Tue Jul 09 11:33:37 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 10:09:57 2024 +0200 +++ b/OrthancServer/Sources/Search/DatabaseLookup.h Tue Jul 09 11:33:37 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 10:09:57 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.cpp Tue Jul 09 11:33:37 2024 +0200 @@ -1533,6 +1533,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) { @@ -1556,8 +1558,7 @@ { const size_t lookupLimit = (databaseLimit == 0 ? 0 : databaseLimit + 1); - 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 10:09:57 2024 +0200 +++ b/OrthancServer/Sources/ServerContext.h Tue Jul 09 11:33:37 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,