annotate OrthancServer/Sources/Search/DatabaseConstraint.cpp @ 4880:81dfdcf16e16

merge
author Alain Mazy <am@osimis.io>
date Wed, 19 Jan 2022 17:06:22 +0100
parents 43e613a7756b
children 6eff25f70121
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * In addition, as a special exception, the copyright holders of this
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * program give permission to link the code of its release with the
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * that use the same license as the "OpenSSL" library), and distribute
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * the linked executables. You must obey the GNU General Public License
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * in all respects for all of the code used other than "OpenSSL". If you
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * modify file(s) with this exception, you may extend this exception to
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * your version of the file(s), but you are not obligated to do so. If
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * you do not wish to do so, delete this exception statement from your
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * version. If you delete this exception statement from all source files
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * in the program, then also delete it here.
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 *
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * This program is distributed in the hope that it will be useful, but
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * WITHOUT ANY WARRANTY; without even the implied warranty of
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * General Public License for more details.
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 *
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * You should have received a copy of the GNU General Public License
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 **/
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
4096
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
35 #if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
36 # error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
37 #endif
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
38
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
39 #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
40 # include "../PrecompiledHeadersServer.h"
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
41 #endif
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
42
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include "DatabaseConstraint.h"
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
4096
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
45 #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
46 # include "../../../OrthancFramework/Sources/OrthancException.h"
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
47 #else
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
48 # include <OrthancException.h>
d633e5bb7ba3 reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
49 #endif
3077
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
50
4304
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4096
diff changeset
51 #include <cassert>
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4096
diff changeset
52
50b0c69b653a continued abi
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4096
diff changeset
53
3077
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
54 namespace Orthanc
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
55 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
56 namespace Plugins
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
57 {
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
58 #if ORTHANC_ENABLE_PLUGINS == 1
3077
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
59 OrthancPluginResourceType Convert(ResourceType type)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
60 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
61 switch (type)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
62 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
63 case ResourceType_Patient:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
64 return OrthancPluginResourceType_Patient;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
65
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
66 case ResourceType_Study:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
67 return OrthancPluginResourceType_Study;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
68
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
69 case ResourceType_Series:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
70 return OrthancPluginResourceType_Series;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
71
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
72 case ResourceType_Instance:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
73 return OrthancPluginResourceType_Instance;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
74
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
75 default:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
76 throw OrthancException(ErrorCode_ParameterOutOfRange);
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
77 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
78 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
79 #endif
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
80
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
81
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
82 #if ORTHANC_ENABLE_PLUGINS == 1
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
83 ResourceType Convert(OrthancPluginResourceType type)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
84 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
85 switch (type)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
86 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
87 case OrthancPluginResourceType_Patient:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
88 return ResourceType_Patient;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
89
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
90 case OrthancPluginResourceType_Study:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
91 return ResourceType_Study;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
92
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
93 case OrthancPluginResourceType_Series:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
94 return ResourceType_Series;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
95
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
96 case OrthancPluginResourceType_Instance:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
97 return ResourceType_Instance;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
98
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
99 default:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
100 throw OrthancException(ErrorCode_ParameterOutOfRange);
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
101 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
102 }
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
103 #endif
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
104
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
105
3098
717efd0989f9 renamed macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3087
diff changeset
106 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
3077
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
107 OrthancPluginConstraintType Convert(ConstraintType constraint)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
108 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
109 switch (constraint)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
110 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
111 case ConstraintType_Equal:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
112 return OrthancPluginConstraintType_Equal;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
113
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
114 case ConstraintType_GreaterOrEqual:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
115 return OrthancPluginConstraintType_GreaterOrEqual;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
116
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
117 case ConstraintType_SmallerOrEqual:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
118 return OrthancPluginConstraintType_SmallerOrEqual;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
119
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
120 case ConstraintType_Wildcard:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
121 return OrthancPluginConstraintType_Wildcard;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
122
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
123 case ConstraintType_List:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
124 return OrthancPluginConstraintType_List;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
125
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
126 default:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
127 throw OrthancException(ErrorCode_ParameterOutOfRange);
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
128 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
129 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
130 #endif
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
131
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
132
3098
717efd0989f9 renamed macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3087
diff changeset
133 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
3077
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
134 ConstraintType Convert(OrthancPluginConstraintType constraint)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
135 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
136 switch (constraint)
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
137 {
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
138 case OrthancPluginConstraintType_Equal:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
139 return ConstraintType_Equal;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
140
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
141 case OrthancPluginConstraintType_GreaterOrEqual:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
142 return ConstraintType_GreaterOrEqual;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
143
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
144 case OrthancPluginConstraintType_SmallerOrEqual:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
145 return ConstraintType_SmallerOrEqual;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
146
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
147 case OrthancPluginConstraintType_Wildcard:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
148 return ConstraintType_Wildcard;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
149
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
150 case OrthancPluginConstraintType_List:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
151 return ConstraintType_List;
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
152
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
153 default:
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
154 throw OrthancException(ErrorCode_ParameterOutOfRange);
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
155 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
156 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
157 #endif
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
158 }
aae1d6d31fef compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
159
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
160 DatabaseConstraint::DatabaseConstraint(ResourceType level,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
161 const DicomTag& tag,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
162 bool isIdentifier,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
163 ConstraintType type,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
164 const std::vector<std::string>& values,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
165 bool caseSensitive,
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
166 bool mandatory) :
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 level_(level),
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
168 tag_(tag),
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
169 isIdentifier_(isIdentifier),
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
170 constraintType_(type),
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
171 values_(values),
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
172 caseSensitive_(caseSensitive),
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
173 mandatory_(mandatory)
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 {
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
175 if (type != ConstraintType_List &&
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
176 values_.size() != 1)
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 {
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
178 throw OrthancException(ErrorCode_ParameterOutOfRange);
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
179 }
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
180 }
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
3073
0e9d1731b1b0 refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3062
diff changeset
182
3098
717efd0989f9 renamed macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3087
diff changeset
183 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
184 DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
185 level_(Plugins::Convert(constraint.level)),
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
186 tag_(constraint.tagGroup, constraint.tagElement),
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
187 isIdentifier_(constraint.isIdentifierTag),
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
188 constraintType_(Plugins::Convert(constraint.type)),
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
189 caseSensitive_(constraint.isCaseSensitive),
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
190 mandatory_(constraint.isMandatory)
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
191 {
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
192 if (constraintType_ != ConstraintType_List &&
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
193 constraint.valuesCount != 1)
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
194 {
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
195 throw OrthancException(ErrorCode_ParameterOutOfRange);
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
196 }
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
197
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
198 values_.resize(constraint.valuesCount);
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
199
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
200 for (uint32_t i = 0; i < constraint.valuesCount; i++)
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
201 {
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
202 assert(constraint.values[i] != NULL);
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
203 values_[i].assign(constraint.values[i]);
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
204 }
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
205 }
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
206 #endif
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
207
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
208
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 const std::string& DatabaseConstraint::GetValue(size_t index) const
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 {
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 if (index >= values_.size())
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 throw OrthancException(ErrorCode_ParameterOutOfRange);
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 else
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 {
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 return values_[index];
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 }
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 }
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 const std::string& DatabaseConstraint::GetSingleValue() const
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 if (values_.size() != 1)
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 }
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 else
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 return values_[0];
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 }
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 }
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
233
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
234
3098
717efd0989f9 renamed macro
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3087
diff changeset
235 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
236 void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
237 std::vector<const char*>& tmpValues) const
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
238 {
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
239 memset(&constraint, 0, sizeof(constraint));
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
240
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
241 tmpValues.resize(values_.size());
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
242
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
243 for (size_t i = 0; i < values_.size(); i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
244 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
245 tmpValues[i] = values_[i].c_str();
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
246 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
247
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
248 constraint.level = Plugins::Convert(level_);
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
249 constraint.tagGroup = tag_.GetGroup();
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
250 constraint.tagElement = tag_.GetElement();
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
251 constraint.isIdentifierTag = isIdentifier_;
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
252 constraint.isCaseSensitive = caseSensitive_;
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
253 constraint.isMandatory = mandatory_;
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
254 constraint.type = Plugins::Convert(constraintType_);
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
255 constraint.valuesCount = values_.size();
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3077
diff changeset
256 constraint.values = (tmpValues.empty() ? NULL : &tmpValues[0]);
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
257 }
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3073
diff changeset
258 #endif
3029
ea653ec47f31 new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 }