# HG changeset patch # User Sebastien Jodogne # Date 1732869990 -3600 # Node ID 92e5579681f20d66e463a67b84da4eacfa0c38b2 # Parent 96f49b200c15849ca3b5c63e866380fc7b3f5c4f refactored StatelessDatabaseOperations::ListLabels() diff -r 96f49b200c15 -r 92e5579681f2 .clang-format --- /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 +... diff -r 96f49b200c15 -r 92e5579681f2 .hgignore --- 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/ diff -r 96f49b200c15 -r 92e5579681f2 OrthancServer/Sources/Database/Compatibility/GenericFind.cpp --- 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()) diff -r 96f49b200c15 -r 92e5579681f2 OrthancServer/Sources/Database/IDatabaseWrapper.h --- 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& target, - int64_t resource) = 0; - // List all the labels that are present in any resource virtual void ListAllLabels(std::set& 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& target, + int64_t resource) = 0; }; diff -r 96f49b200c15 -r 92e5579681f2 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- 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&, 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(); } diff -r 96f49b200c15 -r 92e5579681f2 OrthancServer/Sources/Database/StatelessDatabaseOperations.h --- 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& target, - int64_t id) - { - transaction_.ListLabels(target, id); - } - void ListAllLabels(std::set& target) { transaction_.ListAllLabels(target);