Mercurial > hg > orthanc
annotate OrthancServer/Sources/Search/DatabaseConstraint.cpp @ 4310:2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Nov 2020 14:40:51 +0100 |
parents | 50b0c69b653a |
children | d9473bd5ed43 |
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 |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3098
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * 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
|
9 * published by the Free Software Foundation, either version 3 of the |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * License, or (at your option) any later version. |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * In addition, as a special exception, the copyright holders of this |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * 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
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * 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
|
18 * 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
|
19 * 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
|
20 * 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
|
21 * version. If you delete this exception statement from all source files |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * in the program, then also delete it here. |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * 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
|
25 * WITHOUT ANY WARRANTY; without even the implied warranty of |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * General Public License for more details. |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * 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
|
30 * 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
|
31 **/ |
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 |
4096
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
34 #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
|
35 # 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
|
36 #endif |
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
37 |
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
38 #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
|
39 # include "../PrecompiledHeadersServer.h" |
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
40 #endif |
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
41 |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 #include "DatabaseConstraint.h" |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
4096
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
44 #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
|
45 # 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
|
46 #else |
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
47 # include <OrthancException.h> |
d633e5bb7ba3
reusing of ISqlLookupFormatter and DatabaseConstraint in orthanc-databases project
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4045
diff
changeset
|
48 #endif |
3077
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
49 |
4304 | 50 #include <cassert> |
51 | |
52 | |
3077
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
53 namespace Orthanc |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
54 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
55 namespace Plugins |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
56 { |
3074
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
57 #if ORTHANC_ENABLE_PLUGINS == 1 |
3077
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
58 OrthancPluginResourceType Convert(ResourceType type) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
59 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
60 switch (type) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
61 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
62 case ResourceType_Patient: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
63 return OrthancPluginResourceType_Patient; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
64 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
65 case ResourceType_Study: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
66 return OrthancPluginResourceType_Study; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
67 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
68 case ResourceType_Series: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
69 return OrthancPluginResourceType_Series; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
70 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
71 case ResourceType_Instance: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
72 return OrthancPluginResourceType_Instance; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
73 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
74 default: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
75 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
76 } |
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 #endif |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
79 |
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 #if ORTHANC_ENABLE_PLUGINS == 1 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
82 ResourceType Convert(OrthancPluginResourceType type) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
83 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
84 switch (type) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
85 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
86 case OrthancPluginResourceType_Patient: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
87 return ResourceType_Patient; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
88 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
89 case OrthancPluginResourceType_Study: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
90 return ResourceType_Study; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
91 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
92 case OrthancPluginResourceType_Series: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
93 return ResourceType_Series; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
94 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
95 case OrthancPluginResourceType_Instance: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
96 return ResourceType_Instance; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
97 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
98 default: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
99 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
100 } |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
101 } |
3074
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
102 #endif |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
103 |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
104 |
3098 | 105 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
3077
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
106 OrthancPluginConstraintType Convert(ConstraintType constraint) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
107 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
108 switch (constraint) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
109 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
110 case ConstraintType_Equal: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
111 return OrthancPluginConstraintType_Equal; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
112 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
113 case ConstraintType_GreaterOrEqual: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
114 return OrthancPluginConstraintType_GreaterOrEqual; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
115 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
116 case ConstraintType_SmallerOrEqual: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
117 return OrthancPluginConstraintType_SmallerOrEqual; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
118 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
119 case ConstraintType_Wildcard: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
120 return OrthancPluginConstraintType_Wildcard; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
121 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
122 case ConstraintType_List: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
123 return OrthancPluginConstraintType_List; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
124 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
125 default: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
126 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
127 } |
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 #endif |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
130 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
131 |
3098 | 132 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
3077
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
133 ConstraintType Convert(OrthancPluginConstraintType constraint) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
134 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
135 switch (constraint) |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
136 { |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
137 case OrthancPluginConstraintType_Equal: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
138 return ConstraintType_Equal; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
139 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
140 case OrthancPluginConstraintType_GreaterOrEqual: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
141 return ConstraintType_GreaterOrEqual; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
142 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
143 case OrthancPluginConstraintType_SmallerOrEqual: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
144 return ConstraintType_SmallerOrEqual; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
145 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
146 case OrthancPluginConstraintType_Wildcard: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
147 return ConstraintType_Wildcard; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
148 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
149 case OrthancPluginConstraintType_List: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
150 return ConstraintType_List; |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
151 |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
152 default: |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
153 throw OrthancException(ErrorCode_ParameterOutOfRange); |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
154 } |
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 #endif |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
157 } |
aae1d6d31fef
compatibility with orthanc-databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
158 |
3073
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
159 DatabaseConstraint::DatabaseConstraint(ResourceType level, |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
160 const DicomTag& tag, |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
161 bool isIdentifier, |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
162 ConstraintType type, |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
163 const std::vector<std::string>& values, |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
164 bool caseSensitive, |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
165 bool mandatory) : |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 level_(level), |
3073
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
167 tag_(tag), |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
168 isIdentifier_(isIdentifier), |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
169 constraintType_(type), |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
170 values_(values), |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
171 caseSensitive_(caseSensitive), |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
172 mandatory_(mandatory) |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 { |
3073
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
174 if (type != ConstraintType_List && |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
175 values_.size() != 1) |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 { |
3073
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
177 throw OrthancException(ErrorCode_ParameterOutOfRange); |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
178 } |
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
179 } |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 |
3073
0e9d1731b1b0
refactoring to reuse DatabaseConstraint in separate projects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3062
diff
changeset
|
181 |
3098 | 182 #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
|
183 DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) : |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
184 level_(Plugins::Convert(constraint.level)), |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
185 tag_(constraint.tagGroup, constraint.tagElement), |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
186 isIdentifier_(constraint.isIdentifierTag), |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
187 constraintType_(Plugins::Convert(constraint.type)), |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
188 caseSensitive_(constraint.isCaseSensitive), |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
189 mandatory_(constraint.isMandatory) |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
190 { |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
191 if (constraintType_ != ConstraintType_List && |
3078 | 192 constraint.valuesCount != 1) |
3074
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
193 { |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
194 throw OrthancException(ErrorCode_ParameterOutOfRange); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
195 } |
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 values_.resize(constraint.valuesCount); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
198 |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
199 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
|
200 { |
3078 | 201 assert(constraint.values[i] != NULL); |
3074
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
202 values_[i].assign(constraint.values[i]); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
203 } |
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 #endif |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
206 |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
207 |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 const std::string& DatabaseConstraint::GetValue(size_t index) const |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 { |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 if (index >= values_.size()) |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
212 throw OrthancException(ErrorCode_ParameterOutOfRange); |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
213 } |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
214 else |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
215 { |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
216 return values_[index]; |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 } |
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 const std::string& DatabaseConstraint::GetSingleValue() const |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 { |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 if (values_.size() != 1) |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
224 { |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 } |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
227 else |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
228 { |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 return values_[0]; |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 } |
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 } |
3074
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
232 |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
233 |
3098 | 234 #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
|
235 void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint, |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
236 std::vector<const char*>& tmpValues) const |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
237 { |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
238 memset(&constraint, 0, sizeof(constraint)); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
239 |
3078 | 240 tmpValues.resize(values_.size()); |
241 | |
242 for (size_t i = 0; i < values_.size(); i++) | |
243 { | |
244 tmpValues[i] = values_[i].c_str(); | |
245 } | |
246 | |
3074
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
247 constraint.level = Plugins::Convert(level_); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
248 constraint.tagGroup = tag_.GetGroup(); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
249 constraint.tagElement = tag_.GetElement(); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
250 constraint.isIdentifierTag = isIdentifier_; |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
251 constraint.isCaseSensitive = caseSensitive_; |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
252 constraint.isMandatory = mandatory_; |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
253 constraint.type = Plugins::Convert(constraintType_); |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
254 constraint.valuesCount = values_.size(); |
3078 | 255 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
|
256 } |
495c5edce708
new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3073
diff
changeset
|
257 #endif |
3029
ea653ec47f31
new class: DatabaseConstraint
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
258 } |