Mercurial > hg > orthanc-databases
annotate Framework/Plugins/OrthancCppDatabasePlugin.h @ 78:2ee166f77501 db-changes
renamed macro
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sun, 06 Jan 2019 12:48:18 +0100 |
parents | a1c6238b26f8 |
children | 1012fe77241c |
rev | line source |
---|---|
0 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
67 | 5 * Copyright (C) 2017-2019 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero General Public License | |
9 * as published by the Free Software Foundation, either version 3 of | |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 | |
23 /** | |
24 * NOTE: Until Orthanc 1.4.0, this file was part of the Orthanc source | |
25 * distribution. This file is now part of "orthanc-databases", in | |
26 * order to uncouple its evolution from the Orthanc core. | |
27 **/ | |
28 | |
29 #pragma once | |
30 | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
31 #if HAS_ORTHANC_EXCEPTION != 1 |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
32 # error HAS_ORTHANC_EXCEPTION must be set to 1 |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
33 #endif |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
34 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
35 #if ORTHANC_ENABLE_PLUGINS != 1 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
36 # error ORTHANC_ENABLE_PLUGINS must be set to 1 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
37 #endif |
0 | 38 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
39 |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
40 #include <Core/OrthancException.h> |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
41 #include <OrthancServer/Search/DatabaseConstraint.h> |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
42 |
0 | 43 |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
44 |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
45 #define ORTHANC_PLUGINS_DATABASE_CATCH \ |
0 | 46 catch (::Orthanc::OrthancException& e) \ |
47 { \ | |
48 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); \ | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
49 } \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
50 catch (::std::runtime_error& e) \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
51 { \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
52 LogError(backend, e); \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
53 return OrthancPluginErrorCode_DatabasePlugin; \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
54 } \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
55 catch (...) \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
56 { \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
57 backend->GetOutput().LogError("Native exception"); \ |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
58 return OrthancPluginErrorCode_DatabasePlugin; \ |
0 | 59 } |
60 | |
61 | |
62 #include <stdexcept> | |
63 #include <list> | |
64 #include <string> | |
65 | |
66 namespace OrthancPlugins | |
67 { | |
68 /** | |
69 * @ingroup Callbacks | |
70 **/ | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
71 class DatabaseBackendOutput : public boost::noncopyable |
0 | 72 { |
73 friend class DatabaseBackendAdapter; | |
74 | |
75 private: | |
76 enum AllowedAnswers | |
77 { | |
78 AllowedAnswers_All, | |
79 AllowedAnswers_None, | |
80 AllowedAnswers_Attachment, | |
81 AllowedAnswers_Change, | |
82 AllowedAnswers_DicomTag, | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
83 AllowedAnswers_ExportedResource, |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
84 AllowedAnswers_MatchingResource, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
85 AllowedAnswers_String |
0 | 86 }; |
87 | |
88 OrthancPluginContext* context_; | |
89 OrthancPluginDatabaseContext* database_; | |
90 AllowedAnswers allowedAnswers_; | |
91 | |
92 void SetAllowedAnswers(AllowedAnswers allowed) | |
93 { | |
94 allowedAnswers_ = allowed; | |
95 } | |
96 | |
97 public: | |
98 DatabaseBackendOutput(OrthancPluginContext* context, | |
99 OrthancPluginDatabaseContext* database) : | |
100 context_(context), | |
101 database_(database), | |
102 allowedAnswers_(AllowedAnswers_All /* for unit tests */) | |
103 { | |
104 } | |
105 | |
106 OrthancPluginContext* GetContext() | |
107 { | |
108 return context_; | |
109 } | |
110 | |
111 void LogError(const std::string& message) | |
112 { | |
113 OrthancPluginLogError(context_, message.c_str()); | |
114 } | |
115 | |
116 void LogWarning(const std::string& message) | |
117 { | |
118 OrthancPluginLogWarning(context_, message.c_str()); | |
119 } | |
120 | |
121 void LogInfo(const std::string& message) | |
122 { | |
123 OrthancPluginLogInfo(context_, message.c_str()); | |
124 } | |
125 | |
126 void SignalDeletedAttachment(const std::string& uuid, | |
127 int32_t contentType, | |
128 uint64_t uncompressedSize, | |
129 const std::string& uncompressedHash, | |
130 int32_t compressionType, | |
131 uint64_t compressedSize, | |
132 const std::string& compressedHash) | |
133 { | |
134 OrthancPluginAttachment attachment; | |
135 attachment.uuid = uuid.c_str(); | |
136 attachment.contentType = contentType; | |
137 attachment.uncompressedSize = uncompressedSize; | |
138 attachment.uncompressedHash = uncompressedHash.c_str(); | |
139 attachment.compressionType = compressionType; | |
140 attachment.compressedSize = compressedSize; | |
141 attachment.compressedHash = compressedHash.c_str(); | |
142 | |
143 OrthancPluginDatabaseSignalDeletedAttachment(context_, database_, &attachment); | |
144 } | |
145 | |
146 void SignalDeletedResource(const std::string& publicId, | |
147 OrthancPluginResourceType resourceType) | |
148 { | |
149 OrthancPluginDatabaseSignalDeletedResource(context_, database_, publicId.c_str(), resourceType); | |
150 } | |
151 | |
152 void SignalRemainingAncestor(const std::string& ancestorId, | |
153 OrthancPluginResourceType ancestorType) | |
154 { | |
155 OrthancPluginDatabaseSignalRemainingAncestor(context_, database_, ancestorId.c_str(), ancestorType); | |
156 } | |
157 | |
158 void AnswerAttachment(const std::string& uuid, | |
159 int32_t contentType, | |
160 uint64_t uncompressedSize, | |
161 const std::string& uncompressedHash, | |
162 int32_t compressionType, | |
163 uint64_t compressedSize, | |
164 const std::string& compressedHash) | |
165 { | |
166 if (allowedAnswers_ != AllowedAnswers_All && | |
167 allowedAnswers_ != AllowedAnswers_Attachment) | |
168 { | |
169 throw std::runtime_error("Cannot answer with an attachment in the current state"); | |
170 } | |
171 | |
172 OrthancPluginAttachment attachment; | |
173 attachment.uuid = uuid.c_str(); | |
174 attachment.contentType = contentType; | |
175 attachment.uncompressedSize = uncompressedSize; | |
176 attachment.uncompressedHash = uncompressedHash.c_str(); | |
177 attachment.compressionType = compressionType; | |
178 attachment.compressedSize = compressedSize; | |
179 attachment.compressedHash = compressedHash.c_str(); | |
180 | |
181 OrthancPluginDatabaseAnswerAttachment(context_, database_, &attachment); | |
182 } | |
183 | |
184 void AnswerChange(int64_t seq, | |
185 int32_t changeType, | |
186 OrthancPluginResourceType resourceType, | |
187 const std::string& publicId, | |
188 const std::string& date) | |
189 { | |
190 if (allowedAnswers_ != AllowedAnswers_All && | |
191 allowedAnswers_ != AllowedAnswers_Change) | |
192 { | |
193 throw std::runtime_error("Cannot answer with a change in the current state"); | |
194 } | |
195 | |
196 OrthancPluginChange change; | |
197 change.seq = seq; | |
198 change.changeType = changeType; | |
199 change.resourceType = resourceType; | |
200 change.publicId = publicId.c_str(); | |
201 change.date = date.c_str(); | |
202 | |
203 OrthancPluginDatabaseAnswerChange(context_, database_, &change); | |
204 } | |
205 | |
206 void AnswerDicomTag(uint16_t group, | |
207 uint16_t element, | |
208 const std::string& value) | |
209 { | |
210 if (allowedAnswers_ != AllowedAnswers_All && | |
211 allowedAnswers_ != AllowedAnswers_DicomTag) | |
212 { | |
213 throw std::runtime_error("Cannot answer with a DICOM tag in the current state"); | |
214 } | |
215 | |
216 OrthancPluginDicomTag tag; | |
217 tag.group = group; | |
218 tag.element = element; | |
219 tag.value = value.c_str(); | |
220 | |
221 OrthancPluginDatabaseAnswerDicomTag(context_, database_, &tag); | |
222 } | |
223 | |
224 void AnswerExportedResource(int64_t seq, | |
225 OrthancPluginResourceType resourceType, | |
226 const std::string& publicId, | |
227 const std::string& modality, | |
228 const std::string& date, | |
229 const std::string& patientId, | |
230 const std::string& studyInstanceUid, | |
231 const std::string& seriesInstanceUid, | |
232 const std::string& sopInstanceUid) | |
233 { | |
234 if (allowedAnswers_ != AllowedAnswers_All && | |
235 allowedAnswers_ != AllowedAnswers_ExportedResource) | |
236 { | |
237 throw std::runtime_error("Cannot answer with an exported resource in the current state"); | |
238 } | |
239 | |
240 OrthancPluginExportedResource exported; | |
241 exported.seq = seq; | |
242 exported.resourceType = resourceType; | |
243 exported.publicId = publicId.c_str(); | |
244 exported.modality = modality.c_str(); | |
245 exported.date = date.c_str(); | |
246 exported.patientId = patientId.c_str(); | |
247 exported.studyInstanceUid = studyInstanceUid.c_str(); | |
248 exported.seriesInstanceUid = seriesInstanceUid.c_str(); | |
249 exported.sopInstanceUid = sopInstanceUid.c_str(); | |
250 | |
251 OrthancPluginDatabaseAnswerExportedResource(context_, database_, &exported); | |
252 } | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
253 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
254 |
78 | 255 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
256 void AnswerMatchingResource(const std::string& resourceId) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
257 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
258 if (allowedAnswers_ != AllowedAnswers_All && |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
259 allowedAnswers_ != AllowedAnswers_MatchingResource) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
260 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
261 throw std::runtime_error("Cannot answer with an exported resource in the current state"); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
262 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
263 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
264 OrthancPluginMatchingResource match; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
265 match.resourceId = resourceId.c_str(); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
266 match.someInstanceId = NULL; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
267 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
268 OrthancPluginDatabaseAnswerMatchingResource(context_, database_, &match); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
269 } |
70
e6c13ddd26d9
all integration tests passing with LookupResources extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
69
diff
changeset
|
270 #endif |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
271 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
272 |
78 | 273 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
274 void AnswerMatchingResource(const std::string& resourceId, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
275 const std::string& someInstanceId) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
276 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
277 if (allowedAnswers_ != AllowedAnswers_All && |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
278 allowedAnswers_ != AllowedAnswers_MatchingResource) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
279 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
280 throw std::runtime_error("Cannot answer with an exported resource in the current state"); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
281 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
282 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
283 OrthancPluginMatchingResource match; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
284 match.resourceId = resourceId.c_str(); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
285 match.someInstanceId = someInstanceId.c_str(); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
286 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
287 OrthancPluginDatabaseAnswerMatchingResource(context_, database_, &match); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
288 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
289 #endif |
0 | 290 }; |
291 | |
292 | |
293 /** | |
294 * @ingroup Callbacks | |
295 **/ | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
296 class IDatabaseBackend : public boost::noncopyable |
0 | 297 { |
298 friend class DatabaseBackendAdapter; | |
299 | |
300 private: | |
301 DatabaseBackendOutput* output_; | |
302 | |
303 void Finalize() | |
304 { | |
305 if (output_ != NULL) | |
306 { | |
307 delete output_; | |
308 output_ = NULL; | |
309 } | |
310 } | |
311 | |
312 protected: | |
313 DatabaseBackendOutput& GetOutput() | |
314 { | |
315 return *output_; | |
316 } | |
317 | |
318 public: | |
319 IDatabaseBackend() : output_(NULL) | |
320 { | |
321 } | |
322 | |
323 virtual ~IDatabaseBackend() | |
324 { | |
325 Finalize(); | |
326 } | |
327 | |
328 // This takes the ownership | |
329 void RegisterOutput(DatabaseBackendOutput* output) | |
330 { | |
331 Finalize(); | |
332 output_ = output; | |
333 } | |
334 | |
335 virtual void Open() = 0; | |
336 | |
337 virtual void Close() = 0; | |
338 | |
339 virtual void AddAttachment(int64_t id, | |
340 const OrthancPluginAttachment& attachment) = 0; | |
341 | |
342 virtual void AttachChild(int64_t parent, | |
343 int64_t child) = 0; | |
344 | |
345 virtual void ClearChanges() = 0; | |
346 | |
347 virtual void ClearExportedResources() = 0; | |
348 | |
349 virtual int64_t CreateResource(const char* publicId, | |
350 OrthancPluginResourceType type) = 0; | |
351 | |
352 virtual void DeleteAttachment(int64_t id, | |
353 int32_t attachment) = 0; | |
354 | |
355 virtual void DeleteMetadata(int64_t id, | |
356 int32_t metadataType) = 0; | |
357 | |
358 virtual void DeleteResource(int64_t id) = 0; | |
359 | |
360 virtual void GetAllInternalIds(std::list<int64_t>& target, | |
361 OrthancPluginResourceType resourceType) = 0; | |
362 | |
363 virtual void GetAllPublicIds(std::list<std::string>& target, | |
364 OrthancPluginResourceType resourceType) = 0; | |
365 | |
366 virtual void GetAllPublicIds(std::list<std::string>& target, | |
367 OrthancPluginResourceType resourceType, | |
368 uint64_t since, | |
369 uint64_t limit) = 0; | |
370 | |
371 /* Use GetOutput().AnswerChange() */ | |
372 virtual void GetChanges(bool& done /*out*/, | |
373 int64_t since, | |
374 uint32_t maxResults) = 0; | |
375 | |
376 virtual void GetChildrenInternalId(std::list<int64_t>& target /*out*/, | |
377 int64_t id) = 0; | |
378 | |
379 virtual void GetChildrenPublicId(std::list<std::string>& target /*out*/, | |
380 int64_t id) = 0; | |
381 | |
382 /* Use GetOutput().AnswerExportedResource() */ | |
383 virtual void GetExportedResources(bool& done /*out*/, | |
384 int64_t since, | |
385 uint32_t maxResults) = 0; | |
386 | |
387 /* Use GetOutput().AnswerChange() */ | |
388 virtual void GetLastChange() = 0; | |
389 | |
390 /* Use GetOutput().AnswerExportedResource() */ | |
391 virtual void GetLastExportedResource() = 0; | |
392 | |
393 /* Use GetOutput().AnswerDicomTag() */ | |
394 virtual void GetMainDicomTags(int64_t id) = 0; | |
395 | |
396 virtual std::string GetPublicId(int64_t resourceId) = 0; | |
397 | |
398 virtual uint64_t GetResourceCount(OrthancPluginResourceType resourceType) = 0; | |
399 | |
400 virtual OrthancPluginResourceType GetResourceType(int64_t resourceId) = 0; | |
401 | |
402 virtual uint64_t GetTotalCompressedSize() = 0; | |
403 | |
404 virtual uint64_t GetTotalUncompressedSize() = 0; | |
405 | |
406 virtual bool IsExistingResource(int64_t internalId) = 0; | |
407 | |
408 virtual bool IsProtectedPatient(int64_t internalId) = 0; | |
409 | |
410 virtual void ListAvailableMetadata(std::list<int32_t>& target /*out*/, | |
411 int64_t id) = 0; | |
412 | |
413 virtual void ListAvailableAttachments(std::list<int32_t>& target /*out*/, | |
414 int64_t id) = 0; | |
415 | |
416 virtual void LogChange(const OrthancPluginChange& change) = 0; | |
417 | |
418 virtual void LogExportedResource(const OrthancPluginExportedResource& resource) = 0; | |
419 | |
420 /* Use GetOutput().AnswerAttachment() */ | |
421 virtual bool LookupAttachment(int64_t id, | |
422 int32_t contentType) = 0; | |
423 | |
424 virtual bool LookupGlobalProperty(std::string& target /*out*/, | |
425 int32_t property) = 0; | |
426 | |
427 virtual void LookupIdentifier(std::list<int64_t>& target /*out*/, | |
428 OrthancPluginResourceType resourceType, | |
429 uint16_t group, | |
430 uint16_t element, | |
431 OrthancPluginIdentifierConstraint constraint, | |
432 const char* value) = 0; | |
433 | |
434 virtual void LookupIdentifierRange(std::list<int64_t>& target /*out*/, | |
435 OrthancPluginResourceType resourceType, | |
436 uint16_t group, | |
437 uint16_t element, | |
438 const char* start, | |
439 const char* end) = 0; | |
440 | |
441 virtual bool LookupMetadata(std::string& target /*out*/, | |
442 int64_t id, | |
443 int32_t metadataType) = 0; | |
444 | |
445 virtual bool LookupParent(int64_t& parentId /*out*/, | |
446 int64_t resourceId) = 0; | |
447 | |
448 virtual bool LookupResource(int64_t& id /*out*/, | |
449 OrthancPluginResourceType& type /*out*/, | |
450 const char* publicId) = 0; | |
451 | |
452 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/) = 0; | |
453 | |
454 virtual bool SelectPatientToRecycle(int64_t& internalId /*out*/, | |
455 int64_t patientIdToAvoid) = 0; | |
456 | |
457 virtual void SetGlobalProperty(int32_t property, | |
458 const char* value) = 0; | |
459 | |
460 virtual void SetMainDicomTag(int64_t id, | |
461 uint16_t group, | |
462 uint16_t element, | |
463 const char* value) = 0; | |
464 | |
465 virtual void SetIdentifierTag(int64_t id, | |
466 uint16_t group, | |
467 uint16_t element, | |
468 const char* value) = 0; | |
469 | |
470 virtual void SetMetadata(int64_t id, | |
471 int32_t metadataType, | |
472 const char* value) = 0; | |
473 | |
474 virtual void SetProtectedPatient(int64_t internalId, | |
475 bool isProtected) = 0; | |
476 | |
477 virtual void StartTransaction() = 0; | |
478 | |
479 virtual void RollbackTransaction() = 0; | |
480 | |
481 virtual void CommitTransaction() = 0; | |
482 | |
483 virtual uint32_t GetDatabaseVersion() = 0; | |
484 | |
485 /** | |
486 * Upgrade the database to the specified version of the database | |
487 * schema. The upgrade script is allowed to make calls to | |
488 * OrthancPluginReconstructMainDicomTags(). | |
489 **/ | |
490 virtual void UpgradeDatabase(uint32_t targetVersion, | |
491 OrthancPluginStorageArea* storageArea) = 0; | |
492 | |
493 virtual void ClearMainDicomTags(int64_t internalId) = 0; | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
494 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
495 virtual bool HasCreateInstance() const = 0; |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
496 |
78 | 497 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
498 virtual void LookupResources(const std::vector<Orthanc::DatabaseConstraint>& lookup, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
499 OrthancPluginResourceType queryLevel, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
500 uint32_t limit, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
501 bool requestSomeInstance) = 0; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
502 #endif |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
503 |
78 | 504 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
505 virtual void CreateInstance(OrthancPluginCreateInstanceResult& result, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
506 const char* hashPatient, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
507 const char* hashStudy, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
508 const char* hashSeries, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
509 const char* hashInstance) |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
510 { |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
511 throw std::runtime_error("Not implemented"); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
512 } |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
513 #endif |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
514 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
515 |
78 | 516 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
517 virtual void SetResourcesContent( |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
518 uint32_t countIdentifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
519 const OrthancPluginResourcesContentTags* identifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
520 uint32_t countMainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
521 const OrthancPluginResourcesContentTags* mainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
522 uint32_t countMetadata, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
523 const OrthancPluginResourcesContentMetadata* metadata) = 0; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
524 #endif |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
525 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
526 |
78 | 527 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
528 virtual void GetChildrenMetadata(std::list<std::string>& target, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
529 int64_t resourceId, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
530 int32_t metadata) = 0; |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
531 #endif |
0 | 532 }; |
533 | |
534 | |
535 | |
536 /** | |
537 * @brief Bridge between C and C++ database engines. | |
538 * | |
539 * Class creating the bridge between the C low-level primitives for | |
540 * custom database engines, and the high-level IDatabaseBackend C++ | |
541 * interface. | |
542 * | |
543 * @ingroup Callbacks | |
544 **/ | |
545 class DatabaseBackendAdapter | |
546 { | |
547 private: | |
548 // This class cannot be instantiated | |
549 DatabaseBackendAdapter() | |
550 { | |
551 } | |
552 | |
553 static void LogError(IDatabaseBackend* backend, | |
554 const std::runtime_error& e) | |
555 { | |
556 backend->GetOutput().LogError("Exception in database back-end: " + std::string(e.what())); | |
557 } | |
558 | |
559 | |
560 static OrthancPluginErrorCode AddAttachment(void* payload, | |
561 int64_t id, | |
562 const OrthancPluginAttachment* attachment) | |
563 { | |
564 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
565 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
566 | |
567 try | |
568 { | |
569 backend->AddAttachment(id, *attachment); | |
570 return OrthancPluginErrorCode_Success; | |
571 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
572 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 573 } |
574 | |
575 | |
576 static OrthancPluginErrorCode AttachChild(void* payload, | |
577 int64_t parent, | |
578 int64_t child) | |
579 { | |
580 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
581 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
582 | |
583 try | |
584 { | |
585 backend->AttachChild(parent, child); | |
586 return OrthancPluginErrorCode_Success; | |
587 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
588 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 589 } |
590 | |
591 | |
592 static OrthancPluginErrorCode ClearChanges(void* payload) | |
593 { | |
594 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
595 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
596 | |
597 try | |
598 { | |
599 backend->ClearChanges(); | |
600 return OrthancPluginErrorCode_Success; | |
601 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
602 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 603 } |
604 | |
605 | |
606 static OrthancPluginErrorCode ClearExportedResources(void* payload) | |
607 { | |
608 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
609 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
610 | |
611 try | |
612 { | |
613 backend->ClearExportedResources(); | |
614 return OrthancPluginErrorCode_Success; | |
615 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
616 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 617 } |
618 | |
619 | |
620 static OrthancPluginErrorCode CreateResource(int64_t* id, | |
621 void* payload, | |
622 const char* publicId, | |
623 OrthancPluginResourceType resourceType) | |
624 { | |
625 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
626 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
627 | |
628 try | |
629 { | |
630 *id = backend->CreateResource(publicId, resourceType); | |
631 return OrthancPluginErrorCode_Success; | |
632 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
633 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 634 } |
635 | |
636 | |
637 static OrthancPluginErrorCode DeleteAttachment(void* payload, | |
638 int64_t id, | |
639 int32_t contentType) | |
640 { | |
641 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
642 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
643 | |
644 try | |
645 { | |
646 backend->DeleteAttachment(id, contentType); | |
647 return OrthancPluginErrorCode_Success; | |
648 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
649 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 650 } |
651 | |
652 | |
653 static OrthancPluginErrorCode DeleteMetadata(void* payload, | |
654 int64_t id, | |
655 int32_t metadataType) | |
656 { | |
657 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
658 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
659 | |
660 try | |
661 { | |
662 backend->DeleteMetadata(id, metadataType); | |
663 return OrthancPluginErrorCode_Success; | |
664 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
665 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 666 } |
667 | |
668 | |
669 static OrthancPluginErrorCode DeleteResource(void* payload, | |
670 int64_t id) | |
671 { | |
672 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
673 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
674 | |
675 try | |
676 { | |
677 backend->DeleteResource(id); | |
678 return OrthancPluginErrorCode_Success; | |
679 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
680 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 681 } |
682 | |
683 | |
684 static OrthancPluginErrorCode GetAllInternalIds(OrthancPluginDatabaseContext* context, | |
685 void* payload, | |
686 OrthancPluginResourceType resourceType) | |
687 { | |
688 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
689 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
690 | |
691 try | |
692 { | |
693 std::list<int64_t> target; | |
694 backend->GetAllInternalIds(target, resourceType); | |
695 | |
696 for (std::list<int64_t>::const_iterator | |
697 it = target.begin(); it != target.end(); ++it) | |
698 { | |
699 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
700 backend->GetOutput().database_, *it); | |
701 } | |
702 | |
703 return OrthancPluginErrorCode_Success; | |
704 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
705 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 706 } |
707 | |
708 | |
709 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseContext* context, | |
710 void* payload, | |
711 OrthancPluginResourceType resourceType) | |
712 { | |
713 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
714 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
715 | |
716 try | |
717 { | |
718 std::list<std::string> ids; | |
719 backend->GetAllPublicIds(ids, resourceType); | |
720 | |
721 for (std::list<std::string>::const_iterator | |
722 it = ids.begin(); it != ids.end(); ++it) | |
723 { | |
724 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, | |
725 backend->GetOutput().database_, | |
726 it->c_str()); | |
727 } | |
728 | |
729 return OrthancPluginErrorCode_Success; | |
730 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
731 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 732 } |
733 | |
734 | |
735 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseContext* context, | |
736 void* payload, | |
737 OrthancPluginResourceType resourceType, | |
738 uint64_t since, | |
739 uint64_t limit) | |
740 { | |
741 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
742 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
743 | |
744 try | |
745 { | |
746 std::list<std::string> ids; | |
747 backend->GetAllPublicIds(ids, resourceType, since, limit); | |
748 | |
749 for (std::list<std::string>::const_iterator | |
750 it = ids.begin(); it != ids.end(); ++it) | |
751 { | |
752 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, | |
753 backend->GetOutput().database_, | |
754 it->c_str()); | |
755 } | |
756 | |
757 return OrthancPluginErrorCode_Success; | |
758 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
759 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 760 } |
761 | |
762 | |
763 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseContext* context, | |
764 void* payload, | |
765 int64_t since, | |
766 uint32_t maxResult) | |
767 { | |
768 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
769 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change); | |
770 | |
771 try | |
772 { | |
773 bool done; | |
774 backend->GetChanges(done, since, maxResult); | |
775 | |
776 if (done) | |
777 { | |
778 OrthancPluginDatabaseAnswerChangesDone(backend->GetOutput().context_, | |
779 backend->GetOutput().database_); | |
780 } | |
781 | |
782 return OrthancPluginErrorCode_Success; | |
783 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
784 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 785 } |
786 | |
787 | |
788 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseContext* context, | |
789 void* payload, | |
790 int64_t id) | |
791 { | |
792 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
793 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
794 | |
795 try | |
796 { | |
797 std::list<int64_t> target; | |
798 backend->GetChildrenInternalId(target, id); | |
799 | |
800 for (std::list<int64_t>::const_iterator | |
801 it = target.begin(); it != target.end(); ++it) | |
802 { | |
803 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
804 backend->GetOutput().database_, *it); | |
805 } | |
806 | |
807 return OrthancPluginErrorCode_Success; | |
808 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
809 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 810 } |
811 | |
812 | |
813 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseContext* context, | |
814 void* payload, | |
815 int64_t id) | |
816 { | |
817 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
818 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
819 | |
820 try | |
821 { | |
822 std::list<std::string> ids; | |
823 backend->GetChildrenPublicId(ids, id); | |
824 | |
825 for (std::list<std::string>::const_iterator | |
826 it = ids.begin(); it != ids.end(); ++it) | |
827 { | |
828 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, | |
829 backend->GetOutput().database_, | |
830 it->c_str()); | |
831 } | |
832 | |
833 return OrthancPluginErrorCode_Success; | |
834 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
835 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 836 } |
837 | |
838 | |
839 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseContext* context, | |
840 void* payload, | |
841 int64_t since, | |
842 uint32_t maxResult) | |
843 { | |
844 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
845 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource); | |
846 | |
847 try | |
848 { | |
849 bool done; | |
850 backend->GetExportedResources(done, since, maxResult); | |
851 | |
852 if (done) | |
853 { | |
854 OrthancPluginDatabaseAnswerExportedResourcesDone(backend->GetOutput().context_, | |
855 backend->GetOutput().database_); | |
856 } | |
857 return OrthancPluginErrorCode_Success; | |
858 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
859 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 860 } |
861 | |
862 | |
863 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseContext* context, | |
864 void* payload) | |
865 { | |
866 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
867 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Change); | |
868 | |
869 try | |
870 { | |
871 backend->GetLastChange(); | |
872 return OrthancPluginErrorCode_Success; | |
873 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
874 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 875 } |
876 | |
877 | |
878 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseContext* context, | |
879 void* payload) | |
880 { | |
881 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
882 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_ExportedResource); | |
883 | |
884 try | |
885 { | |
886 backend->GetLastExportedResource(); | |
887 return OrthancPluginErrorCode_Success; | |
888 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
889 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 890 } |
891 | |
892 | |
893 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseContext* context, | |
894 void* payload, | |
895 int64_t id) | |
896 { | |
897 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
898 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_DicomTag); | |
899 | |
900 try | |
901 { | |
902 backend->GetMainDicomTags(id); | |
903 return OrthancPluginErrorCode_Success; | |
904 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
905 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 906 } |
907 | |
908 | |
909 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseContext* context, | |
910 void* payload, | |
911 int64_t id) | |
912 { | |
913 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
914 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
915 | |
916 try | |
917 { | |
918 std::string s = backend->GetPublicId(id); | |
919 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, | |
920 backend->GetOutput().database_, | |
921 s.c_str()); | |
922 | |
923 return OrthancPluginErrorCode_Success; | |
924 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
925 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 926 } |
927 | |
928 | |
929 static OrthancPluginErrorCode GetResourceCount(uint64_t* target, | |
930 void* payload, | |
931 OrthancPluginResourceType resourceType) | |
932 { | |
933 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
934 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
935 | |
936 try | |
937 { | |
938 *target = backend->GetResourceCount(resourceType); | |
939 return OrthancPluginErrorCode_Success; | |
940 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
941 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 942 } |
943 | |
944 | |
945 static OrthancPluginErrorCode GetResourceType(OrthancPluginResourceType* resourceType, | |
946 void* payload, | |
947 int64_t id) | |
948 { | |
949 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
950 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
951 | |
952 try | |
953 { | |
954 *resourceType = backend->GetResourceType(id); | |
955 return OrthancPluginErrorCode_Success; | |
956 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
957 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 958 } |
959 | |
960 | |
961 static OrthancPluginErrorCode GetTotalCompressedSize(uint64_t* target, | |
962 void* payload) | |
963 { | |
964 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
965 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
966 | |
967 try | |
968 { | |
969 *target = backend->GetTotalCompressedSize(); | |
970 return OrthancPluginErrorCode_Success; | |
971 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
972 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 973 } |
974 | |
975 | |
976 static OrthancPluginErrorCode GetTotalUncompressedSize(uint64_t* target, | |
977 void* payload) | |
978 { | |
979 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
980 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
981 | |
982 try | |
983 { | |
984 *target = backend->GetTotalUncompressedSize(); | |
985 return OrthancPluginErrorCode_Success; | |
986 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
987 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 988 } |
989 | |
990 | |
991 static OrthancPluginErrorCode IsExistingResource(int32_t* existing, | |
992 void* payload, | |
993 int64_t id) | |
994 { | |
995 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
996 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
997 | |
998 try | |
999 { | |
1000 *existing = backend->IsExistingResource(id); | |
1001 return OrthancPluginErrorCode_Success; | |
1002 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1003 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1004 } |
1005 | |
1006 | |
1007 static OrthancPluginErrorCode IsProtectedPatient(int32_t* isProtected, | |
1008 void* payload, | |
1009 int64_t id) | |
1010 { | |
1011 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1012 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1013 | |
1014 try | |
1015 { | |
1016 *isProtected = backend->IsProtectedPatient(id); | |
1017 return OrthancPluginErrorCode_Success; | |
1018 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1019 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1020 } |
1021 | |
1022 | |
1023 static OrthancPluginErrorCode ListAvailableMetadata(OrthancPluginDatabaseContext* context, | |
1024 void* payload, | |
1025 int64_t id) | |
1026 { | |
1027 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1028 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1029 | |
1030 try | |
1031 { | |
1032 std::list<int32_t> target; | |
1033 backend->ListAvailableMetadata(target, id); | |
1034 | |
1035 for (std::list<int32_t>::const_iterator | |
1036 it = target.begin(); it != target.end(); ++it) | |
1037 { | |
1038 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_, | |
1039 backend->GetOutput().database_, | |
1040 *it); | |
1041 } | |
1042 | |
1043 return OrthancPluginErrorCode_Success; | |
1044 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1045 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1046 } |
1047 | |
1048 | |
1049 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseContext* context, | |
1050 void* payload, | |
1051 int64_t id) | |
1052 { | |
1053 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1054 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1055 | |
1056 try | |
1057 { | |
1058 std::list<int32_t> target; | |
1059 backend->ListAvailableAttachments(target, id); | |
1060 | |
1061 for (std::list<int32_t>::const_iterator | |
1062 it = target.begin(); it != target.end(); ++it) | |
1063 { | |
1064 OrthancPluginDatabaseAnswerInt32(backend->GetOutput().context_, | |
1065 backend->GetOutput().database_, | |
1066 *it); | |
1067 } | |
1068 | |
1069 return OrthancPluginErrorCode_Success; | |
1070 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1071 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1072 } |
1073 | |
1074 | |
1075 static OrthancPluginErrorCode LogChange(void* payload, | |
1076 const OrthancPluginChange* change) | |
1077 { | |
1078 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1079 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1080 | |
1081 try | |
1082 { | |
1083 backend->LogChange(*change); | |
1084 return OrthancPluginErrorCode_Success; | |
1085 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1086 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1087 } |
1088 | |
1089 | |
1090 static OrthancPluginErrorCode LogExportedResource(void* payload, | |
1091 const OrthancPluginExportedResource* exported) | |
1092 { | |
1093 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1094 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1095 | |
1096 try | |
1097 { | |
1098 backend->LogExportedResource(*exported); | |
1099 return OrthancPluginErrorCode_Success; | |
1100 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1101 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1102 } |
1103 | |
1104 | |
1105 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseContext* context, | |
1106 void* payload, | |
1107 int64_t id, | |
1108 int32_t contentType) | |
1109 { | |
1110 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1111 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_Attachment); | |
1112 | |
1113 try | |
1114 { | |
1115 backend->LookupAttachment(id, contentType); | |
1116 return OrthancPluginErrorCode_Success; | |
1117 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1118 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1119 } |
1120 | |
1121 | |
1122 static OrthancPluginErrorCode LookupGlobalProperty(OrthancPluginDatabaseContext* context, | |
1123 void* payload, | |
1124 int32_t property) | |
1125 { | |
1126 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1127 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1128 | |
1129 try | |
1130 { | |
1131 std::string s; | |
1132 if (backend->LookupGlobalProperty(s, property)) | |
1133 { | |
1134 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, | |
1135 backend->GetOutput().database_, | |
1136 s.c_str()); | |
1137 } | |
1138 | |
1139 return OrthancPluginErrorCode_Success; | |
1140 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1141 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1142 } |
1143 | |
1144 | |
1145 static OrthancPluginErrorCode LookupIdentifier3(OrthancPluginDatabaseContext* context, | |
1146 void* payload, | |
1147 OrthancPluginResourceType resourceType, | |
1148 const OrthancPluginDicomTag* tag, | |
1149 OrthancPluginIdentifierConstraint constraint) | |
1150 { | |
1151 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1152 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1153 | |
1154 try | |
1155 { | |
1156 std::list<int64_t> target; | |
1157 backend->LookupIdentifier(target, resourceType, tag->group, tag->element, constraint, tag->value); | |
1158 | |
1159 for (std::list<int64_t>::const_iterator | |
1160 it = target.begin(); it != target.end(); ++it) | |
1161 { | |
1162 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
1163 backend->GetOutput().database_, *it); | |
1164 } | |
1165 | |
1166 return OrthancPluginErrorCode_Success; | |
1167 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1168 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1169 } |
1170 | |
1171 | |
1172 static OrthancPluginErrorCode LookupIdentifierRange(OrthancPluginDatabaseContext* context, | |
1173 void* payload, | |
1174 OrthancPluginResourceType resourceType, | |
1175 uint16_t group, | |
1176 uint16_t element, | |
1177 const char* start, | |
1178 const char* end) | |
1179 { | |
1180 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1181 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1182 | |
1183 try | |
1184 { | |
1185 std::list<int64_t> target; | |
1186 backend->LookupIdentifierRange(target, resourceType, group, element, start, end); | |
1187 | |
1188 for (std::list<int64_t>::const_iterator | |
1189 it = target.begin(); it != target.end(); ++it) | |
1190 { | |
1191 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
1192 backend->GetOutput().database_, *it); | |
1193 } | |
1194 | |
1195 return OrthancPluginErrorCode_Success; | |
1196 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1197 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1198 } |
1199 | |
1200 | |
1201 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseContext* context, | |
1202 void* payload, | |
1203 int64_t id, | |
1204 int32_t metadata) | |
1205 { | |
1206 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1207 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1208 | |
1209 try | |
1210 { | |
1211 std::string s; | |
1212 if (backend->LookupMetadata(s, id, metadata)) | |
1213 { | |
1214 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, | |
1215 backend->GetOutput().database_, s.c_str()); | |
1216 } | |
1217 | |
1218 return OrthancPluginErrorCode_Success; | |
1219 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1220 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1221 } |
1222 | |
1223 | |
1224 static OrthancPluginErrorCode LookupParent(OrthancPluginDatabaseContext* context, | |
1225 void* payload, | |
1226 int64_t id) | |
1227 { | |
1228 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1229 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1230 | |
1231 try | |
1232 { | |
1233 int64_t parent; | |
1234 if (backend->LookupParent(parent, id)) | |
1235 { | |
1236 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
1237 backend->GetOutput().database_, parent); | |
1238 } | |
1239 | |
1240 return OrthancPluginErrorCode_Success; | |
1241 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1242 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1243 } |
1244 | |
1245 | |
1246 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseContext* context, | |
1247 void* payload, | |
1248 const char* publicId) | |
1249 { | |
1250 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1251 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1252 | |
1253 try | |
1254 { | |
1255 int64_t id; | |
1256 OrthancPluginResourceType type; | |
1257 if (backend->LookupResource(id, type, publicId)) | |
1258 { | |
1259 OrthancPluginDatabaseAnswerResource(backend->GetOutput().context_, | |
1260 backend->GetOutput().database_, | |
1261 id, type); | |
1262 } | |
1263 | |
1264 return OrthancPluginErrorCode_Success; | |
1265 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1266 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1267 } |
1268 | |
1269 | |
1270 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseContext* context, | |
1271 void* payload) | |
1272 { | |
1273 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1274 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1275 | |
1276 try | |
1277 { | |
1278 int64_t id; | |
1279 if (backend->SelectPatientToRecycle(id)) | |
1280 { | |
1281 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
1282 backend->GetOutput().database_, id); | |
1283 } | |
1284 | |
1285 return OrthancPluginErrorCode_Success; | |
1286 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1287 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1288 } |
1289 | |
1290 | |
1291 static OrthancPluginErrorCode SelectPatientToRecycle2(OrthancPluginDatabaseContext* context, | |
1292 void* payload, | |
1293 int64_t patientIdToAvoid) | |
1294 { | |
1295 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1296 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1297 | |
1298 try | |
1299 { | |
1300 int64_t id; | |
1301 if (backend->SelectPatientToRecycle(id, patientIdToAvoid)) | |
1302 { | |
1303 OrthancPluginDatabaseAnswerInt64(backend->GetOutput().context_, | |
1304 backend->GetOutput().database_, id); | |
1305 } | |
1306 | |
1307 return OrthancPluginErrorCode_Success; | |
1308 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1309 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1310 } |
1311 | |
1312 | |
1313 static OrthancPluginErrorCode SetGlobalProperty(void* payload, | |
1314 int32_t property, | |
1315 const char* value) | |
1316 { | |
1317 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1318 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1319 | |
1320 try | |
1321 { | |
1322 backend->SetGlobalProperty(property, value); | |
1323 return OrthancPluginErrorCode_Success; | |
1324 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1325 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1326 } |
1327 | |
1328 | |
1329 static OrthancPluginErrorCode SetMainDicomTag(void* payload, | |
1330 int64_t id, | |
1331 const OrthancPluginDicomTag* tag) | |
1332 { | |
1333 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1334 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1335 | |
1336 try | |
1337 { | |
1338 backend->SetMainDicomTag(id, tag->group, tag->element, tag->value); | |
1339 return OrthancPluginErrorCode_Success; | |
1340 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1341 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1342 } |
1343 | |
1344 | |
1345 static OrthancPluginErrorCode SetIdentifierTag(void* payload, | |
1346 int64_t id, | |
1347 const OrthancPluginDicomTag* tag) | |
1348 { | |
1349 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1350 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1351 | |
1352 try | |
1353 { | |
1354 backend->SetIdentifierTag(id, tag->group, tag->element, tag->value); | |
1355 return OrthancPluginErrorCode_Success; | |
1356 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1357 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1358 } |
1359 | |
1360 | |
1361 static OrthancPluginErrorCode SetMetadata(void* payload, | |
1362 int64_t id, | |
1363 int32_t metadata, | |
1364 const char* value) | |
1365 { | |
1366 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1367 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1368 | |
1369 try | |
1370 { | |
1371 backend->SetMetadata(id, metadata, value); | |
1372 return OrthancPluginErrorCode_Success; | |
1373 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1374 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1375 } |
1376 | |
1377 | |
1378 static OrthancPluginErrorCode SetProtectedPatient(void* payload, | |
1379 int64_t id, | |
1380 int32_t isProtected) | |
1381 { | |
1382 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1383 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1384 | |
1385 try | |
1386 { | |
1387 backend->SetProtectedPatient(id, (isProtected != 0)); | |
1388 return OrthancPluginErrorCode_Success; | |
1389 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1390 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1391 } |
1392 | |
1393 | |
1394 static OrthancPluginErrorCode StartTransaction(void* payload) | |
1395 { | |
1396 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1397 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1398 | |
1399 try | |
1400 { | |
1401 backend->StartTransaction(); | |
1402 return OrthancPluginErrorCode_Success; | |
1403 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1404 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1405 } |
1406 | |
1407 | |
1408 static OrthancPluginErrorCode RollbackTransaction(void* payload) | |
1409 { | |
1410 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1411 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1412 | |
1413 try | |
1414 { | |
1415 backend->RollbackTransaction(); | |
1416 return OrthancPluginErrorCode_Success; | |
1417 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1418 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1419 } |
1420 | |
1421 | |
1422 static OrthancPluginErrorCode CommitTransaction(void* payload) | |
1423 { | |
1424 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1425 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1426 | |
1427 try | |
1428 { | |
1429 backend->CommitTransaction(); | |
1430 return OrthancPluginErrorCode_Success; | |
1431 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1432 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1433 } |
1434 | |
1435 | |
1436 static OrthancPluginErrorCode Open(void* payload) | |
1437 { | |
1438 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1439 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1440 | |
1441 try | |
1442 { | |
1443 backend->Open(); | |
1444 return OrthancPluginErrorCode_Success; | |
1445 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1446 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1447 } |
1448 | |
1449 | |
1450 static OrthancPluginErrorCode Close(void* payload) | |
1451 { | |
1452 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
1453 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); | |
1454 | |
1455 try | |
1456 { | |
1457 backend->Close(); | |
1458 return OrthancPluginErrorCode_Success; | |
1459 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1460 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1461 } |
1462 | |
1463 | |
1464 static OrthancPluginErrorCode GetDatabaseVersion(uint32_t* version, | |
1465 void* payload) | |
1466 { | |
1467 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1468 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); |
0 | 1469 |
1470 try | |
1471 { | |
1472 *version = backend->GetDatabaseVersion(); | |
1473 return OrthancPluginErrorCode_Success; | |
1474 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1475 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1476 } |
1477 | |
1478 | |
1479 static OrthancPluginErrorCode UpgradeDatabase(void* payload, | |
1480 uint32_t targetVersion, | |
1481 OrthancPluginStorageArea* storageArea) | |
1482 { | |
1483 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1484 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); |
0 | 1485 |
1486 try | |
1487 { | |
1488 backend->UpgradeDatabase(targetVersion, storageArea); | |
1489 return OrthancPluginErrorCode_Success; | |
1490 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1491 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1492 } |
1493 | |
1494 | |
1495 static OrthancPluginErrorCode ClearMainDicomTags(void* payload, | |
1496 int64_t internalId) | |
1497 { | |
1498 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); | |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1499 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); |
0 | 1500 |
1501 try | |
1502 { | |
1503 backend->ClearMainDicomTags(internalId); | |
1504 return OrthancPluginErrorCode_Success; | |
1505 } | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1506 ORTHANC_PLUGINS_DATABASE_CATCH |
0 | 1507 } |
1508 | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1509 |
78 | 1510 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1511 /* Use GetOutput().AnswerResource() */ |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1512 static OrthancPluginErrorCode LookupResources( |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1513 OrthancPluginDatabaseContext* context, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1514 void* payload, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1515 uint32_t constraintsCount, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1516 const OrthancPluginDatabaseConstraint* constraints, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1517 OrthancPluginResourceType queryLevel, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1518 uint32_t limit, |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1519 uint8_t requestSomeInstance) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1520 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1521 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1522 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_MatchingResource); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1523 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1524 try |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1525 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1526 std::vector<Orthanc::DatabaseConstraint> lookup; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1527 lookup.reserve(constraintsCount); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1528 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1529 for (uint32_t i = 0; i < constraintsCount; i++) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1530 { |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1531 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i])); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1532 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1533 |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1534 backend->LookupResources(lookup, queryLevel, limit, (requestSomeInstance != 0)); |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1535 return OrthancPluginErrorCode_Success; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1536 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1537 ORTHANC_PLUGINS_DATABASE_CATCH |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1538 } |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1539 #endif |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1540 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1541 |
78 | 1542 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1543 static OrthancPluginErrorCode CreateInstance(OrthancPluginCreateInstanceResult* output, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1544 void* payload, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1545 const char* hashPatient, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1546 const char* hashStudy, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1547 const char* hashSeries, |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1548 const char* hashInstance) |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1549 { |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1550 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1551 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1552 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1553 try |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1554 { |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1555 backend->CreateInstance(*output, hashPatient, hashStudy, hashSeries, hashInstance); |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1556 return OrthancPluginErrorCode_Success; |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1557 } |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1558 ORTHANC_PLUGINS_DATABASE_CATCH |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1559 } |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1560 #endif |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1561 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1562 |
78 | 1563 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1564 static OrthancPluginErrorCode SetResourcesContent( |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1565 void* payload, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1566 uint32_t countIdentifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1567 const OrthancPluginResourcesContentTags* identifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1568 uint32_t countMainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1569 const OrthancPluginResourcesContentTags* mainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1570 uint32_t countMetadata, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1571 const OrthancPluginResourcesContentMetadata* metadata) |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1572 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1573 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1574 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1575 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1576 try |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1577 { |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1578 backend->SetResourcesContent(countIdentifierTags, identifierTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1579 countMainDicomTags, mainDicomTags, |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1580 countMetadata, metadata); |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1581 return OrthancPluginErrorCode_Success; |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1582 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1583 ORTHANC_PLUGINS_DATABASE_CATCH |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1584 } |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1585 #endif |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1586 |
0 | 1587 |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1588 |
78 | 1589 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1590 // New primitive since Orthanc 1.5.2 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1591 static OrthancPluginErrorCode GetChildrenMetadata(OrthancPluginDatabaseContext* context, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1592 void* payload, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1593 int64_t resourceId, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1594 int32_t metadata) |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1595 { |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1596 IDatabaseBackend* backend = reinterpret_cast<IDatabaseBackend*>(payload); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1597 backend->GetOutput().SetAllowedAnswers(DatabaseBackendOutput::AllowedAnswers_None); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1598 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1599 try |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1600 { |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1601 std::list<std::string> values; |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1602 backend->GetChildrenMetadata(values, resourceId, metadata); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1603 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1604 for (std::list<std::string>::const_iterator |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1605 it = values.begin(); it != values.end(); ++it) |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1606 { |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1607 OrthancPluginDatabaseAnswerString(backend->GetOutput().context_, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1608 backend->GetOutput().database_, |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1609 it->c_str()); |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1610 } |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1611 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1612 return OrthancPluginErrorCode_Success; |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1613 } |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1614 ORTHANC_PLUGINS_DATABASE_CATCH |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1615 } |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1616 #endif |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1617 |
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1618 |
0 | 1619 public: |
1620 /** | |
1621 * Register a custom database back-end written in C++. | |
1622 * | |
1623 * @param context The Orthanc plugin context, as received by OrthancPluginInitialize(). | |
1624 * @param backend Your custom database engine. | |
1625 **/ | |
1626 | |
1627 static void Register(OrthancPluginContext* context, | |
1628 IDatabaseBackend& backend) | |
1629 { | |
1630 OrthancPluginDatabaseBackend params; | |
1631 memset(¶ms, 0, sizeof(params)); | |
1632 | |
1633 OrthancPluginDatabaseExtensions extensions; | |
1634 memset(&extensions, 0, sizeof(extensions)); | |
1635 | |
1636 params.addAttachment = AddAttachment; | |
1637 params.attachChild = AttachChild; | |
1638 params.clearChanges = ClearChanges; | |
1639 params.clearExportedResources = ClearExportedResources; | |
1640 params.createResource = CreateResource; | |
1641 params.deleteAttachment = DeleteAttachment; | |
1642 params.deleteMetadata = DeleteMetadata; | |
1643 params.deleteResource = DeleteResource; | |
1644 params.getAllPublicIds = GetAllPublicIds; | |
1645 params.getChanges = GetChanges; | |
1646 params.getChildrenInternalId = GetChildrenInternalId; | |
1647 params.getChildrenPublicId = GetChildrenPublicId; | |
1648 params.getExportedResources = GetExportedResources; | |
1649 params.getLastChange = GetLastChange; | |
1650 params.getLastExportedResource = GetLastExportedResource; | |
1651 params.getMainDicomTags = GetMainDicomTags; | |
1652 params.getPublicId = GetPublicId; | |
1653 params.getResourceCount = GetResourceCount; | |
1654 params.getResourceType = GetResourceType; | |
1655 params.getTotalCompressedSize = GetTotalCompressedSize; | |
1656 params.getTotalUncompressedSize = GetTotalUncompressedSize; | |
1657 params.isExistingResource = IsExistingResource; | |
1658 params.isProtectedPatient = IsProtectedPatient; | |
1659 params.listAvailableMetadata = ListAvailableMetadata; | |
1660 params.listAvailableAttachments = ListAvailableAttachments; | |
1661 params.logChange = LogChange; | |
1662 params.logExportedResource = LogExportedResource; | |
1663 params.lookupAttachment = LookupAttachment; | |
1664 params.lookupGlobalProperty = LookupGlobalProperty; | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1665 params.lookupIdentifier = NULL; // Unused starting with Orthanc 0.9.5 (db v6) |
0 | 1666 params.lookupIdentifier2 = NULL; // Unused starting with Orthanc 0.9.5 (db v6) |
1667 params.lookupMetadata = LookupMetadata; | |
1668 params.lookupParent = LookupParent; | |
1669 params.lookupResource = LookupResource; | |
1670 params.selectPatientToRecycle = SelectPatientToRecycle; | |
1671 params.selectPatientToRecycle2 = SelectPatientToRecycle2; | |
1672 params.setGlobalProperty = SetGlobalProperty; | |
1673 params.setMainDicomTag = SetMainDicomTag; | |
1674 params.setIdentifierTag = SetIdentifierTag; | |
1675 params.setMetadata = SetMetadata; | |
1676 params.setProtectedPatient = SetProtectedPatient; | |
1677 params.startTransaction = StartTransaction; | |
1678 params.rollbackTransaction = RollbackTransaction; | |
1679 params.commitTransaction = CommitTransaction; | |
1680 params.open = Open; | |
1681 params.close = Close; | |
1682 | |
1683 extensions.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit; | |
1684 extensions.getDatabaseVersion = GetDatabaseVersion; | |
1685 extensions.upgradeDatabase = UpgradeDatabase; | |
1686 extensions.clearMainDicomTags = ClearMainDicomTags; | |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1687 extensions.getAllInternalIds = GetAllInternalIds; // New in Orthanc 0.9.5 (db v6) |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1688 extensions.lookupIdentifier3 = LookupIdentifier3; // New in Orthanc 0.9.5 (db v6) |
0 | 1689 |
1690 bool performanceWarning = true; | |
1691 | |
1692 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | |
1693 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 4, 0) | |
1694 extensions.lookupIdentifierRange = LookupIdentifierRange; // New in Orthanc 1.4.0 | |
1695 # endif | |
1696 #endif | |
1697 | |
78 | 1698 #if ORTHANC_PLUGINS_HAS_DATABASE_CONSTRAINT == 1 |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1699 // Optimizations brought by Orthanc 1.5.2 |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1700 extensions.lookupResources = LookupResources; // Fast lookup |
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1701 extensions.setResourcesContent = SetResourcesContent; // Fast setting tags/metadata |
76
a1c6238b26f8
new extension implemented for PostgreSQL: GetChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
75
diff
changeset
|
1702 extensions.getChildrenMetadata = GetChildrenMetadata; |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1703 |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1704 if (backend.HasCreateInstance()) |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1705 { |
75
52c70007bb87
new extension implemented for PostgreSQL: SetResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
74
diff
changeset
|
1706 extensions.createInstance = CreateInstance; // Fast creation of resources |
71
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1707 } |
d40c5fecd160
new extension implemented for PostgreSQL: CreateInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
70
diff
changeset
|
1708 |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1709 performanceWarning = false; |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1710 #endif |
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1711 |
0 | 1712 if (performanceWarning) |
1713 { | |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1714 char info[1024]; |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1715 sprintf(info, |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1716 "Performance warning: The database index plugin was compiled " |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1717 "against an old version of the Orthanc SDK (%d.%d.%d): " |
69
19764fc60ade
compatibility with Orthanc SDDK 0.9.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
67
diff
changeset
|
1718 "Consider upgrading to version 1.5.2 of the Orthanc SDK", |
24
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1719 ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER, |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1720 ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER, |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1721 ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER); |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1722 |
17f849b2af34
sharing plugin initialization code
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
16
diff
changeset
|
1723 OrthancPluginLogWarning(context, info); |
0 | 1724 } |
1725 | |
1
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1726 OrthancPluginDatabaseContext* database = |
d17b2631bb67
starting StorageBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
0
diff
changeset
|
1727 OrthancPluginRegisterDatabaseBackendV2(context, ¶ms, &extensions, &backend); |
0 | 1728 if (!context) |
1729 { | |
1730 throw std::runtime_error("Unable to register the database backend"); | |
1731 } | |
1732 | |
1733 backend.RegisterOutput(new DatabaseBackendOutput(context, database)); | |
1734 } | |
1735 }; | |
1736 } |