Mercurial > hg > orthanc-databases
annotate Framework/Plugins/DatabaseConstraint.cpp @ 551:1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Sep 2024 15:19:28 +0200 |
parents | e620f36b8e09 |
children | 7f45f23b10d0 |
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 #include "DatabaseConstraint.h" |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 |
548
25005693297b
removed unnecessary macro ORTHANC_BUILDING_SERVER_LIBRARY
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
547
diff
changeset
|
33 #include <OrthancException.h> |
547
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 #include <cassert> |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
38 namespace OrthancDatabases |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 namespace Plugins |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
42 OrthancPluginResourceType Convert(Orthanc::ResourceType type) |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 switch (type) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
46 case Orthanc::ResourceType_Patient: |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 return OrthancPluginResourceType_Patient; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
49 case Orthanc::ResourceType_Study: |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 return OrthancPluginResourceType_Study; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
52 case Orthanc::ResourceType_Series: |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 return OrthancPluginResourceType_Series; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
55 case Orthanc::ResourceType_Instance: |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
56 return OrthancPluginResourceType_Instance; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
57 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 default: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
59 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 } |
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 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
64 Orthanc::ResourceType Convert(OrthancPluginResourceType type) |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 switch (type) |
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 OrthancPluginResourceType_Patient: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
69 return Orthanc::ResourceType_Patient; |
547
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 case OrthancPluginResourceType_Study: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
72 return Orthanc::ResourceType_Study; |
547
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 case OrthancPluginResourceType_Series: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
75 return Orthanc::ResourceType_Series; |
547
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 case OrthancPluginResourceType_Instance: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
78 return Orthanc::ResourceType_Instance; |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 default: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
81 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
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 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 |
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 #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
|
87 OrthancPluginConstraintType Convert(ConstraintType constraint) |
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 switch (constraint) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 case ConstraintType_Equal: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 return OrthancPluginConstraintType_Equal; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 case ConstraintType_GreaterOrEqual: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 return OrthancPluginConstraintType_GreaterOrEqual; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 case ConstraintType_SmallerOrEqual: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 return OrthancPluginConstraintType_SmallerOrEqual; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 case ConstraintType_Wildcard: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 return OrthancPluginConstraintType_Wildcard; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 case ConstraintType_List: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 return OrthancPluginConstraintType_List; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 default: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
107 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 } |
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 #endif |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 |
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 #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
|
114 ConstraintType Convert(OrthancPluginConstraintType constraint) |
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 switch (constraint) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 case OrthancPluginConstraintType_Equal: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 return ConstraintType_Equal; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 case OrthancPluginConstraintType_GreaterOrEqual: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 return ConstraintType_GreaterOrEqual; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 case OrthancPluginConstraintType_SmallerOrEqual: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 return ConstraintType_SmallerOrEqual; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 case OrthancPluginConstraintType_Wildcard: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 return ConstraintType_Wildcard; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 case OrthancPluginConstraintType_List: |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 return ConstraintType_List; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 default: |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
134 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 } |
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 #endif |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
140 DatabaseConstraint::DatabaseConstraint(Orthanc::ResourceType level, |
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
141 const Orthanc::DicomTag& tag, |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 bool isIdentifier, |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 ConstraintType type, |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 const std::vector<std::string>& values, |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 bool caseSensitive, |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 bool mandatory) : |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 level_(level), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 tag_(tag), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 isIdentifier_(isIdentifier), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 constraintType_(type), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
151 values_(values), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 caseSensitive_(caseSensitive), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 mandatory_(mandatory) |
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 if (type != ConstraintType_List && |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 values_.size() != 1) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
158 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 #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
|
164 DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) : |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 level_(Plugins::Convert(constraint.level)), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 tag_(constraint.tagGroup, constraint.tagElement), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 isIdentifier_(constraint.isIdentifierTag), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 constraintType_(Plugins::Convert(constraint.type)), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 caseSensitive_(constraint.isCaseSensitive), |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 mandatory_(constraint.isMandatory) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 if (constraintType_ != ConstraintType_List && |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 constraint.valuesCount != 1) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
175 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
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 values_.resize(constraint.valuesCount); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 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
|
181 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 assert(constraint.values[i] != NULL); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 values_[i].assign(constraint.values[i]); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 #endif |
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 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 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
|
190 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 if (index >= values_.size()) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
193 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
195 else |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
197 return values_[index]; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 } |
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 const std::string& DatabaseConstraint::GetSingleValue() const |
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 if (values_.size() != 1) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
205 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
206 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
207 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 else |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 return values_[0]; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 } |
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 |
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 #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
|
216 void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint, |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
217 std::vector<const char*>& tmpValues) const |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
218 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
219 memset(&constraint, 0, sizeof(constraint)); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
220 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 tmpValues.resize(values_.size()); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
222 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
223 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
|
224 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
225 tmpValues[i] = values_[i].c_str(); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
226 } |
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 constraint.level = Plugins::Convert(level_); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
229 constraint.tagGroup = tag_.GetGroup(); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
230 constraint.tagElement = tag_.GetElement(); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
231 constraint.isIdentifierTag = isIdentifier_; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
232 constraint.isCaseSensitive = caseSensitive_; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 constraint.isMandatory = mandatory_; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 constraint.type = Plugins::Convert(constraintType_); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 constraint.valuesCount = values_.size(); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 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
|
237 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 #endif |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
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 void DatabaseConstraints::Clear() |
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 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
|
244 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
245 assert(constraints_[i] != NULL); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
246 delete constraints_[i]; |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
247 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
248 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
249 constraints_.clear(); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
250 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
251 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
253 void DatabaseConstraints::AddConstraint(DatabaseConstraint* constraint) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
255 if (constraint == NULL) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
256 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
257 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer); |
547
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 else |
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 constraints_.push_back(constraint); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 } |
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 |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 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
|
267 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 if (index >= constraints_.size()) |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 { |
551
1a23f1ce3b98
move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
549
diff
changeset
|
270 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
547
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 else |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 { |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 assert(constraints_[index] != NULL); |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 return *constraints_[index]; |
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 } |
b8e6e7a19424
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 } |