comparison Framework/Plugins/ISqlLookupFormatter.h @ 547:b8e6e7a19424

un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Sep 2024 13:18:35 +0200
parents
children 25005693297b
comparison
equal deleted inserted replaced
542:a8f9d44e7842 547:b8e6e7a19424
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
8 *
9 * This program is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU Affero General Public License
11 * as published by the Free Software Foundation, either version 3 of
12 * the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Affero General Public License for more details.
18 *
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **/
22
23
24 /**
25 * NB: Until 2024-09-09, this file was synchronized with the following
26 * folder from the Orthanc main project:
27 * https://orthanc.uclouvain.be/hg/orthanc/file/default/OrthancServer/Sources/Search/
28 **/
29
30
31 #pragma once
32
33 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
34 # include "../../../OrthancFramework/Sources/Enumerations.h"
35 #else
36 # include <Enumerations.h>
37 #endif
38
39 #include <boost/noncopyable.hpp>
40 #include <vector>
41
42 namespace Orthanc
43 {
44 class DatabaseConstraints;
45
46 enum LabelsConstraint
47 {
48 LabelsConstraint_All,
49 LabelsConstraint_Any,
50 LabelsConstraint_None
51 };
52
53 // This class is also used by the "orthanc-databases" project
54 class ISqlLookupFormatter : public boost::noncopyable
55 {
56 public:
57 virtual ~ISqlLookupFormatter()
58 {
59 }
60
61 virtual std::string GenerateParameter(const std::string& value) = 0;
62
63 virtual std::string FormatResourceType(ResourceType level) = 0;
64
65 virtual std::string FormatWildcardEscape() = 0;
66
67 /**
68 * Whether to escape '[' and ']', which is only needed for
69 * MSSQL. New in Orthanc 1.10.0, from the following changeset:
70 * https://orthanc.uclouvain.be/hg/orthanc-databases/rev/389c037387ea
71 **/
72 virtual bool IsEscapeBrackets() const = 0;
73
74 static void GetLookupLevels(ResourceType& lowerLevel,
75 ResourceType& upperLevel,
76 const ResourceType& queryLevel,
77 const DatabaseConstraints& lookup);
78
79 static void Apply(std::string& sql,
80 ISqlLookupFormatter& formatter,
81 const DatabaseConstraints& lookup,
82 ResourceType queryLevel,
83 const std::set<std::string>& labels, // New in Orthanc 1.12.0
84 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0
85 size_t limit);
86
87 static void ApplySingleLevel(std::string& sql,
88 ISqlLookupFormatter& formatter,
89 const DatabaseConstraints& lookup,
90 ResourceType queryLevel,
91 const std::set<std::string>& labels, // New in Orthanc 1.12.0
92 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0
93 size_t limit);
94 };
95 }