Mercurial > hg > orthanc
changeset 5884:92e5579681f2 find-refactoring
refactored StatelessDatabaseOperations::ListLabels()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 29 Nov 2024 09:46:30 +0100 |
parents | 96f49b200c15 |
children | 207371ec031e |
files | .clang-format .hgignore OrthancServer/Sources/Database/Compatibility/GenericFind.cpp OrthancServer/Sources/Database/IDatabaseWrapper.h OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp OrthancServer/Sources/Database/StatelessDatabaseOperations.h |
diffstat | 6 files changed, 73 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.clang-format Fri Nov 29 09:46:30 2024 +0100 @@ -0,0 +1,57 @@ +--- +Language: Cpp +BasedOnStyle: LLVM +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignOperands: true +AlignTrailingComments: false +AlwaysBreakTemplateDeclarations: Yes +BraceWrapping: + AfterCaseLabel: true + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: true + BeforeElse: true + BeforeLambdaBody: true + BeforeWhile: true + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: AfterColon +BreakConstructorInitializersBeforeComma: false +ColumnLimit: 200 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ContinuationIndentWidth: 2 +IncludeCategories: + - Regex: '^<.*' + Priority: 1 + - Regex: '^".*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +InsertNewlineAtEOF: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: All +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: false +SpaceBeforeRangeBasedForLoopColon: false +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInConditionalStatement: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +TabWidth: 2 +...
--- a/.hgignore Fri Nov 29 09:30:50 2024 +0100 +++ b/.hgignore Fri Nov 29 09:46:30 2024 +0100 @@ -7,6 +7,7 @@ .vscode/ *~ *.cmake.orig +.idea/ # when opening Orthanc in VSCode, it might find a java project and create files we wan't to ignore: .settings/
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Fri Nov 29 09:30:50 2024 +0100 +++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp Fri Nov 29 09:46:30 2024 +0100 @@ -514,7 +514,7 @@ if (capabilities.HasLabelsSupport() && request.IsRetrieveLabels()) { - transaction_.ListLabels(resource->GetLabels(), internalId); + compatibilityTransaction_.ListLabels(resource->GetLabels(), internalId); } if (request.IsRetrieveAttachments())
--- a/OrthancServer/Sources/Database/IDatabaseWrapper.h Fri Nov 29 09:30:50 2024 +0100 +++ b/OrthancServer/Sources/Database/IDatabaseWrapper.h Fri Nov 29 09:46:30 2024 +0100 @@ -354,10 +354,6 @@ virtual void RemoveLabel(int64_t resource, const std::string& label) = 0; - // List the labels of one single resource - virtual void ListLabels(std::set<std::string>& target, - int64_t resource) = 0; - // List all the labels that are present in any resource virtual void ListAllLabels(std::set<std::string>& target) = 0; @@ -443,6 +439,14 @@ ResourceType& type, std::string& parentPublicId, const std::string& publicId) = 0; + + /** + * Primitives introduced in Orthanc 1.12.0 + **/ + + // List the labels of one single resource + virtual void ListLabels(std::set<std::string>& target, + int64_t resource) = 0; };
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Nov 29 09:30:50 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Fri Nov 29 09:46:30 2024 +0100 @@ -3196,28 +3196,12 @@ const std::string& publicId, ResourceType level) { - class Operations : public ReadOnlyOperationsT3<std::set<std::string>&, const std::string&, ResourceType> - { - public: - virtual void ApplyTuple(ReadOnlyTransaction& transaction, - const Tuple& tuple) ORTHANC_OVERRIDE - { - ResourceType type; - int64_t id; - if (!transaction.LookupResource(id, type, tuple.get<1>()) || - tuple.get<2>() != type) - { - throw OrthancException(ErrorCode_UnknownResource); - } - else - { - transaction.ListLabels(tuple.get<0>(), id); - } - } - }; - - Operations operations; - operations.Apply(*this, target, publicId, level); + FindRequest request(level); + request.SetOrthancId(level, publicId); + request.SetRetrieveLabels(true); + + FindResponse response; + target = ExecuteSingleResource(response, request).GetLabels(); }
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Fri Nov 29 09:30:50 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.h Fri Nov 29 09:46:30 2024 +0100 @@ -266,12 +266,6 @@ return transaction_.LookupResource(id, type, publicId); } - void ListLabels(std::set<std::string>& target, - int64_t id) - { - transaction_.ListLabels(target, id); - } - void ListAllLabels(std::set<std::string>& target) { transaction_.ListAllLabels(target);