annotate OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp @ 4045:05b8fd21089c framework

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