Mercurial > hg > orthanc-databases
annotate Framework/Plugins/MessagesToolbox.cpp @ 575:4c84d908e891 find-refactoring tip
fix statistics in read-only
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 30 Sep 2024 18:02:36 +0200 |
parents | 1a74fc1bea2d |
children |
rev | line source |
---|---|
550
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
9ed9a91bde33
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 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
9ed9a91bde33
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 |
9ed9a91bde33
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 |
9ed9a91bde33
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 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * |
9ed9a91bde33
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 |
9ed9a91bde33
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 |
9ed9a91bde33
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 |
9ed9a91bde33
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. |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * |
9ed9a91bde33
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 |
9ed9a91bde33
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 |
9ed9a91bde33
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 |
9ed9a91bde33
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. |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * |
9ed9a91bde33
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 |
9ed9a91bde33
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/>. |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 **/ |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "MessagesToolbox.h" |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 namespace OrthancDatabases |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 { |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 namespace MessagesToolbox |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 { |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 Orthanc::ResourceType Convert(Orthanc::DatabasePluginMessages::ResourceType resourceType) |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 { |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 switch (resourceType) |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 { |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 case Orthanc::DatabasePluginMessages::RESOURCE_PATIENT: |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 return Orthanc::ResourceType_Patient; |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 case Orthanc::DatabasePluginMessages::RESOURCE_STUDY: |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 return Orthanc::ResourceType_Study; |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 case Orthanc::DatabasePluginMessages::RESOURCE_SERIES: |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 return Orthanc::ResourceType_Series; |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 case Orthanc::DatabasePluginMessages::RESOURCE_INSTANCE: |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 return Orthanc::ResourceType_Instance; |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 default: |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 } |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 } |
554 | 51 |
52 | |
53 OrthancPluginResourceType ConvertToPlainC(Orthanc::ResourceType type) | |
54 { | |
55 switch (type) | |
56 { | |
57 case Orthanc::ResourceType_Patient: | |
58 return OrthancPluginResourceType_Patient; | |
59 | |
60 case Orthanc::ResourceType_Study: | |
61 return OrthancPluginResourceType_Study; | |
62 | |
63 case Orthanc::ResourceType_Series: | |
64 return OrthancPluginResourceType_Series; | |
65 | |
66 case Orthanc::ResourceType_Instance: | |
67 return OrthancPluginResourceType_Instance; | |
68 | |
69 default: | |
70 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
71 } | |
72 } | |
73 | |
74 | |
75 Orthanc::ResourceType Convert(OrthancPluginResourceType type) | |
76 { | |
77 switch (type) | |
78 { | |
79 case OrthancPluginResourceType_Patient: | |
80 return Orthanc::ResourceType_Patient; | |
81 | |
82 case OrthancPluginResourceType_Study: | |
83 return Orthanc::ResourceType_Study; | |
84 | |
85 case OrthancPluginResourceType_Series: | |
86 return Orthanc::ResourceType_Series; | |
87 | |
88 case OrthancPluginResourceType_Instance: | |
89 return Orthanc::ResourceType_Instance; | |
90 | |
91 default: | |
92 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
93 } | |
94 } | |
95 | |
96 | |
97 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 | |
98 OrthancPluginConstraintType ConvertToPlainC(ConstraintType constraint) | |
99 { | |
100 switch (constraint) | |
101 { | |
102 case ConstraintType_Equal: | |
103 return OrthancPluginConstraintType_Equal; | |
104 | |
105 case ConstraintType_GreaterOrEqual: | |
106 return OrthancPluginConstraintType_GreaterOrEqual; | |
107 | |
108 case ConstraintType_SmallerOrEqual: | |
109 return OrthancPluginConstraintType_SmallerOrEqual; | |
110 | |
111 case ConstraintType_Wildcard: | |
112 return OrthancPluginConstraintType_Wildcard; | |
113 | |
114 case ConstraintType_List: | |
115 return OrthancPluginConstraintType_List; | |
116 | |
117 default: | |
118 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
119 } | |
120 } | |
121 #endif | |
122 | |
123 | |
124 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 | |
125 ConstraintType Convert(OrthancPluginConstraintType constraint) | |
126 { | |
127 switch (constraint) | |
128 { | |
129 case OrthancPluginConstraintType_Equal: | |
130 return ConstraintType_Equal; | |
131 | |
132 case OrthancPluginConstraintType_GreaterOrEqual: | |
133 return ConstraintType_GreaterOrEqual; | |
134 | |
135 case OrthancPluginConstraintType_SmallerOrEqual: | |
136 return ConstraintType_SmallerOrEqual; | |
137 | |
138 case OrthancPluginConstraintType_Wildcard: | |
139 return ConstraintType_Wildcard; | |
140 | |
141 case OrthancPluginConstraintType_List: | |
142 return ConstraintType_List; | |
143 | |
144 default: | |
145 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
146 } | |
147 } | |
148 #endif | |
149 | |
150 | |
151 Orthanc::DatabasePluginMessages::ResourceType ConvertToProtobuf(OrthancPluginResourceType resourceType) | |
152 { | |
153 switch (resourceType) | |
154 { | |
155 case OrthancPluginResourceType_Patient: | |
156 return Orthanc::DatabasePluginMessages::RESOURCE_PATIENT; | |
157 | |
158 case OrthancPluginResourceType_Study: | |
159 return Orthanc::DatabasePluginMessages::RESOURCE_STUDY; | |
160 | |
161 case OrthancPluginResourceType_Series: | |
162 return Orthanc::DatabasePluginMessages::RESOURCE_SERIES; | |
163 | |
164 case OrthancPluginResourceType_Instance: | |
165 return Orthanc::DatabasePluginMessages::RESOURCE_INSTANCE; | |
166 | |
167 default: | |
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
169 } | |
170 } | |
550
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 } |
9ed9a91bde33
un-sharing DatabaseConstraint and ISqlLookupFormatter with Orthanc core
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 } |