annotate OrthancServer/Sources/Search/ISqlLookupFormatter.h @ 5641:3f13db27b399 find-refactoring

integration mainline->find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 30 May 2024 21:27:48 +0200
parents 043c8016ed6a f7adfb22e20e
children 77875b51cf95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5432
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4096
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
26 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
27 # include "../../../OrthancFramework/Sources/Enumerations.h"
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
28 #else
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
29 # include <Enumerations.h>
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
30 #endif
3100
f6de9d25b20d removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
31
f6de9d25b20d removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
32 #include <boost/noncopyable.hpp>
f6de9d25b20d removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
33 #include <vector>
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 namespace Orthanc
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
3100
f6de9d25b20d removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
37 class DatabaseConstraint;
5591
043c8016ed6a removing standalone OrthancServer/Sources/Search/LabelsConstraint.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5568
diff changeset
38
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
39 enum LabelsConstraint
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
40 {
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
41 LabelsConstraint_All,
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
42 LabelsConstraint_Any,
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
43 LabelsConstraint_None
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
44 };
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
45
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 // This class is also used by the "orthanc-databases" project
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 class ISqlLookupFormatter : public boost::noncopyable
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 public:
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 virtual ~ISqlLookupFormatter()
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 virtual std::string GenerateParameter(const std::string& value) = 0;
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
56 virtual std::string FormatResourceType(ResourceType level) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
57
3079
65e2bfa953ef ISqlLookupFormatter::FormatWildcardEscape()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3078
diff changeset
58 virtual std::string FormatWildcardEscape() = 0;
65e2bfa953ef ISqlLookupFormatter::FormatWildcardEscape()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3078
diff changeset
59
4817
b8fcd331b4b3 added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
60 /**
b8fcd331b4b3 added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
61 * Whether to escape '[' and ']', which is only needed for
4902
df86d2505df8 Orthanc 1.9.8 is now known as Orthanc 1.10.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
62 * MSSQL. New in Orthanc 1.10.0, from the following changeset:
5432
59e3b6f8c5be migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5422
diff changeset
63 * https://orthanc.uclouvain.be/hg/orthanc-databases/rev/389c037387ea
4817
b8fcd331b4b3 added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
64 **/
b8fcd331b4b3 added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
65 virtual bool IsEscapeBrackets() const = 0;
b8fcd331b4b3 added ISqlLookupFormatter::IsEscapeBrackets()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
66
5422
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
67 static void GetLookupLevels(ResourceType& lowerLevel, ResourceType& upperLevel, const ResourceType& queryLevel, const std::vector<DatabaseConstraint>& lookup);
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
68
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 static void Apply(std::string& sql,
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 ISqlLookupFormatter& formatter,
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 const std::vector<DatabaseConstraint>& lookup,
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 ResourceType queryLevel,
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
73 const std::set<std::string>& labels, // New in Orthanc 1.12.0
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5227
diff changeset
74 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 size_t limit);
5422
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
76
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
77 static void ApplySingleLevel(std::string& sql,
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
78 ISqlLookupFormatter& formatter,
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
79 const std::vector<DatabaseConstraint>& lookup,
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
80 ResourceType queryLevel,
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
81 const std::set<std::string>& labels, // New in Orthanc 1.12.0
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
82 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0
7f37233359aa sync code from DB plugins
Alain Mazy <am@osimis.io>
parents: 5248
diff changeset
83 size_t limit);
3058
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 };
6faf575ba9cc refactoring: class ISqlLookupFormatter to be used in orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 }