annotate Framework/Plugins/DatabaseConstraint.cpp @ 553:7f45f23b10d0 find-refactoring

integration mainline->find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Sep 2024 15:27:52 +0200
parents 9ed9a91bde33 1a23f1ce3b98
children 1a74fc1bea2d
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 #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
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
35 #include <boost/lexical_cast.hpp>
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include <cassert>
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
39 namespace OrthancDatabases
547
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 namespace Plugins
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
43 OrthancPluginResourceType Convert(Orthanc::ResourceType type)
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 switch (type)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
47 case Orthanc::ResourceType_Patient:
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 return OrthancPluginResourceType_Patient;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
50 case Orthanc::ResourceType_Study:
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 return OrthancPluginResourceType_Study;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
53 case Orthanc::ResourceType_Series:
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 return OrthancPluginResourceType_Series;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
56 case Orthanc::ResourceType_Instance:
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 return OrthancPluginResourceType_Instance;
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 default:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
60 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
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
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
65 Orthanc::ResourceType Convert(OrthancPluginResourceType type)
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 switch (type)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 case OrthancPluginResourceType_Patient:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
70 return Orthanc::ResourceType_Patient;
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 case OrthancPluginResourceType_Study:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
73 return Orthanc::ResourceType_Study;
547
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 case OrthancPluginResourceType_Series:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
76 return Orthanc::ResourceType_Series;
547
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 case OrthancPluginResourceType_Instance:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
79 return Orthanc::ResourceType_Instance;
547
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 default:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
82 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
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
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 #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
88 OrthancPluginConstraintType Convert(ConstraintType constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 switch (constraint)
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 ConstraintType_Equal:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 return OrthancPluginConstraintType_Equal;
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 case ConstraintType_GreaterOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 return OrthancPluginConstraintType_GreaterOrEqual;
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 case ConstraintType_SmallerOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 return OrthancPluginConstraintType_SmallerOrEqual;
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 case ConstraintType_Wildcard:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 return OrthancPluginConstraintType_Wildcard;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 case ConstraintType_List:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 return OrthancPluginConstraintType_List;
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 default:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
108 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
109 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 #endif
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
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 #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
115 ConstraintType Convert(OrthancPluginConstraintType constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 switch (constraint)
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 OrthancPluginConstraintType_Equal:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 return ConstraintType_Equal;
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 case OrthancPluginConstraintType_GreaterOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 return ConstraintType_GreaterOrEqual;
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 case OrthancPluginConstraintType_SmallerOrEqual:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 return ConstraintType_SmallerOrEqual;
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 case OrthancPluginConstraintType_Wildcard:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 return ConstraintType_Wildcard;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 case OrthancPluginConstraintType_List:
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 return ConstraintType_List;
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 default:
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
135 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
136 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 #endif
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
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
141 DatabaseConstraint::DatabaseConstraint(Orthanc::ResourceType level,
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
142 const Orthanc::DicomTag& tag,
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 bool isIdentifier,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 ConstraintType type,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 const std::vector<std::string>& values,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 bool caseSensitive,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 bool mandatory) :
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 level_(level),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 tag_(tag),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 isIdentifier_(isIdentifier),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 constraintType_(type),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 values_(values),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 caseSensitive_(caseSensitive),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 mandatory_(mandatory)
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 if (type != ConstraintType_List &&
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 values_.size() != 1)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
159 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
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
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 #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
165 DatabaseConstraint::DatabaseConstraint(const OrthancPluginDatabaseConstraint& constraint) :
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 level_(Plugins::Convert(constraint.level)),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 tag_(constraint.tagGroup, constraint.tagElement),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 isIdentifier_(constraint.isIdentifierTag),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 constraintType_(Plugins::Convert(constraint.type)),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 caseSensitive_(constraint.isCaseSensitive),
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 mandatory_(constraint.isMandatory)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 if (constraintType_ != ConstraintType_List &&
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 constraint.valuesCount != 1)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
176 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
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 values_.resize(constraint.valuesCount);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 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
182 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 assert(constraint.values[i] != NULL);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 values_[i].assign(constraint.values[i]);
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 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 #endif
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
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
190 #if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
191 DatabaseConstraint::DatabaseConstraint(const Orthanc::DatabasePluginMessages::DatabaseConstraint& constraint) :
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
192 level_(OrthancDatabases::MessagesToolbox::Convert(constraint.level())),
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
193 tag_(constraint.tag_group(), constraint.tag_element()),
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
194 isIdentifier_(constraint.is_identifier_tag()),
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
195 caseSensitive_(constraint.is_case_sensitive()),
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
196 mandatory_(constraint.is_mandatory())
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
197 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
198 switch (constraint.type())
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
199 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
200 case Orthanc::DatabasePluginMessages::CONSTRAINT_EQUAL:
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
201 constraintType_ = ConstraintType_Equal;
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
202 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
203
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
204 case Orthanc::DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL:
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
205 constraintType_ = ConstraintType_SmallerOrEqual;
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
206 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
207
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
208 case Orthanc::DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL:
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
209 constraintType_ = ConstraintType_GreaterOrEqual;
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
210 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
211
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
212 case Orthanc::DatabasePluginMessages::CONSTRAINT_WILDCARD:
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
213 constraintType_ = ConstraintType_Wildcard;
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
214 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
215
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
216 case Orthanc::DatabasePluginMessages::CONSTRAINT_LIST:
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
217 constraintType_ = ConstraintType_List;
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
218 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
219
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
220 default:
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
221 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
222 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
223
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
224 if (constraintType_ != ConstraintType_List &&
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
225 constraint.values().size() != 1)
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
226 {
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
227 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
228 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
229
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
230 values_.resize(constraint.values().size());
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
231
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
232 for (int i = 0; i < constraint.values().size(); i++)
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
233 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
234 values_[i] = constraint.values(i);
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
235 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
236 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
237 #endif
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
238
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
239
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 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
241 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 if (index >= values_.size())
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
244 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
245 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 else
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 return values_[index];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 }
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 const std::string& DatabaseConstraint::GetSingleValue() const
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 (values_.size() != 1)
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_BadSequenceOfCalls);
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 return values_[0];
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 #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
267 void DatabaseConstraint::EncodeForPlugins(OrthancPluginDatabaseConstraint& constraint,
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 std::vector<const char*>& tmpValues) const
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 memset(&constraint, 0, sizeof(constraint));
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 tmpValues.resize(values_.size());
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 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
275 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 tmpValues[i] = values_[i].c_str();
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
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 constraint.level = Plugins::Convert(level_);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 constraint.tagGroup = tag_.GetGroup();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 constraint.tagElement = tag_.GetElement();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 constraint.isIdentifierTag = isIdentifier_;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 constraint.isCaseSensitive = caseSensitive_;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 constraint.isMandatory = mandatory_;
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 constraint.type = Plugins::Convert(constraintType_);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 constraint.valuesCount = values_.size();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 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
288 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 #endif
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 void DatabaseConstraints::Clear()
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 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
295 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 assert(constraints_[i] != NULL);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 delete constraints_[i];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 constraints_.clear();
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 void DatabaseConstraints::AddConstraint(DatabaseConstraint* constraint)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 if (constraint == NULL)
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
308 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
309 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 constraints_.push_back(constraint);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 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
318 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 if (index >= constraints_.size())
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 {
551
1a23f1ce3b98 move classes DatabaseConstraint and ISqlLookupFormatter into namespace OrthancDatabases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
321 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
322 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 else
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 {
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 assert(constraints_[index] != NULL);
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 return *constraints_[index];
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 }
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 }
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
329
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
330
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
331 std::string DatabaseConstraints::Format() const
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
332 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
333 std::string s;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
334
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
335 for (size_t i = 0; i < constraints_.size(); i++)
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
336 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
337 assert(constraints_[i] != NULL);
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
338 const DatabaseConstraint& constraint = *constraints_[i];
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
339 s += "Constraint " + boost::lexical_cast<std::string>(i) + " at " + EnumerationToString(constraint.GetLevel()) +
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
340 ": " + constraint.GetTag().Format();
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
341
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
342 switch (constraint.GetConstraintType())
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
343 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
344 case ConstraintType_Equal:
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
345 s += " == " + constraint.GetSingleValue();
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
346 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
347
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
348 case ConstraintType_SmallerOrEqual:
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
349 s += " <= " + constraint.GetSingleValue();
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
350 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
351
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
352 case ConstraintType_GreaterOrEqual:
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
353 s += " >= " + constraint.GetSingleValue();
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
354 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
355
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
356 case ConstraintType_Wildcard:
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
357 s += " ~~ " + constraint.GetSingleValue();
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
358 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
359
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
360 case ConstraintType_List:
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
361 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
362 s += " in [ ";
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
363 bool first = true;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
364 for (size_t j = 0; j < constraint.GetValuesCount(); j++)
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
365 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
366 if (first)
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
367 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
368 first = false;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
369 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
370 else
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
371 {
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
372 s += ", ";
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
373 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
374 s += constraint.GetValue(j);
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
375 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
376 s += "]";
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
377 break;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
378 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
379
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
380 default:
553
7f45f23b10d0 integration mainline->find-refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 550 551
diff changeset
381 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
550
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
382 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
383
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
384 s += "\n";
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
385 }
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
386
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
387 return s;
9ed9a91bde33 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 549
diff changeset
388 }
547
b8e6e7a19424 un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 }