annotate OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp @ 4589:bec74e29f86b db-changes

attaching the listener to transactions in IDatabaseWrapper
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 12 Mar 2021 15:33:47 +0100
parents 9224e107d613
children ff8170d17d90
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
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4271
diff changeset
5 * Copyright (C) 2017-2021 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
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
34 #include "../../Sources/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
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
42 #include "../../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
43 #include "../../../OrthancFramework/Sources/OrthancException.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 {
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
50 class OrthancPluginDatabase::Transaction : public IDatabaseWrapper::ITransaction
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
51 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
52 private:
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
53 OrthancPluginDatabase& that_;
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
54
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
55 void CheckSuccess(OrthancPluginErrorCode code) const
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
56 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
57 if (code != OrthancPluginErrorCode_Success)
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
58 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
59 that_.errorDictionary_.LogError(code, true);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
60 throw OrthancException(static_cast<ErrorCode>(code));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
61 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
62 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
63
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
64 public:
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
65 explicit Transaction(OrthancPluginDatabase& that,
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
66 IDatabaseListener& listener) :
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
67 that_(that)
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
68 {
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
69 assert(that_.listener_ == NULL);
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
70 that_.listener_ = &listener; // TODO - STORE IN TRANSACTION
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
71 }
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
72
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
73 virtual ~Transaction()
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
74 {
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
75 assert(that_.listener_ != NULL);
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
76 that_.listener_ = NULL; // TODO - STORE IN TRANSACTION
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
77 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
78
4556
2a0f8031fb93 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
79 void Begin()
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
80 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
81 CheckSuccess(that_.backend_.startTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
82 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
83
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
84 virtual void Rollback() ORTHANC_OVERRIDE
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
85 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
86 CheckSuccess(that_.backend_.rollbackTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
87 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
88
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
89 virtual void Commit(int64_t diskSizeDelta) ORTHANC_OVERRIDE
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
90 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
91 if (that_.fastGetTotalSize_)
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
92 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
93 CheckSuccess(that_.backend_.commitTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
94 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
95 else
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
96 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
97 if (static_cast<int64_t>(that_.currentDiskSize_) + diskSizeDelta < 0)
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
98 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
99 throw OrthancException(ErrorCode_DatabasePlugin);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
100 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
101
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
102 uint64_t newDiskSize = (that_.currentDiskSize_ + diskSizeDelta);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
103
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
104 assert(newDiskSize == that_.GetTotalCompressedSize());
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
105
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
106 CheckSuccess(that_.backend_.commitTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
107
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
108 // The transaction has succeeded, we can commit the new disk size
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
109 that_.currentDiskSize_ = newDiskSize;
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
110 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
111 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
112 };
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
113
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
114
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 static FileInfo Convert(const OrthancPluginAttachment& attachment)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 return FileInfo(attachment.uuid,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 static_cast<FileContentType>(attachment.contentType),
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 attachment.uncompressedSize,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 attachment.uncompressedHash,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 static_cast<CompressionType>(attachment.compressionType),
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 attachment.compressedSize,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 attachment.compressedHash);
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
127 void OrthancPluginDatabase::CheckSuccess(OrthancPluginErrorCode code)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
128 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
129 if (code != OrthancPluginErrorCode_Success)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
130 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
131 errorDictionary_.LogError(code, true);
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
132 throw OrthancException(static_cast<ErrorCode>(code));
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
133 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
134 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
135
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
136
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 void OrthancPluginDatabase::ResetAnswers()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 type_ = _OrthancPluginDatabaseAnswerType_None;
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 answerDicomMap_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 answerChanges_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 answerExportedResources_ = NULL;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 answerDone_ = NULL;
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
145 answerMatchingResources_ = NULL;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
146 answerMatchingInstances_ = NULL;
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
147 answerMetadata_ = NULL;
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 }
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 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
152 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 type_ != _OrthancPluginDatabaseAnswerType_Int64)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 {
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
156 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 target.clear();
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 if (type_ == _OrthancPluginDatabaseAnswerType_Int64)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 for (std::list<int64_t>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
164 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
165 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 target.push_back(*it);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 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
173 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 type_ != _OrthancPluginDatabaseAnswerType_String)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 {
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
177 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 if (type_ == _OrthancPluginDatabaseAnswerType_String)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 for (std::list<std::string>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
185 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
186 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 target.push_back(*it);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 bool OrthancPluginDatabase::ForwardSingleAnswer(std::string& target)
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 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 else if (type_ == _OrthancPluginDatabaseAnswerType_String &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 answerStrings_.size() == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 target = answerStrings_.front();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 return true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 {
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
207 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 bool OrthancPluginDatabase::ForwardSingleAnswer(int64_t& target)
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 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 else if (type_ == _OrthancPluginDatabaseAnswerType_Int64 &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 answerInt64_.size() == 1)
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 target = answerInt64_.front();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 return true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 {
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
226 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 }
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
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
231 OrthancPluginDatabase::OrthancPluginDatabase(SharedLibrary& library,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
232 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
233 const OrthancPluginDatabaseBackend& backend,
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
234 const OrthancPluginDatabaseExtensions* extensions,
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
235 size_t extensionsSize,
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
236 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
237 library_(library),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
238 errorDictionary_(errorDictionary),
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
239 backend_(backend),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
240 payload_(payload),
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
241 listener_(NULL),
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
242 fastGetTotalSize_(false),
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
243 currentDiskSize_(0),
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
244 answerDoneIgnored_(false)
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
245 {
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
246 static const char* const MISSING = " Missing extension in database index plugin: ";
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
247
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
248 ResetAnswers();
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
249
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
250 memset(&extensions_, 0, sizeof(extensions_));
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
251
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
252 size_t size = sizeof(extensions_);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
253 if (extensionsSize < size)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
254 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
255 size = extensionsSize; // Not all the extensions are available
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
256 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
257
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
258 memcpy(&extensions_, extensions, size);
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
259
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
260 bool isOptimal = true;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
261
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
262 if (extensions_.lookupResources == NULL)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
263 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
264 CLOG(INFO, PLUGINS) << MISSING << "LookupIdentifierRange()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
265 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
266 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
267
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
268 if (extensions_.createInstance == NULL)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
269 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
270 CLOG(INFO, PLUGINS) << MISSING << "CreateInstance()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
271 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
272 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
273
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
274 if (extensions_.setResourcesContent == NULL)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
275 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
276 CLOG(INFO, PLUGINS) << MISSING << "SetResourcesContent()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
277 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
278 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
279
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
280 if (extensions_.getChildrenMetadata == NULL)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
281 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
282 CLOG(INFO, PLUGINS) << MISSING << "GetChildrenMetadata()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
283 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
284 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
285
3190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
286 if (extensions_.getAllMetadata == NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
287 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
288 CLOG(INFO, PLUGINS) << MISSING << "GetAllMetadata()";
3190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
289 isOptimal = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
290 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
291
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
292 if (extensions_.lookupResourceAndParent == NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
293 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
294 CLOG(INFO, PLUGINS) << MISSING << "LookupResourceAndParent()";
3190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
295 isOptimal = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
296 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
297
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
298 if (isOptimal)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
299 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
300 CLOG(INFO, PLUGINS) << "The performance of the database index plugin "
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
301 << "is optimal for this version of Orthanc";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
302 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
303 else
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
304 {
3124
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
305 LOG(WARNING) << "Performance warning in the database index: "
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
306 << "Some extensions are missing in the plugin";
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
307 }
3105
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
308
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
309 if (extensions_.getLastChangeIndex == NULL)
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
310 {
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
311 LOG(WARNING) << "The database extension GetLastChangeIndex() is missing";
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
312 }
3124
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
313
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
314 if (extensions_.tagMostRecentPatient == NULL)
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
315 {
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
316 LOG(WARNING) << "The database extension TagMostRecentPatient() is missing "
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
317 << "(affected by issue 58)";
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
318 }
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
319 }
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
320
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
321
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
322 namespace
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
323 {
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
324 class VoidListener : public IDatabaseListener
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
325 {
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
326 public:
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
327 virtual void SignalRemainingAncestor(ResourceType parentType,
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
328 const std::string& publicId)
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
329 {
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
330 throw OrthancException(ErrorCode_InternalError); // Should be read-only transaction
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
331 }
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
332
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
333 virtual void SignalAttachmentDeleted(const FileInfo& info)
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
334 {
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
335 throw OrthancException(ErrorCode_InternalError); // Should be read-only transaction
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
336 }
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
337
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
338 virtual void SignalResourceDeleted(ResourceType type,
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
339 const std::string& publicId)
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
340 {
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
341 throw OrthancException(ErrorCode_InternalError); // Should be read-only transaction
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
342 }
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
343 };
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
344 }
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
345
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
346
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
347 void OrthancPluginDatabase::Open()
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
348 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
349 CheckSuccess(backend_.open(payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
350
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
351 VoidListener listener;
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
352
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
353 {
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
354 Transaction transaction(*this, listener);
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
355 transaction.Begin();
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
356
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
357 std::string tmp;
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
358 fastGetTotalSize_ =
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
359 (LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast) &&
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
360 tmp == "1");
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
361
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
362 if (fastGetTotalSize_)
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
363 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
364 currentDiskSize_ = 0; // Unused
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
365 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
366 else
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
367 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
368 // This is the case of database plugins using Orthanc SDK <= 1.5.2
3020
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
369 LOG(WARNING) << "Your database index plugin is not compatible with multiple Orthanc writers";
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
370 currentDiskSize_ = GetTotalCompressedSize();
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
371 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
372
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
373 transaction.Commit(0);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
374 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
375 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
376
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
377
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 void OrthancPluginDatabase::AddAttachment(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379 const FileInfo& attachment)
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 OrthancPluginAttachment tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 tmp.uuid = attachment.GetUuid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 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
384 tmp.uncompressedSize = attachment.GetUncompressedSize();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 tmp.uncompressedHash = attachment.GetUncompressedMD5().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 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
387 tmp.compressedSize = attachment.GetCompressedSize();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 tmp.compressedHash = attachment.GetCompressedMD5().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
390 CheckSuccess(backend_.addAttachment(payload_, id, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 }
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 void OrthancPluginDatabase::AttachChild(int64_t parent,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 int64_t child)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
397 CheckSuccess(backend_.attachChild(payload_, parent, child));
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401 void OrthancPluginDatabase::ClearChanges()
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_.clearChanges(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::ClearExportedResources()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
409 CheckSuccess(backend_.clearExportedResources(payload_));
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 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
414 ResourceType type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 int64_t id;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
417 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
418 return id;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420
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 void OrthancPluginDatabase::DeleteAttachment(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 FileContentType attachment)
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_.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
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 void OrthancPluginDatabase::DeleteMetadata(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 MetadataType type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
432 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
433 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 void OrthancPluginDatabase::DeleteResource(int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
438 CheckSuccess(backend_.deleteResource(payload_, id));
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 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
443 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 {
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
445 if (extensions_.getAllMetadata == NULL)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
446 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
447 // Fallback implementation if extension is missing
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
448 target.clear();
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
450 ResetAnswers();
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
451 CheckSuccess(backend_.listAvailableMetadata(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
453 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
454 type_ != _OrthancPluginDatabaseAnswerType_Int32)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
455 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
456 throw OrthancException(ErrorCode_DatabasePlugin);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
457 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
458
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
459 target.clear();
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
460
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
461 if (type_ == _OrthancPluginDatabaseAnswerType_Int32)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462 {
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
463 for (std::list<int32_t>::const_iterator
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
464 it = answerInt32_.begin(); it != answerInt32_.end(); ++it)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
465 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
466 MetadataType type = static_cast<MetadataType>(*it);
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
467
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
468 std::string value;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
469 if (LookupMetadata(value, id, type))
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
470 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
471 target[type] = value;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
472 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
473 }
1309
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 }
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
476 else
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
477 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
478 ResetAnswers();
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
479
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
480 answerMetadata_ = &target;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
481 target.clear();
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
482
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
483 CheckSuccess(extensions_.getAllMetadata(GetContext(), payload_, id));
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
484
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
485 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
486 type_ != _OrthancPluginDatabaseAnswerType_Metadata)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
487 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
488 throw OrthancException(ErrorCode_DatabasePlugin);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
489 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
490 }
1309
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
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
494 void OrthancPluginDatabase::GetAllInternalIds(std::list<int64_t>& target,
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
495 ResourceType resourceType)
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
496 {
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
497 if (extensions_.getAllInternalIds == NULL)
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
498 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
499 throw OrthancException(ErrorCode_DatabasePlugin,
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
500 "The database plugin does not implement the mandatory GetAllInternalIds() extension");
1760
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
501 }
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
502
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
503 ResetAnswers();
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
504 CheckSuccess(extensions_.getAllInternalIds(GetContext(), payload_, Plugins::Convert(resourceType)));
51db4a25a741 LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1750
diff changeset
505 ForwardAnswers(target);
1750
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
506 }
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
507
55d52567bebb LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1746
diff changeset
508
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 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
510 ResourceType resourceType)
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 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
513 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
514 ForwardAnswers(target);
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
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
518 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
519 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
520 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
521 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
522 {
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
523 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
524 {
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
525 // 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
526 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
527 CheckSuccess(extensions_.getAllPublicIdsWithLimit
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
528 (GetContext(), payload_, Plugins::Convert(resourceType), since, limit));
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
529 ForwardAnswers(target);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
530 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
531 else
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
532 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
533 // 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
534 // fallback implementation
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
535 target.clear();
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
536
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
537 if (limit == 0)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
538 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
539 return;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
540 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
541
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
542 std::list<std::string> tmp;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
543 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
544
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
545 if (tmp.size() <= since)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
546 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
547 // Not enough results => empty answer
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
548 return;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
549 }
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
550
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
551 std::list<std::string>::iterator current = tmp.begin();
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
552 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
553
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
554 while (limit > 0 && current != tmp.end())
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
555 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
556 target.push_back(*current);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
557 --limit;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
558 ++current;
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
559 }
1509
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
560 }
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
561 }
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
562
0586ed8897f1 limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1486
diff changeset
563
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 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
566 bool& done /*out*/,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 int64_t since,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 uint32_t maxResults)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 answerChanges_ = &target;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 answerDone_ = &done;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 done = false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
575 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
576 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577
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 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
580 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
583 CheckSuccess(backend_.getChildrenInternalId(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584 ForwardAnswers(target);
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
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 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
589 int64_t id)
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 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
592 CheckSuccess(backend_.getChildrenPublicId(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593 ForwardAnswers(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 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
598 bool& done /*out*/,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599 int64_t since,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 uint32_t maxResults)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603 answerExportedResources_ = &target;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 answerDone_ = &done;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 done = false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
607 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
608 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609
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 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
612 {
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
613 answerDoneIgnored_ = false;
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 answerChanges_ = &target;
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
617 answerDone_ = &answerDoneIgnored_;
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
619 CheckSuccess(backend_.getLastChange(GetContext(), payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 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
624 {
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
625 answerDoneIgnored_ = false;
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 answerExportedResources_ = &target;
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
629 answerDone_ = &answerDoneIgnored_;
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
631 CheckSuccess(backend_.getLastExportedResource(GetContext(), payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635 void OrthancPluginDatabase::GetMainDicomTags(DicomMap& map,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 answerDicomMap_ = &map;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
641 CheckSuccess(backend_.getMainDicomTags(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
643
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 std::string OrthancPluginDatabase::GetPublicId(int64_t resourceId)
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 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 std::string s;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
650 CheckSuccess(backend_.getPublicId(GetContext(), payload_, resourceId));
1629
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
651
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
652 if (!ForwardSingleAnswer(s))
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 {
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
654 throw OrthancException(ErrorCode_DatabasePlugin);
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 return s;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 }
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 uint64_t OrthancPluginDatabase::GetResourceCount(ResourceType resourceType)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 uint64_t count;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
664 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
665 return count;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666 }
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 ResourceType OrthancPluginDatabase::GetResourceType(int64_t resourceId)
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 OrthancPluginResourceType type;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
672 CheckSuccess(backend_.getResourceType(&type, payload_, resourceId));
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
673 return Plugins::Convert(type);
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 uint64_t OrthancPluginDatabase::GetTotalCompressedSize()
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 uint64_t size;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
680 CheckSuccess(backend_.getTotalCompressedSize(&size, payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681 return size;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 }
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 uint64_t OrthancPluginDatabase::GetTotalUncompressedSize()
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 uint64_t size;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
688 CheckSuccess(backend_.getTotalUncompressedSize(&size, payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 return size;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691
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 bool OrthancPluginDatabase::IsExistingResource(int64_t internalId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 int32_t existing;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
696 CheckSuccess(backend_.isExistingResource(&existing, payload_, internalId));
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1510
diff changeset
697 return (existing != 0);
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701 bool OrthancPluginDatabase::IsProtectedPatient(int64_t internalId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703 int32_t isProtected;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
704 CheckSuccess(backend_.isProtectedPatient(&isProtected, payload_, internalId));
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1510
diff changeset
705 return (isProtected != 0);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
709 void OrthancPluginDatabase::ListAvailableAttachments(std::set<FileContentType>& target,
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 int64_t id)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
714 CheckSuccess(backend_.listAvailableAttachments(GetContext(), payload_, id));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 type_ != _OrthancPluginDatabaseAnswerType_Int32)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 {
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
719 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 target.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724 if (type_ == _OrthancPluginDatabaseAnswerType_Int32)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 for (std::list<int32_t>::const_iterator
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
727 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
728 {
4514
5b929e6b3c36 removal of "dicom-as-json" attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
729 target.insert(static_cast<FileContentType>(*it));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735 void OrthancPluginDatabase::LogChange(int64_t internalId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 const ServerIndexChange& change)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 OrthancPluginChange tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 tmp.seq = change.GetSeq();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 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
741 tmp.resourceType = Plugins::Convert(change.GetResourceType());
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 tmp.publicId = change.GetPublicId().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 tmp.date = change.GetDate().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
745 CheckSuccess(backend_.logChange(payload_, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 void OrthancPluginDatabase::LogExportedResource(const ExportedResource& resource)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 OrthancPluginExportedResource tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 tmp.seq = resource.GetSeq();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
753 tmp.resourceType = Plugins::Convert(resource.GetResourceType());
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 tmp.publicId = resource.GetPublicId().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 tmp.modality = resource.GetModality().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 tmp.date = resource.GetDate().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 tmp.patientId = resource.GetPatientId().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 tmp.studyInstanceUid = resource.GetStudyInstanceUid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 tmp.seriesInstanceUid = resource.GetSeriesInstanceUid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 tmp.sopInstanceUid = resource.GetSopInstanceUid().c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
762 CheckSuccess(backend_.logExportedResource(payload_, &tmp));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766 bool OrthancPluginDatabase::LookupAttachment(FileInfo& attachment,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767 int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 FileContentType contentType)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
772 CheckSuccess(backend_.lookupAttachment
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
773 (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
774
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 else if (type_ == _OrthancPluginDatabaseAnswerType_Attachment &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 answerAttachments_.size() == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 attachment = answerAttachments_.front();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 return true;
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 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786 {
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
787 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 }
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 bool OrthancPluginDatabase::LookupGlobalProperty(std::string& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 GlobalProperty property)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
797 CheckSuccess(backend_.lookupGlobalProperty
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
798 (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
799
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 return ForwardSingleAnswer(target);
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 bool OrthancPluginDatabase::LookupMetadata(std::string& target,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 MetadataType type)
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 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
809 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
810 return ForwardSingleAnswer(target);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 }
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 bool OrthancPluginDatabase::LookupParent(int64_t& parentId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 int64_t resourceId)
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 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
818 CheckSuccess(backend_.lookupParent(GetContext(), payload_, resourceId));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 return ForwardSingleAnswer(parentId);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 }
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 bool OrthancPluginDatabase::LookupResource(int64_t& id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 ResourceType& type,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 const std::string& publicId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
826 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
827 ResetAnswers();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
829 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
830
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 return false;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 else if (type_ == _OrthancPluginDatabaseAnswerType_Resource &&
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 answerResources_.size() == 1)
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 id = answerResources_.front().first;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
839 type = answerResources_.front().second;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
840 return true;
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 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 {
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
844 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849 bool OrthancPluginDatabase::SelectPatientToRecycle(int64_t& internalId)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
852 CheckSuccess(backend_.selectPatientToRecycle(GetContext(), payload_));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853 return ForwardSingleAnswer(internalId);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 bool OrthancPluginDatabase::SelectPatientToRecycle(int64_t& internalId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 int64_t patientIdToAvoid)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 ResetAnswers();
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
861 CheckSuccess(backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 return ForwardSingleAnswer(internalId);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 void OrthancPluginDatabase::SetGlobalProperty(GlobalProperty property,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 const std::string& value)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
869 CheckSuccess(backend_.setGlobalProperty
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
870 (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
871 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
873
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
874 void OrthancPluginDatabase::ClearMainDicomTags(int64_t id)
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
875 {
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
876 if (extensions_.clearMainDicomTags == NULL)
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
877 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
878 throw OrthancException(ErrorCode_DatabasePlugin,
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
879 "Your custom index plugin does not implement the mandatory ClearMainDicomTags() extension");
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
880 }
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
881
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
882 CheckSuccess(extensions_.clearMainDicomTags(payload_, id));
1668
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
883 }
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
884
de1413733c97 reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1651
diff changeset
885
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
886 void OrthancPluginDatabase::SetMainDicomTag(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
887 const DicomTag& tag,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
888 const std::string& value)
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 OrthancPluginDicomTag tmp;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
891 tmp.group = tag.GetGroup();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892 tmp.element = tag.GetElement();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893 tmp.value = value.c_str();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
895 CheckSuccess(backend_.setMainDicomTag(payload_, id, &tmp));
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
896 }
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
897
1629
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
898
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
899 void OrthancPluginDatabase::SetIdentifierTag(int64_t id,
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
900 const DicomTag& tag,
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
901 const std::string& value)
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
902 {
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
903 OrthancPluginDicomTag tmp;
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
904 tmp.group = tag.GetGroup();
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
905 tmp.element = tag.GetElement();
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
906 tmp.value = value.c_str();
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907
1713
4db9200c7f46 SetIdentifierTag
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1711
diff changeset
908 CheckSuccess(backend_.setIdentifierTag(payload_, id, &tmp));
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 void OrthancPluginDatabase::SetMetadata(int64_t id,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 MetadataType type,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 const std::string& value)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
916 CheckSuccess(backend_.setMetadata
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
917 (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
918 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921 void OrthancPluginDatabase::SetProtectedPatient(int64_t internalId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 bool isProtected)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
924 CheckSuccess(backend_.setProtectedPatient(payload_, internalId, isProtected));
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
928 IDatabaseWrapper::ITransaction* OrthancPluginDatabase::StartTransaction(TransactionType type,
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
929 IDatabaseListener& listener)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 {
4570
648defffc8cc new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4556
diff changeset
931 // TODO - Take advantage of "type"
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
932
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
933 std::unique_ptr<Transaction> transaction(new Transaction(*this, listener));
4556
2a0f8031fb93 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
934 transaction->Begin();
2a0f8031fb93 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
935 return transaction.release();
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938
1432
0ac74fa21db8 rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1314
diff changeset
939 static void ProcessEvent(IDatabaseListener& listener,
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 const _OrthancPluginDatabaseAnswer& answer)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 switch (answer.type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944 case _OrthancPluginDatabaseAnswerType_DeletedAttachment:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 const OrthancPluginAttachment& attachment =
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric);
4571
9224e107d613 simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4570
diff changeset
948 listener.SignalAttachmentDeleted(Convert(attachment));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 }
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 case _OrthancPluginDatabaseAnswerType_RemainingAncestor:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
954 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
955 listener.SignalRemainingAncestor(type, answer.valueString);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 break;
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 case _OrthancPluginDatabaseAnswerType_DeletedResource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 {
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
961 ResourceType type = Plugins::Convert(static_cast<OrthancPluginResourceType>(answer.valueInt32));
4571
9224e107d613 simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4570
diff changeset
962 listener.SignalResourceDeleted(type, answer.valueString);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 }
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 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
967 throw OrthancException(ErrorCode_DatabasePlugin);
1309
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
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
972 unsigned int OrthancPluginDatabase::GetDatabaseVersion()
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
973 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
974 if (extensions_.getDatabaseVersion != NULL)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
975 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
976 uint32_t version;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
977 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
978 return version;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
979 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
980 else
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
981 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
982 // 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
983 // (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
984 // version 5.
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
985 return 5;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
986 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
987 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
988
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
989
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
990 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
991 IStorageArea& storageArea)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
992 {
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
993 VoidListener listener;
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
994
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
995 if (extensions_.upgradeDatabase != NULL)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
996 {
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
997 Transaction transaction(*this, listener);
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
998 transaction.Begin();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
999
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1000 OrthancPluginErrorCode code = extensions_.upgradeDatabase(
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1001 payload_, targetVersion,
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1002 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea));
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1003
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1004 if (code == OrthancPluginErrorCode_Success)
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1005 {
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1006 transaction.Commit(0);
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1007 }
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1008 else
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1009 {
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1010 transaction.Rollback();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1011 errorDictionary_.LogError(code, true);
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1012 throw OrthancException(static_cast<ErrorCode>(code));
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1013 }
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1014 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1015 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1016
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1017
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer)
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 if (answer.type == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 {
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
1022 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 if (answer.type == _OrthancPluginDatabaseAnswerType_DeletedAttachment ||
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 answer.type == _OrthancPluginDatabaseAnswerType_DeletedResource ||
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027 answer.type == _OrthancPluginDatabaseAnswerType_RemainingAncestor)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029 assert(listener_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 ProcessEvent(*listener_, answer);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 return;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 type_ = answer.type;
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 switch (type_)
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 case _OrthancPluginDatabaseAnswerType_Int32:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 answerInt32_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044 case _OrthancPluginDatabaseAnswerType_Int64:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045 answerInt64_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1046 break;
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 case _OrthancPluginDatabaseAnswerType_Resource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1049 answerResources_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1050 break;
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 case _OrthancPluginDatabaseAnswerType_Attachment:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 answerAttachments_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 case _OrthancPluginDatabaseAnswerType_String:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057 answerStrings_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 case _OrthancPluginDatabaseAnswerType_DicomTag:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 assert(answerDicomMap_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 answerDicomMap_->Clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 case _OrthancPluginDatabaseAnswerType_Change:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 assert(answerChanges_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 answerChanges_->clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1070 case _OrthancPluginDatabaseAnswerType_ExportedResource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071 assert(answerExportedResources_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 answerExportedResources_->clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1073 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1075 case _OrthancPluginDatabaseAnswerType_MatchingResource:
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1076 assert(answerMatchingResources_ != NULL);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1077 answerMatchingResources_->clear();
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1078
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1079 if (answerMatchingInstances_ != NULL)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1080 {
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1081 answerMatchingInstances_->clear();
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1082 }
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1083
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1084 break;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1085
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1086 case _OrthancPluginDatabaseAnswerType_Metadata:
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1087 assert(answerMetadata_ != NULL);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1088 answerMetadata_->clear();
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1089 break;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1090
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 default:
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1092 throw OrthancException(ErrorCode_DatabasePlugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1093 "Unhandled type of answer for custom index plugin: " +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1094 boost::lexical_cast<std::string>(answer.type));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1097 else if (type_ != answer.type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1098 {
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1099 throw OrthancException(ErrorCode_DatabasePlugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1100 "Error in the plugin protocol: Cannot change the answer type");
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1101 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1102
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1103 switch (answer.type)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1104 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1105 case _OrthancPluginDatabaseAnswerType_Int32:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107 answerInt32_.push_back(answer.valueInt32);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1111 case _OrthancPluginDatabaseAnswerType_Int64:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1112 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113 answerInt64_.push_back(answer.valueInt64);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1114 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1115 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1116
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117 case _OrthancPluginDatabaseAnswerType_Resource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1118 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1119 OrthancPluginResourceType type = static_cast<OrthancPluginResourceType>(answer.valueInt32);
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1120 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
1121 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1122 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1123
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1124 case _OrthancPluginDatabaseAnswerType_Attachment:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1125 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1126 const OrthancPluginAttachment& attachment =
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1127 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1128
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1129 answerAttachments_.push_back(Convert(attachment));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1130 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1131 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1132
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1133 case _OrthancPluginDatabaseAnswerType_DicomTag:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1134 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1135 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
1136 assert(answerDicomMap_ != NULL);
2007
655489d9165d DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1900
diff changeset
1137 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
1138 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1139 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1140
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1141 case _OrthancPluginDatabaseAnswerType_String:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1142 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1143 if (answer.valueString == NULL)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1144 {
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
1145 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1146 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1147
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1148 if (type_ == _OrthancPluginDatabaseAnswerType_None)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1149 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1150 type_ = _OrthancPluginDatabaseAnswerType_String;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1151 answerStrings_.clear();
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1152 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1153 else if (type_ != _OrthancPluginDatabaseAnswerType_String)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1154 {
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
1155 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1156 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1157
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1158 answerStrings_.push_back(std::string(answer.valueString));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1159 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1160 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1161
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1162 case _OrthancPluginDatabaseAnswerType_Change:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1163 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1164 assert(answerDone_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1165 if (answer.valueUint32 == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1166 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1167 *answerDone_ = true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1168 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 else if (*answerDone_)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 {
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
1171 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174 {
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3076
diff changeset
1175 const OrthancPluginChange& change =
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3076
diff changeset
1176 *reinterpret_cast<const OrthancPluginChange*>(answer.valueGeneric);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1177 assert(answerChanges_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 answerChanges_->push_back
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179 (ServerIndexChange(change.seq,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1180 static_cast<ChangeType>(change.changeType),
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1181 Plugins::Convert(change.resourceType),
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1182 change.publicId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1183 change.date));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1184 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1185
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1186 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1187 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1188
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1189 case _OrthancPluginDatabaseAnswerType_ExportedResource:
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1190 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1191 assert(answerDone_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1192 if (answer.valueUint32 == 1)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1194 *answerDone_ = true;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1195 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1196 else if (*answerDone_)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1197 {
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
1198 throw OrthancException(ErrorCode_DatabasePlugin);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1199 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1200 else
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1201 {
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1202 const OrthancPluginExportedResource& exported =
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1203 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1204 assert(answerExportedResources_ != NULL);
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1205 answerExportedResources_->push_back
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1206 (ExportedResource(exported.seq,
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1207 Plugins::Convert(exported.resourceType),
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1208 exported.publicId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 exported.modality,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210 exported.date,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 exported.patientId,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 exported.studyInstanceUid,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1213 exported.seriesInstanceUid,
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1214 exported.sopInstanceUid));
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1215 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1216
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217 break;
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1218 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1219
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1220 case _OrthancPluginDatabaseAnswerType_MatchingResource:
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1221 {
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1222 const OrthancPluginMatchingResource& match =
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1223 *reinterpret_cast<const OrthancPluginMatchingResource*>(answer.valueGeneric);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1224
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1225 if (match.resourceId == NULL)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1226 {
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1227 throw OrthancException(ErrorCode_DatabasePlugin);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1228 }
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1229
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1230 assert(answerMatchingResources_ != NULL);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1231 answerMatchingResources_->push_back(match.resourceId);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1232
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1233 if (answerMatchingInstances_ != NULL)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1234 {
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1235 if (match.someInstanceId == NULL)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1236 {
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1237 throw OrthancException(ErrorCode_DatabasePlugin);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1238 }
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1239
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1240 answerMatchingInstances_->push_back(match.someInstanceId);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1241 }
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1242
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1243 break;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1244 }
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1245
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1246 case _OrthancPluginDatabaseAnswerType_Metadata:
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1247 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1248 const OrthancPluginResourcesContentMetadata& metadata =
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1249 *reinterpret_cast<const OrthancPluginResourcesContentMetadata*>(answer.valueGeneric);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1250
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1251 MetadataType type = static_cast<MetadataType>(metadata.metadata);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1252
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1253 if (metadata.value == NULL)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1254 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1255 throw OrthancException(ErrorCode_DatabasePlugin);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1256 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1257
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1258 assert(answerMetadata_ != NULL &&
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1259 answerMetadata_->find(type) == answerMetadata_->end());
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1260 (*answerMetadata_) [type] = metadata.value;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1261 break;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1262 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1263
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1264 default:
2956
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1265 throw OrthancException(ErrorCode_DatabasePlugin,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1266 "Unhandled type of answer for custom index plugin: " +
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2697
diff changeset
1267 boost::lexical_cast<std::string>(answer.type));
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1268 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1269 }
3020
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1270
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1271
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1272 bool OrthancPluginDatabase::IsDiskSizeAbove(uint64_t threshold)
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1273 {
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1274 if (fastGetTotalSize_)
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1275 {
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1276 return GetTotalCompressedSize() > threshold;
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1277 }
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1278 else
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1279 {
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1280 assert(GetTotalCompressedSize() == currentDiskSize_);
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1281 return currentDiskSize_ > threshold;
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1282 }
d207f6ac1f86 tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3019
diff changeset
1283 }
3025
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3020
diff changeset
1284
039a9d262d64 preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3020
diff changeset
1285
3075
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1286 void OrthancPluginDatabase::ApplyLookupResources(std::list<std::string>& resourcesId,
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1287 std::list<std::string>* instancesId,
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1288 const std::vector<DatabaseConstraint>& lookup,
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1289 ResourceType queryLevel,
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1290 size_t limit)
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1291 {
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1292 if (extensions_.lookupResources == NULL)
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1293 {
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1294 // Fallback to compatibility mode
3085
c829758b9ca0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3084
diff changeset
1295 ILookupResources::Apply
c829758b9ca0 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3084
diff changeset
1296 (*this, *this, resourcesId, instancesId, lookup, queryLevel, limit);
3075
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1297 }
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1298 else
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1299 {
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1300 std::vector<OrthancPluginDatabaseConstraint> constraints;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1301 std::vector< std::vector<const char*> > constraintsValues;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1302
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1303 constraints.resize(lookup.size());
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1304 constraintsValues.resize(lookup.size());
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1305
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1306 for (size_t i = 0; i < lookup.size(); i++)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1307 {
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1308 lookup[i].EncodeForPlugins(constraints[i], constraintsValues[i]);
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1309 }
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1310
3078
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3076
diff changeset
1311 ResetAnswers();
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1312 answerMatchingResources_ = &resourcesId;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1313 answerMatchingInstances_ = instancesId;
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1314
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1315 CheckSuccess(extensions_.lookupResources(GetContext(), payload_, lookup.size(),
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1316 (lookup.empty() ? NULL : &constraints[0]),
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1317 Plugins::Convert(queryLevel),
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1318 limit, (instancesId == NULL ? 0 : 1)));
3075
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1319 }
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1320 }
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1321
ead8576a02ef IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3074
diff changeset
1322
3080
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1323 bool OrthancPluginDatabase::CreateInstance(
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1324 IDatabaseWrapper::CreateInstanceResult& result,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1325 int64_t& instanceId,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1326 const std::string& patient,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1327 const std::string& study,
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1328 const std::string& series,
3082
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1329 const std::string& instance)
3080
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1330 {
3082
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1331 if (extensions_.createInstance == NULL)
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1332 {
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1333 // Fallback to compatibility mode
3084
195ba4cbac3f reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3082
diff changeset
1334 return ICreateInstance::Apply
3091
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1335 (*this, result, instanceId, patient, study, series, instance);
3082
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1336 }
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1337 else
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1338 {
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1339 OrthancPluginCreateInstanceResult output;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1340 memset(&output, 0, sizeof(output));
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1341
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1342 CheckSuccess(extensions_.createInstance(&output, payload_, patient.c_str(),
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1343 study.c_str(), series.c_str(), instance.c_str()));
3080
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1344
3082
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1345 instanceId = output.instanceId;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1346
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1347 if (output.isNewInstance)
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1348 {
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1349 result.isNewPatient_ = output.isNewPatient;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1350 result.isNewStudy_ = output.isNewStudy;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1351 result.isNewSeries_ = output.isNewSeries;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1352 result.patientId_ = output.patientId;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1353 result.studyId_ = output.studyId;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1354 result.seriesId_ = output.seriesId;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1355 return true;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1356 }
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1357 else
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1358 {
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1359 return false;
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1360 }
847a0ed92654 new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3080
diff changeset
1361 }
3080
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1362 }
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1363
1a75595d8e44 started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3079
diff changeset
1364
3052
c7db469bbe8e new class: Compatibility::DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3051
diff changeset
1365 void OrthancPluginDatabase::LookupIdentifier(std::list<int64_t>& result,
3051
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1366 ResourceType level,
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1367 const DicomTag& tag,
3054
3638de45a08c backward compatibility with filtering identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3053
diff changeset
1368 Compatibility::IdentifierConstraintType type,
3051
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1369 const std::string& value)
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1370 {
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1371 if (extensions_.lookupIdentifier3 == NULL)
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1372 {
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1373 throw OrthancException(ErrorCode_DatabasePlugin,
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1374 "The database plugin does not implement the mandatory LookupIdentifier3() extension");
3051
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1375 }
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1376
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1377 OrthancPluginDicomTag tmp;
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1378 tmp.group = tag.GetGroup();
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1379 tmp.element = tag.GetElement();
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1380 tmp.value = value.c_str();
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1381
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1382 ResetAnswers();
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1383 CheckSuccess(extensions_.lookupIdentifier3(GetContext(), payload_, Plugins::Convert(level),
3074
495c5edce708 new extension for database plugin SDK: lookupResources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3061
diff changeset
1384 &tmp, Compatibility::Convert(type)));
3051
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1385 ForwardAnswers(result);
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1386 }
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1387
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1388
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1389 void OrthancPluginDatabase::LookupIdentifierRange(std::list<int64_t>& result,
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1390 ResourceType level,
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1391 const DicomTag& tag,
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1392 const std::string& start,
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1393 const std::string& end)
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1394 {
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1395 if (extensions_.lookupIdentifierRange == NULL)
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1396 {
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1397 // Default implementation, for plugins using Orthanc SDK <= 1.3.2
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1398
3054
3638de45a08c backward compatibility with filtering identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3053
diff changeset
1399 LookupIdentifier(result, level, tag, Compatibility::IdentifierConstraintType_GreaterOrEqual, start);
3051
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1400
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1401 std::list<int64_t> b;
3054
3638de45a08c backward compatibility with filtering identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3053
diff changeset
1402 LookupIdentifier(result, level, tag, Compatibility::IdentifierConstraintType_SmallerOrEqual, end);
3051
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1403
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1404 result.splice(result.end(), b);
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1405 }
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1406 else
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1407 {
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1408 ResetAnswers();
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1409 CheckSuccess(extensions_.lookupIdentifierRange(GetContext(), payload_, Plugins::Convert(level),
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1410 tag.GetGroup(), tag.GetElement(),
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1411 start.c_str(), end.c_str()));
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1412 ForwardAnswers(result);
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1413 }
39db63e68dcf fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3038
diff changeset
1414 }
3089
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1415
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1416
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1417 void OrthancPluginDatabase::SetResourcesContent(const Orthanc::ResourcesContent& content)
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1418 {
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1419 if (extensions_.setResourcesContent == NULL)
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1420 {
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1421 ISetResourcesContent::Apply(*this, content);
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1422 }
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1423 else
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1424 {
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1425 std::vector<OrthancPluginResourcesContentTags> identifierTags;
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1426 std::vector<OrthancPluginResourcesContentTags> mainDicomTags;
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1427 std::vector<OrthancPluginResourcesContentMetadata> metadata;
3099
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1428
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1429 identifierTags.reserve(content.GetListTags().size());
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1430 mainDicomTags.reserve(content.GetListTags().size());
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1431 metadata.reserve(content.GetListMetadata().size());
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1432
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1433 for (ResourcesContent::ListTags::const_iterator
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1434 it = content.GetListTags().begin(); it != content.GetListTags().end(); ++it)
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1435 {
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1436 OrthancPluginResourcesContentTags tmp;
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1437 tmp.resource = it->resourceId_;
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1438 tmp.group = it->tag_.GetGroup();
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1439 tmp.element = it->tag_.GetElement();
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1440 tmp.value = it->value_.c_str();
3089
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1441
3099
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1442 if (it->isIdentifier_)
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1443 {
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1444 identifierTags.push_back(tmp);
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1445 }
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1446 else
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1447 {
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1448 mainDicomTags.push_back(tmp);
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1449 }
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1450 }
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1451
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1452 for (ResourcesContent::ListMetadata::const_iterator
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1453 it = content.GetListMetadata().begin(); it != content.GetListMetadata().end(); ++it)
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1454 {
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1455 OrthancPluginResourcesContentMetadata tmp;
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1456 tmp.resource = it->resourceId_;
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1457 tmp.metadata = it->metadata_;
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1458 tmp.value = it->value_.c_str();
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1459 metadata.push_back(tmp);
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1460 }
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1461
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1462 assert(identifierTags.size() + mainDicomTags.size() == content.GetListTags().size() &&
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1463 metadata.size() == content.GetListMetadata().size());
9c71abbff70f removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3092
diff changeset
1464
3089
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1465 CheckSuccess(extensions_.setResourcesContent(
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1466 payload_,
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1467 identifierTags.size(),
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1468 (identifierTags.empty() ? NULL : &identifierTags[0]),
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1469 mainDicomTags.size(),
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1470 (mainDicomTags.empty() ? NULL : &mainDicomTags[0]),
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1471 metadata.size(),
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1472 (metadata.empty() ? NULL : &metadata[0])));
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1473 }
fb8ee0786b1e new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3085
diff changeset
1474 }
3091
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1475
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1476
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1477
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1478 void OrthancPluginDatabase::GetChildrenMetadata(std::list<std::string>& target,
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1479 int64_t resourceId,
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1480 MetadataType metadata)
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1481 {
3092
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1482 if (extensions_.getChildrenMetadata == NULL)
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1483 {
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1484 IGetChildrenMetadata::Apply(*this, target, resourceId, metadata);
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1485 }
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1486 else
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1487 {
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1488 ResetAnswers();
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1489 CheckSuccess(extensions_.getChildrenMetadata
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1490 (GetContext(), payload_, resourceId, static_cast<int32_t>(metadata)));
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1491 ForwardAnswers(target);
fc57988dbfd8 new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3091
diff changeset
1492 }
3091
476cba12c2b0 IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3089
diff changeset
1493 }
3105
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1494
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1495
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1496 int64_t OrthancPluginDatabase::GetLastChangeIndex()
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1497 {
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1498 if (extensions_.getLastChangeIndex == NULL)
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1499 {
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1500 // This was the default behavior in Orthanc <= 1.5.1
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1501 // https://groups.google.com/d/msg/orthanc-users/QhzB6vxYeZ0/YxabgqpfBAAJ
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1502 return 0;
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1503 }
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1504 else
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1505 {
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1506 int64_t result = 0;
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1507 CheckSuccess(extensions_.getLastChangeIndex(&result, payload_));
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1508 return result;
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1509 }
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1510 }
3121
f86ebf971a72 fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3105
diff changeset
1511
f86ebf971a72 fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3105
diff changeset
1512
3124
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
1513 void OrthancPluginDatabase::TagMostRecentPatient(int64_t patient)
3121
f86ebf971a72 fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3105
diff changeset
1514 {
3124
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
1515 if (extensions_.tagMostRecentPatient != NULL)
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
1516 {
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
1517 CheckSuccess(extensions_.tagMostRecentPatient(payload_, patient));
c0d7aee8c3f8 Fix issue #58 (Patient recycling order should be defined by their received last instance)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3121
diff changeset
1518 }
3121
f86ebf971a72 fix unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3105
diff changeset
1519 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1520
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1521
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1522 bool OrthancPluginDatabase::LookupResourceAndParent(int64_t& id,
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1523 ResourceType& type,
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1524 std::string& parentPublicId,
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1525 const std::string& publicId)
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1526 {
3189
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1527 if (extensions_.lookupResourceAndParent == NULL)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1528 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1529 return ILookupResourceAndParent::Apply(*this, id, type, parentPublicId, publicId);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1530 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1531 else
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1532 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1533 std::list<std::string> parent;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1534
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1535 uint8_t isExisting;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1536 OrthancPluginResourceType pluginType = OrthancPluginResourceType_Patient;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1537
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1538 ResetAnswers();
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1539 CheckSuccess(extensions_.lookupResourceAndParent
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1540 (GetContext(), &isExisting, &id, &pluginType, payload_, publicId.c_str()));
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1541 ForwardAnswers(parent);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1542
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1543 if (isExisting)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1544 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1545 type = Plugins::Convert(pluginType);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1546
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1547 if (parent.empty())
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1548 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1549 if (type != ResourceType_Patient)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1550 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1551 throw OrthancException(ErrorCode_DatabasePlugin);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1552 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1553 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1554 else if (parent.size() == 1)
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1555 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1556 if ((type != ResourceType_Study &&
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1557 type != ResourceType_Series &&
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1558 type != ResourceType_Instance) ||
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1559 parent.front().empty())
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1560 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1561 throw OrthancException(ErrorCode_DatabasePlugin);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1562 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1563
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1564 parentPublicId = parent.front();
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1565 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1566 else
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1567 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1568 throw OrthancException(ErrorCode_DatabasePlugin);
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1569 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1570
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1571 return true;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1572 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1573 else
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1574 {
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1575 return false;
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1576 }
6f89d22a6ec0 New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3187
diff changeset
1577 }
3187
4bbadcd03966 refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3124
diff changeset
1578 }
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1579 }