annotate Plugins/Engine/OrthancPluginDatabase.cpp @ 2474:0c57f40e2fbf

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Feb 2018 11:51:41 +0100
parents 878b59270859
children e583478e0c6c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1762
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
2447
878b59270859 upgrade to year 2018
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2244
diff changeset
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
1625
c17b1142caab reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
34 #include "../../OrthancServer/PrecompiledHeadersServer.h"
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "OrthancPluginDatabase.h"
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
37 #if ORTHANC_ENABLE_PLUGINS != 1
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
38 #error The plugin support is disabled
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
39 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
40
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
41
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include "../../Core/OrthancException.h"
1486
f967bdf8534e refactoring to Logging.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
43 #include "../../Core/Logging.h"
1629
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
44 #include "PluginsEnumerations.h"
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 #include <cassert>
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 namespace Orthanc
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 static FileInfo Convert(const OrthancPluginAttachment& attachment)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return FileInfo(attachment.uuid,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 static_cast<FileContentType>(attachment.contentType),
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 attachment.uncompressedSize,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 attachment.uncompressedHash,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 static_cast<CompressionType>(attachment.compressionType),
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 attachment.compressedSize,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 attachment.compressedHash);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
62 void OrthancPluginDatabase::CheckSuccess(OrthancPluginErrorCode code)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
63 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
64 if (code != OrthancPluginErrorCode_Success)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
65 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
66 errorDictionary_.LogError(code, true);
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
67 throw OrthancException(static_cast<ErrorCode>(code));
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
68 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
69 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
70
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
71
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 void OrthancPluginDatabase::ResetAnswers()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 type_ = _OrthancPluginDatabaseAnswerType_None;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 answerDicomMap_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 answerChanges_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 answerExportedResources_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 answerDone_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 void OrthancPluginDatabase::ForwardAnswers(std::list<int64_t>& target)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 type_ != _OrthancPluginDatabaseAnswerType_Int64)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
88 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 if (type_ == _OrthancPluginDatabaseAnswerType_Int64)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 for (std::list<int64_t>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
96 it = answerInt64_.begin(); it != answerInt64_.end(); ++it)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 target.push_back(*it);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 void OrthancPluginDatabase::ForwardAnswers(std::list<std::string>& target)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 type_ != _OrthancPluginDatabaseAnswerType_String)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
109 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (type_ == _OrthancPluginDatabaseAnswerType_String)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 for (std::list<std::string>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
117 it = answerStrings_.begin(); it != answerStrings_.end(); ++it)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 target.push_back(*it);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 bool OrthancPluginDatabase::ForwardSingleAnswer(std::string& target)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 else if (type_ == _OrthancPluginDatabaseAnswerType_String &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 answerStrings_.size() == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 target = answerStrings_.front();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 return true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
139 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 bool OrthancPluginDatabase::ForwardSingleAnswer(int64_t& target)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 else if (type_ == _OrthancPluginDatabaseAnswerType_Int64 &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 answerInt64_.size() == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 target = answerInt64_.front();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 return true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
158 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
163 OrthancPluginDatabase::OrthancPluginDatabase(SharedLibrary& library,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
164 PluginsErrorDictionary& errorDictionary,
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
165 const OrthancPluginDatabaseBackend& backend,
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
166 const OrthancPluginDatabaseExtensions* extensions,
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
167 size_t extensionsSize,
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
168 void *payload) :
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
169 library_(library),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
170 errorDictionary_(errorDictionary),
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
171 type_(_OrthancPluginDatabaseAnswerType_None),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
172 backend_(backend),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
173 payload_(payload),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
174 listener_(NULL),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
175 answerDicomMap_(NULL),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
176 answerChanges_(NULL),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
177 answerExportedResources_(NULL),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
178 answerDone_(NULL)
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
179 {
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
180 memset(&extensions_, 0, sizeof(extensions_));
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
181
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
182 size_t size = sizeof(extensions_);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
183 if (extensionsSize < size)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
184 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
185 size = extensionsSize; // Not all the extensions are available
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
186 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
187
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
188 memcpy(&extensions_, extensions, size);
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
189 }
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
190
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
191
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 void OrthancPluginDatabase::AddAttachment(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 const FileInfo& attachment)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 OrthancPluginAttachment tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 tmp.uuid = attachment.GetUuid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 tmp.contentType = static_cast<int32_t>(attachment.GetContentType());
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 tmp.uncompressedSize = attachment.GetUncompressedSize();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 tmp.uncompressedHash = attachment.GetUncompressedMD5().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 tmp.compressionType = static_cast<int32_t>(attachment.GetCompressionType());
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 tmp.compressedSize = attachment.GetCompressedSize();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 tmp.compressedHash = attachment.GetCompressedMD5().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
204 CheckSuccess(backend_.addAttachment(payload_, id, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 void OrthancPluginDatabase::AttachChild(int64_t parent,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 int64_t child)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
211 CheckSuccess(backend_.attachChild(payload_, parent, child));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 void OrthancPluginDatabase::ClearChanges()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
217 CheckSuccess(backend_.clearChanges(payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 void OrthancPluginDatabase::ClearExportedResources()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
223 CheckSuccess(backend_.clearExportedResources(payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 int64_t OrthancPluginDatabase::CreateResource(const std::string& publicId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 ResourceType type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 int64_t id;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
231 CheckSuccess(backend_.createResource(&id, payload_, publicId.c_str(), Plugins::Convert(type)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 return id;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 void OrthancPluginDatabase::DeleteAttachment(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 FileContentType attachment)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
239 CheckSuccess(backend_.deleteAttachment(payload_, id, static_cast<int32_t>(attachment)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 void OrthancPluginDatabase::DeleteMetadata(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 MetadataType type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
246 CheckSuccess(backend_.deleteMetadata(payload_, id, static_cast<int32_t>(type)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 void OrthancPluginDatabase::DeleteResource(int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
252 CheckSuccess(backend_.deleteResource(payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 void OrthancPluginDatabase::GetAllMetadata(std::map<MetadataType, std::string>& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 std::list<MetadataType> metadata;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 ListAvailableMetadata(metadata, id);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 for (std::list<MetadataType>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
265 it = metadata.begin(); it != metadata.end(); ++it)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 std::string value;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 if (!LookupMetadata(value, id, *it))
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
270 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 target[*it] = value;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
278 void OrthancPluginDatabase::GetAllInternalIds(std::list<int64_t>& target,
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
279 ResourceType resourceType)
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
280 {
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
281 if (extensions_.getAllInternalIds == NULL)
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
282 {
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
283 LOG(ERROR) << "The database plugin does not implement the GetAllInternalIds primitive";
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
284 throw OrthancException(ErrorCode_DatabasePlugin);
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
285 }
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
286
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
287 ResetAnswers();
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
288 CheckSuccess(extensions_.getAllInternalIds(GetContext(), payload_, Plugins::Convert(resourceType)));
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
289 ForwardAnswers(target);
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
290 }
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
291
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
292
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 void OrthancPluginDatabase::GetAllPublicIds(std::list<std::string>& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 ResourceType resourceType)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
297 CheckSuccess(backend_.getAllPublicIds(GetContext(), payload_, Plugins::Convert(resourceType)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 ForwardAnswers(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
302 void OrthancPluginDatabase::GetAllPublicIds(std::list<std::string>& target,
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
303 ResourceType resourceType,
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
304 size_t since,
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
305 size_t limit)
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
306 {
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
307 if (extensions_.getAllPublicIdsWithLimit != NULL)
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
308 {
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
309 // This extension is available since Orthanc 0.9.4
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
310 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
311 CheckSuccess(extensions_.getAllPublicIdsWithLimit
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
312 (GetContext(), payload_, Plugins::Convert(resourceType), since, limit));
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
313 ForwardAnswers(target);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
314 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
315 else
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
316 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
317 // The extension is not available in the database plugin, use a
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
318 // fallback implementation
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
319 target.clear();
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
320
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
321 if (limit == 0)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
322 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
323 return;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
324 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
325
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
326 std::list<std::string> tmp;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
327 GetAllPublicIds(tmp, resourceType);
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
328
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
329 if (tmp.size() <= since)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
330 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
331 // Not enough results => empty answer
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
332 return;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
333 }
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
334
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
335 std::list<std::string>::iterator current = tmp.begin();
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
336 std::advance(current, since);
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
337
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
338 while (limit > 0 && current != tmp.end())
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
339 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
340 target.push_back(*current);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
341 --limit;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
342 ++current;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
343 }
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
344 }
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
345 }
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
346
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
347
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 void OrthancPluginDatabase::GetChanges(std::list<ServerIndexChange>& target /*out*/,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 bool& done /*out*/,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 int64_t since,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 uint32_t maxResults)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 answerChanges_ = &target;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 answerDone_ = &done;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 done = false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
359 CheckSuccess(backend_.getChanges(GetContext(), payload_, since, maxResults));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 void OrthancPluginDatabase::GetChildrenInternalId(std::list<int64_t>& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
367 CheckSuccess(backend_.getChildrenInternalId(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 ForwardAnswers(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 void OrthancPluginDatabase::GetChildrenPublicId(std::list<std::string>& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
376 CheckSuccess(backend_.getChildrenPublicId(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 ForwardAnswers(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 void OrthancPluginDatabase::GetExportedResources(std::list<ExportedResource>& target /*out*/,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 bool& done /*out*/,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 int64_t since,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 uint32_t maxResults)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 answerExportedResources_ = &target;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 answerDone_ = &done;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 done = false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
391 CheckSuccess(backend_.getExportedResources(GetContext(), payload_, since, maxResults));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 void OrthancPluginDatabase::GetLastChange(std::list<ServerIndexChange>& target /*out*/)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 bool ignored = false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400 answerChanges_ = &target;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 answerDone_ = &ignored;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
403 CheckSuccess(backend_.getLastChange(GetContext(), payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 void OrthancPluginDatabase::GetLastExportedResource(std::list<ExportedResource>& target /*out*/)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 bool ignored = false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 answerExportedResources_ = &target;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 answerDone_ = &ignored;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
415 CheckSuccess(backend_.getLastExportedResource(GetContext(), payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 void OrthancPluginDatabase::GetMainDicomTags(DicomMap& map,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 answerDicomMap_ = &map;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
425 CheckSuccess(backend_.getMainDicomTags(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 std::string OrthancPluginDatabase::GetPublicId(int64_t resourceId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 std::string s;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
434 CheckSuccess(backend_.getPublicId(GetContext(), payload_, resourceId));
1629
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
435
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
436 if (!ForwardSingleAnswer(s))
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
438 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 return s;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 uint64_t OrthancPluginDatabase::GetResourceCount(ResourceType resourceType)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 uint64_t count;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
448 CheckSuccess(backend_.getResourceCount(&count, payload_, Plugins::Convert(resourceType)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449 return count;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 ResourceType OrthancPluginDatabase::GetResourceType(int64_t resourceId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 OrthancPluginResourceType type;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
456 CheckSuccess(backend_.getResourceType(&type, payload_, resourceId));
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
457 return Plugins::Convert(type);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461 uint64_t OrthancPluginDatabase::GetTotalCompressedSize()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 uint64_t size;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
464 CheckSuccess(backend_.getTotalCompressedSize(&size, payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 return size;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 uint64_t OrthancPluginDatabase::GetTotalUncompressedSize()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 uint64_t size;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
472 CheckSuccess(backend_.getTotalUncompressedSize(&size, payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 return size;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 bool OrthancPluginDatabase::IsExistingResource(int64_t internalId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 int32_t existing;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
480 CheckSuccess(backend_.isExistingResource(&existing, payload_, internalId));
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1510
diff changeset
481 return (existing != 0);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485 bool OrthancPluginDatabase::IsProtectedPatient(int64_t internalId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 int32_t isProtected;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
488 CheckSuccess(backend_.isProtectedPatient(&isProtected, payload_, internalId));
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1510
diff changeset
489 return (isProtected != 0);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 void OrthancPluginDatabase::ListAvailableMetadata(std::list<MetadataType>& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
497 CheckSuccess(backend_.listAvailableMetadata(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 type_ != _OrthancPluginDatabaseAnswerType_Int32)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
502 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 if (type_ == _OrthancPluginDatabaseAnswerType_Int32)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 for (std::list<int32_t>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
510 it = answerInt32_.begin(); it != answerInt32_.end(); ++it)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 target.push_back(static_cast<MetadataType>(*it));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 void OrthancPluginDatabase::ListAvailableAttachments(std::list<FileContentType>& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
523 CheckSuccess(backend_.listAvailableAttachments(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 type_ != _OrthancPluginDatabaseAnswerType_Int32)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
528 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 if (type_ == _OrthancPluginDatabaseAnswerType_Int32)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 for (std::list<int32_t>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
536 it = answerInt32_.begin(); it != answerInt32_.end(); ++it)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 target.push_back(static_cast<FileContentType>(*it));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 void OrthancPluginDatabase::LogChange(int64_t internalId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545 const ServerIndexChange& change)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 OrthancPluginChange tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 tmp.seq = change.GetSeq();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 tmp.changeType = static_cast<int32_t>(change.GetChangeType());
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
550 tmp.resourceType = Plugins::Convert(change.GetResourceType());
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 tmp.publicId = change.GetPublicId().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 tmp.date = change.GetDate().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
554 CheckSuccess(backend_.logChange(payload_, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558 void OrthancPluginDatabase::LogExportedResource(const ExportedResource& resource)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 OrthancPluginExportedResource tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 tmp.seq = resource.GetSeq();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
562 tmp.resourceType = Plugins::Convert(resource.GetResourceType());
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 tmp.publicId = resource.GetPublicId().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 tmp.modality = resource.GetModality().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 tmp.date = resource.GetDate().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 tmp.patientId = resource.GetPatientId().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 tmp.studyInstanceUid = resource.GetStudyInstanceUid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 tmp.seriesInstanceUid = resource.GetSeriesInstanceUid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 tmp.sopInstanceUid = resource.GetSopInstanceUid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
571 CheckSuccess(backend_.logExportedResource(payload_, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 bool OrthancPluginDatabase::LookupAttachment(FileInfo& attachment,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 FileContentType contentType)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
581 CheckSuccess(backend_.lookupAttachment
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
582 (GetContext(), payload_, id, static_cast<int32_t>(contentType)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 else if (type_ == _OrthancPluginDatabaseAnswerType_Attachment &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589 answerAttachments_.size() == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 attachment = answerAttachments_.front();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 return true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
596 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 bool OrthancPluginDatabase::LookupGlobalProperty(std::string& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 GlobalProperty property)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
606 CheckSuccess(backend_.lookupGlobalProperty
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
607 (GetContext(), payload_, static_cast<int32_t>(property)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 return ForwardSingleAnswer(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
613 void OrthancPluginDatabase::LookupIdentifier(std::list<int64_t>& result,
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
614 ResourceType level,
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
615 const DicomTag& tag,
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
616 IdentifierConstraintType type,
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
617 const std::string& value)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618 {
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
619 if (extensions_.lookupIdentifier3 == NULL)
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
620 {
1762
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1760
diff changeset
621 LOG(ERROR) << "The database plugin does not implement the LookupIdentifier3 primitive";
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
622 throw OrthancException(ErrorCode_DatabasePlugin);
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
623 }
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 OrthancPluginDicomTag tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 tmp.group = tag.GetGroup();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 tmp.element = tag.GetElement();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 tmp.value = value.c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
630 ResetAnswers();
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
631 CheckSuccess(extensions_.lookupIdentifier3(GetContext(), payload_, Plugins::Convert(level),
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
632 &tmp, Plugins::Convert(type)));
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
633 ForwardAnswers(result);
1729
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1728
diff changeset
634 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1728
diff changeset
635
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1728
diff changeset
636
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 bool OrthancPluginDatabase::LookupMetadata(std::string& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 MetadataType type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
642 CheckSuccess(backend_.lookupMetadata(GetContext(), payload_, id, static_cast<int32_t>(type)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643 return ForwardSingleAnswer(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
645
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647 bool OrthancPluginDatabase::LookupParent(int64_t& parentId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 int64_t resourceId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
651 CheckSuccess(backend_.lookupParent(GetContext(), payload_, resourceId));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 return ForwardSingleAnswer(parentId);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 bool OrthancPluginDatabase::LookupResource(int64_t& id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 ResourceType& type,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 const std::string& publicId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
662 CheckSuccess(backend_.lookupResource(GetContext(), payload_, publicId.c_str()));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 else if (type_ == _OrthancPluginDatabaseAnswerType_Resource &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 answerResources_.size() == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671 id = answerResources_.front().first;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672 type = answerResources_.front().second;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 return true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
677 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 bool OrthancPluginDatabase::SelectPatientToRecycle(int64_t& internalId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
685 CheckSuccess(backend_.selectPatientToRecycle(GetContext(), payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 return ForwardSingleAnswer(internalId);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 bool OrthancPluginDatabase::SelectPatientToRecycle(int64_t& internalId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 int64_t patientIdToAvoid)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
694 CheckSuccess(backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 return ForwardSingleAnswer(internalId);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 void OrthancPluginDatabase::SetGlobalProperty(GlobalProperty property,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700 const std::string& value)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
702 CheckSuccess(backend_.setGlobalProperty
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
703 (payload_, static_cast<int32_t>(property), value.c_str()));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
707 void OrthancPluginDatabase::ClearMainDicomTags(int64_t id)
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
708 {
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
709 if (extensions_.clearMainDicomTags == NULL)
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
710 {
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
711 LOG(ERROR) << "Your custom index plugin does not implement the ClearMainDicomTags() extension";
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
712 throw OrthancException(ErrorCode_DatabasePlugin);
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
713 }
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
714
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
715 CheckSuccess(extensions_.clearMainDicomTags(payload_, id));
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
716 }
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
717
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
718
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 void OrthancPluginDatabase::SetMainDicomTag(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 const DicomTag& tag,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 const std::string& value)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 OrthancPluginDicomTag tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 tmp.group = tag.GetGroup();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 tmp.element = tag.GetElement();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 tmp.value = value.c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
728 CheckSuccess(backend_.setMainDicomTag(payload_, id, &tmp));
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
729 }
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
730
1629
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
731
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
732 void OrthancPluginDatabase::SetIdentifierTag(int64_t id,
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
733 const DicomTag& tag,
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
734 const std::string& value)
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
735 {
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
736 OrthancPluginDicomTag tmp;
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
737 tmp.group = tag.GetGroup();
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
738 tmp.element = tag.GetElement();
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
739 tmp.value = value.c_str();
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
741 CheckSuccess(backend_.setIdentifierTag(payload_, id, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745 void OrthancPluginDatabase::SetMetadata(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 MetadataType type,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 const std::string& value)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
749 CheckSuccess(backend_.setMetadata
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
750 (payload_, id, static_cast<int32_t>(type), value.c_str()));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 void OrthancPluginDatabase::SetProtectedPatient(int64_t internalId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 bool isProtected)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
757 CheckSuccess(backend_.setProtectedPatient(payload_, internalId, isProtected));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 class OrthancPluginDatabase::Transaction : public SQLite::ITransaction
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 private:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 const OrthancPluginDatabaseBackend& backend_;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 void* payload_;
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
766 PluginsErrorDictionary& errorDictionary_;
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
768 void CheckSuccess(OrthancPluginErrorCode code)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
769 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
770 if (code != OrthancPluginErrorCode_Success)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
771 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
772 errorDictionary_.LogError(code, true);
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
773 throw OrthancException(static_cast<ErrorCode>(code));
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
774 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
775 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
776
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 public:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 Transaction(const OrthancPluginDatabaseBackend& backend,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
779 void* payload,
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
780 PluginsErrorDictionary& errorDictionary) :
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 backend_(backend),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
782 payload_(payload),
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
783 errorDictionary_(errorDictionary)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 virtual void Begin()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
789 CheckSuccess(backend_.startTransaction(payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 virtual void Rollback()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
794 CheckSuccess(backend_.rollbackTransaction(payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 virtual void Commit()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
799 CheckSuccess(backend_.commitTransaction(payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 };
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 SQLite::ITransaction* OrthancPluginDatabase::StartTransaction()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 {
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
806 return new Transaction(backend_, payload_, errorDictionary_);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1314
diff changeset
810 static void ProcessEvent(IDatabaseListener& listener,
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 const _OrthancPluginDatabaseAnswer& answer)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 switch (answer.type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 case _OrthancPluginDatabaseAnswerType_DeletedAttachment:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 const OrthancPluginAttachment& attachment =
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 listener.SignalFileDeleted(Convert(attachment));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823 case _OrthancPluginDatabaseAnswerType_RemainingAncestor:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
825 ResourceType type = Plugins::Convert(static_cast<OrthancPluginResourceType>(answer.valueInt32));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 listener.SignalRemainingAncestor(type, answer.valueString);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 case _OrthancPluginDatabaseAnswerType_DeletedResource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
832 ResourceType type = Plugins::Convert(static_cast<OrthancPluginResourceType>(answer.valueInt32));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 ServerIndexChange change(ChangeType_Deleted, type, answer.valueString);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 listener.SignalChange(change);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
838 default:
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
839 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
844 unsigned int OrthancPluginDatabase::GetDatabaseVersion()
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
845 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
846 if (extensions_.getDatabaseVersion != NULL)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
847 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
848 uint32_t version;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
849 CheckSuccess(extensions_.getDatabaseVersion(&version, payload_));
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
850 return version;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
851 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
852 else
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
853 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
854 // Before adding the "GetDatabaseVersion()" extension in plugins
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
855 // (OrthancPostgreSQL <= 1.2), the only supported DB schema was
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
856 // version 5.
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
857 return 5;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
858 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
859 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
860
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
861
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
862 void OrthancPluginDatabase::Upgrade(unsigned int targetVersion,
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
863 IStorageArea& storageArea)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
864 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
865 if (extensions_.upgradeDatabase != NULL)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
866 {
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
867 Transaction transaction(backend_, payload_, errorDictionary_);
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
868 transaction.Begin();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
869
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
870 OrthancPluginErrorCode code = extensions_.upgradeDatabase(
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
871 payload_, targetVersion,
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
872 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea));
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
873
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
874 if (code == OrthancPluginErrorCode_Success)
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
875 {
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
876 transaction.Commit();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
877 }
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
878 else
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
879 {
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
880 transaction.Rollback();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
881 errorDictionary_.LogError(code, true);
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
882 throw OrthancException(static_cast<ErrorCode>(code));
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
883 }
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
884 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
885 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
886
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
887
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
889 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
890 if (answer.type == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
892 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 if (answer.type == _OrthancPluginDatabaseAnswerType_DeletedAttachment ||
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 answer.type == _OrthancPluginDatabaseAnswerType_DeletedResource ||
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 answer.type == _OrthancPluginDatabaseAnswerType_RemainingAncestor)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 assert(listener_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900 ProcessEvent(*listener_, answer);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 return;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906 type_ = answer.type;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 switch (type_)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910 case _OrthancPluginDatabaseAnswerType_Int32:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 answerInt32_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 case _OrthancPluginDatabaseAnswerType_Int64:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 answerInt64_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 case _OrthancPluginDatabaseAnswerType_Resource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 answerResources_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 case _OrthancPluginDatabaseAnswerType_Attachment:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 answerAttachments_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 case _OrthancPluginDatabaseAnswerType_String:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927 answerStrings_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 case _OrthancPluginDatabaseAnswerType_DicomTag:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 assert(answerDicomMap_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
932 answerDicomMap_->Clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 case _OrthancPluginDatabaseAnswerType_Change:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 assert(answerChanges_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 answerChanges_->clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 case _OrthancPluginDatabaseAnswerType_ExportedResource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 assert(answerExportedResources_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 answerExportedResources_->clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 default:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 LOG(ERROR) << "Unhandled type of answer for custom index plugin: " << answer.type;
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
947 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 else if (type_ != answer.type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952 LOG(ERROR) << "Error in the plugin protocol: Cannot change the answer type";
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
953 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 switch (answer.type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 case _OrthancPluginDatabaseAnswerType_Int32:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 answerInt32_.push_back(answer.valueInt32);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 case _OrthancPluginDatabaseAnswerType_Int64:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
966 answerInt64_.push_back(answer.valueInt64);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
967 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
968 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970 case _OrthancPluginDatabaseAnswerType_Resource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
972 OrthancPluginResourceType type = static_cast<OrthancPluginResourceType>(answer.valueInt32);
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
973 answerResources_.push_back(std::make_pair(answer.valueInt64, Plugins::Convert(type)));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977 case _OrthancPluginDatabaseAnswerType_Attachment:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
978 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979 const OrthancPluginAttachment& attachment =
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
980 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 answerAttachments_.push_back(Convert(attachment));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
983 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
984 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
985
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986 case _OrthancPluginDatabaseAnswerType_DicomTag:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988 const OrthancPluginDicomTag& tag = *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 assert(answerDicomMap_ != NULL);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
990 answerDicomMap_->SetValue(tag.group, tag.element, std::string(tag.value), false);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
991 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
993
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994 case _OrthancPluginDatabaseAnswerType_String:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
995 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996 if (answer.valueString == NULL)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
997 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
998 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
999 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1000
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 type_ = _OrthancPluginDatabaseAnswerType_String;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004 answerStrings_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1005 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 else if (type_ != _OrthancPluginDatabaseAnswerType_String)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
1008 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1009 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1010
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1011 answerStrings_.push_back(std::string(answer.valueString));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1012 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1013 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1014
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1015 case _OrthancPluginDatabaseAnswerType_Change:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017 assert(answerDone_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 if (answer.valueUint32 == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1019 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020 *answerDone_ = true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 else if (*answerDone_)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
1024 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 const OrthancPluginChange& change = *reinterpret_cast<const OrthancPluginChange*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029 assert(answerChanges_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 answerChanges_->push_back
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 (ServerIndexChange(change.seq,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 static_cast<ChangeType>(change.changeType),
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1033 Plugins::Convert(change.resourceType),
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 change.publicId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 change.date));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 case _OrthancPluginDatabaseAnswerType_ExportedResource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043 assert(answerDone_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044 if (answer.valueUint32 == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1046 *answerDone_ = true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 else if (*answerDone_)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1049 {
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
1050 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 const OrthancPluginExportedResource& exported =
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 assert(answerExportedResources_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 answerExportedResources_->push_back
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058 (ExportedResource(exported.seq,
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1059 Plugins::Convert(exported.resourceType),
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 exported.publicId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 exported.modality,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 exported.date,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063 exported.patientId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 exported.studyInstanceUid,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 exported.seriesInstanceUid,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 exported.sopInstanceUid));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1070 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 default:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1073 LOG(ERROR) << "Unhandled type of answer for custom index plugin: " << answer.type;
1630
ffd23c0104af "/system" URI gives information about the plugins used for storage area and DB back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1629
diff changeset
1074 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1075 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1076 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1077 }