Mercurial > hg > orthanc-databases
annotate Resources/Orthanc/Databases/ISqlLookupFormatter.h @ 524:48aba35fe64e large-queries
merged BEGIN and SET TRANSACTION statements
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 09 Jul 2024 16:30:52 +0200 |
parents | 54d518dcd74a |
children | 4ecf50a4521c aff02ad9fbbc |
rev | line source |
---|---|
152 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
507
54d518dcd74a
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
54d518dcd74a
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
459
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
459
ecd0b719cff5
update year to 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
426
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
152 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * 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 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #pragma once | |
25 | |
26 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1 | |
27 # include "../../../OrthancFramework/Sources/Enumerations.h" | |
28 #else | |
29 # include <Enumerations.h> | |
30 #endif | |
31 | |
32 #include <boost/noncopyable.hpp> | |
33 #include <vector> | |
34 | |
35 namespace Orthanc | |
36 { | |
37 class DatabaseConstraint; | |
38 | |
405 | 39 enum LabelsConstraint |
40 { | |
41 LabelsConstraint_All, | |
42 LabelsConstraint_Any, | |
43 LabelsConstraint_None | |
44 }; | |
45 | |
152 | 46 // This class is also used by the "orthanc-databases" project |
47 class ISqlLookupFormatter : public boost::noncopyable | |
48 { | |
49 public: | |
50 virtual ~ISqlLookupFormatter() | |
51 { | |
52 } | |
53 | |
54 virtual std::string GenerateParameter(const std::string& value) = 0; | |
55 | |
56 virtual std::string FormatResourceType(ResourceType level) = 0; | |
57 | |
58 virtual std::string FormatWildcardEscape() = 0; | |
59 | |
354
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
60 /** |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
61 * Whether to escape '[' and ']', which is only needed for |
405 | 62 * MSSQL. New in Orthanc 1.10.0, from the following changeset: |
426
d700c8f9fc24
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
415
diff
changeset
|
63 * https://orthanc.uclouvain.be/hg/orthanc-databases/rev/389c037387ea |
354
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
64 **/ |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
65 virtual bool IsEscapeBrackets() const = 0; |
2a3bbb4104fa
fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
285
diff
changeset
|
66 |
415
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
67 static void GetLookupLevels(ResourceType& lowerLevel, ResourceType& upperLevel, const ResourceType& queryLevel, const std::vector<DatabaseConstraint>& lookup); |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
68 |
152 | 69 static void Apply(std::string& sql, |
70 ISqlLookupFormatter& formatter, | |
71 const std::vector<DatabaseConstraint>& lookup, | |
72 ResourceType queryLevel, | |
405 | 73 const std::set<std::string>& labels, // New in Orthanc 1.12.0 |
74 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 | |
152 | 75 size_t limit); |
414
f2d3b5c5a68d
Optimizing tools/find at studies level only. Integ Tests are ok with PG
Alain Mazy <am@osimis.io>
parents:
406
diff
changeset
|
76 |
415
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
77 static void ApplySingleLevel(std::string& sql, |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
78 ISqlLookupFormatter& formatter, |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
79 const std::vector<DatabaseConstraint>& lookup, |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
80 ResourceType queryLevel, |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
81 const std::set<std::string>& labels, // New in Orthanc 1.12.0 |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
82 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0 |
7e123f047771
LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents:
414
diff
changeset
|
83 size_t limit); |
152 | 84 }; |
85 } |