annotate Framework/Plugins/DatabaseConstraint.cpp @ 547:b8e6e7a19424

un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Sep 2024 13:18:35 +0200
parents
children 25005693297b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU Affero General Public License
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * as published by the Free Software Foundation, either version 3 of
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * the License, or (at your option) any later version.
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * Affero General Public License for more details.
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU Affero General Public License
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 /**
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * NB: Until 2024-09-09, this file was synchronized with the following
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * folder from the Orthanc main project:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * https://orthanc.uclouvain.be/hg/orthanc/file/default/OrthancServer/Sources/Search/
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 **/
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #if !defined(ORTHANC_BUILDING_SERVER_LIBRARY)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 # error Macro ORTHANC_BUILDING_SERVER_LIBRARY must be defined
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 # include "../PrecompiledHeadersServer.h"
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #include "DatabaseConstraint.h"
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #if ORTHANC_BUILDING_SERVER_LIBRARY == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 # include "../../../OrthancFramework/Sources/OrthancException.h"
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 # include <OrthancException.h>
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 #include <cassert>
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 namespace Orthanc
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 namespace Plugins
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 #if ORTHANC_ENABLE_PLUGINS == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 OrthancPluginResourceType Convert(ResourceType type)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 switch (type)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 case ResourceType_Patient:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 return OrthancPluginResourceType_Patient;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 case ResourceType_Study:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 return OrthancPluginResourceType_Study;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 case ResourceType_Series:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 return OrthancPluginResourceType_Series;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 case ResourceType_Instance:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 return OrthancPluginResourceType_Instance;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 default:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 #if ORTHANC_ENABLE_PLUGINS == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 ResourceType Convert(OrthancPluginResourceType type)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 switch (type)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 case OrthancPluginResourceType_Patient:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 return ResourceType_Patient;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 case OrthancPluginResourceType_Study:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 return ResourceType_Study;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 case OrthancPluginResourceType_Series:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 return ResourceType_Series;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 case OrthancPluginResourceType_Instance:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return ResourceType_Instance;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 default:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 OrthancPluginConstraintType Convert(ConstraintType constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 switch (constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 case ConstraintType_Equal:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 return OrthancPluginConstraintType_Equal;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 case ConstraintType_GreaterOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 return OrthancPluginConstraintType_GreaterOrEqual;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 case ConstraintType_SmallerOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 return OrthancPluginConstraintType_SmallerOrEqual;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 case ConstraintType_Wildcard:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 return OrthancPluginConstraintType_Wildcard;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 case ConstraintType_List:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 return OrthancPluginConstraintType_List;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 default:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 ConstraintType Convert(OrthancPluginConstraintType constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 switch (constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 case OrthancPluginConstraintType_Equal:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 return ConstraintType_Equal;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 case OrthancPluginConstraintType_GreaterOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 return ConstraintType_GreaterOrEqual;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 case OrthancPluginConstraintType_SmallerOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 return ConstraintType_SmallerOrEqual;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 case OrthancPluginConstraintType_Wildcard:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 return ConstraintType_Wildcard;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 case OrthancPluginConstraintType_List:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 return ConstraintType_List;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 default:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 DatabaseConstraint::DatabaseConstraint(ResourceType level,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 const DicomTag& tag,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 bool isIdentifier,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 ConstraintType type,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 const std::vector<std::string>& values,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 bool caseSensitive,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 bool mandatory) :
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 level_(level),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 tag_(tag),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 isIdentifier_(isIdentifier),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 constraintType_(type),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 values_(values),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 caseSensitive_(caseSensitive),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 mandatory_(mandatory)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 if (type != ConstraintType_List &&
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 values_.size() != 1)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 level_(Plugins::Convert(constraint.level)),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 tag_(constraint.tagGroup, constraint.tagElement),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 isIdentifier_(constraint.isIdentifierTag),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 constraintType_(Plugins::Convert(constraint.type)),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 caseSensitive_(constraint.isCaseSensitive),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 mandatory_(constraint.isMandatory)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 if (constraintType_ != ConstraintType_List &&
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 constraint.valuesCount != 1)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 values_.resize(constraint.valuesCount);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 for (uint32_t i = 0; i < constraint.valuesCount; i++)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 assert(constraint.values[i] != NULL);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 values_[i].assign(constraint.values[i]);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 const std::string& DatabaseConstraint::GetValue(size_t index) const
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 if (index >= values_.size())
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 return values_[index];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 const std::string& DatabaseConstraint::GetSingleValue() const
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 if (values_.size() != 1)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 return values_[0];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 std::vector<const char*>& tmpValues) const
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 memset(&constraint, 0, sizeof(constraint));
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 tmpValues.resize(values_.size());
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 for (size_t i = 0; i < values_.size(); i++)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 tmpValues[i] = values_[i].c_str();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 constraint.level = Plugins::Convert(level_);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 constraint.tagGroup = tag_.GetGroup();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 constraint.tagElement = tag_.GetElement();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 constraint.isIdentifierTag = isIdentifier_;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 constraint.isCaseSensitive = caseSensitive_;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 constraint.isMandatory = mandatory_;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 constraint.type = Plugins::Convert(constraintType_);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 constraint.valuesCount = values_.size();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 constraint.values = (tmpValues.empty() ? NULL : &tmpValues[0]);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 void DatabaseConstraints::Clear()
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 for (size_t i = 0; i < constraints_.size(); i++)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 assert(constraints_[i] != NULL);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 delete constraints_[i];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265 constraints_.clear();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 void DatabaseConstraints::AddConstraint(DatabaseConstraint* constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 if (constraint == NULL)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 throw OrthancException(ErrorCode_NullPointer);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 constraints_.push_back(constraint);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 const DatabaseConstraint& DatabaseConstraints::GetConstraint(size_t index) const
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 if (index >= constraints_.size())
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 throw OrthancException(ErrorCode_ParameterOutOfRange);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 assert(constraints_[index] != NULL);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 return *constraints_[index];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 }