annotate Resources/Orthanc/Databases/ISqlLookupFormatter.h @ 456:0ac99983abfa pg-transactions

missing drop function
author Alain Mazy <am@osimis.io>
date Tue, 23 Jan 2024 16:50:55 +0100
parents d700c8f9fc24
children ecd0b719cff5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * General Public License for more details.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 # include "../../../OrthancFramework/Sources/Enumerations.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # include <Enumerations.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #endif
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <boost/noncopyable.hpp>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <vector>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 namespace Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 class DatabaseConstraint;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
38 enum LabelsConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
39 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
40 LabelsConstraint_All,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
41 LabelsConstraint_Any,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
42 LabelsConstraint_None
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
43 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
44
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 // This class is also used by the "orthanc-databases" project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 class ISqlLookupFormatter : public boost::noncopyable
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 public:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 virtual ~ISqlLookupFormatter()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 virtual std::string GenerateParameter(const std::string& value) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 virtual std::string FormatResourceType(ResourceType level) = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 virtual std::string FormatWildcardEscape() = 0;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
354
2a3bbb4104fa fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
59 /**
2a3bbb4104fa fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
60 * Whether to escape '[' and ']', which is only needed for
405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
61 * 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
62 * https://orthanc.uclouvain.be/hg/orthanc-databases/rev/389c037387ea
354
2a3bbb4104fa fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
63 **/
2a3bbb4104fa fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
64 virtual bool IsEscapeBrackets() const = 0;
2a3bbb4104fa fix changeset 389c037387ea
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 285
diff changeset
65
415
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
66 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
67
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 static void Apply(std::string& sql,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 ISqlLookupFormatter& formatter,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 const std::vector<DatabaseConstraint>& lookup,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 ResourceType queryLevel,
405
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
72 const std::set<std::string>& labels, // New in Orthanc 1.12.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
73 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 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
75
415
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
76 static void ApplySingleLevel(std::string& sql,
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
77 ISqlLookupFormatter& formatter,
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
78 const std::vector<DatabaseConstraint>& lookup,
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
79 ResourceType queryLevel,
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
80 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
81 LabelsConstraint labelsConstraint, // New in Orthanc 1.12.0
7e123f047771 LookupResources optimization continued
Alain Mazy <am@osimis.io>
parents: 414
diff changeset
82 size_t limit);
152
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 };
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }