Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp @ 4210:7b14ddf795c5
auto-detection of mg_disable_keep_alive() in CMake
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Sep 2020 11:20:08 +0200 |
parents | 318c16cfccab |
children | 1bd14c900699 |
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 | 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 | 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 | 42 #include "../../../OrthancFramework/Sources/Logging.h" |
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: |
4204 | 65 explicit Transaction(OrthancPluginDatabase& that) : |
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 |
4204 | 70 virtual void Begin() ORTHANC_OVERRIDE |
3019
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 |
4204 | 75 virtual void Rollback() ORTHANC_OVERRIDE |
3019
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 |
4204 | 80 virtual void Commit(int64_t diskSizeDelta) ORTHANC_OVERRIDE |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
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 | 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 | 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 | 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 | 230 backend_(backend), |
231 payload_(payload), | |
4204 | 232 listener_(NULL), |
233 fastGetTotalSize_(false), | |
234 currentDiskSize_(0), | |
235 answerDoneIgnored_(false) | |
1314 | 236 { |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
237 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
|
238 |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
239 ResetAnswers(); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
240 |
1609
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
241 memset(&extensions_, 0, sizeof(extensions_)); |
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_t size = sizeof(extensions_); |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
244 if (extensionsSize < size) |
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 size = extensionsSize; // Not all the extensions are available |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
247 } |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
248 |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
249 memcpy(&extensions_, extensions, size); |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
250 |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
251 bool isOptimal = true; |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
252 |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
253 if (extensions_.lookupResources == NULL) |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
254 { |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
255 LOG(INFO) << MISSING << "LookupIdentifierRange()"; |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
256 isOptimal = false; |
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 |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
259 if (extensions_.createInstance == NULL) |
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 LOG(INFO) << MISSING << "CreateInstance()"; |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
262 isOptimal = false; |
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 |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
265 if (extensions_.setResourcesContent == NULL) |
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 LOG(INFO) << MISSING << "SetResourcesContent()"; |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
268 isOptimal = false; |
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 |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
271 if (extensions_.getChildrenMetadata == NULL) |
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 LOG(INFO) << MISSING << "GetChildrenMetadata()"; |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
274 isOptimal = false; |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
275 } |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
276 |
3190 | 277 if (extensions_.getAllMetadata == NULL) |
278 { | |
279 LOG(INFO) << MISSING << "GetAllMetadata()"; | |
280 isOptimal = false; | |
281 } | |
282 | |
283 if (extensions_.lookupResourceAndParent == NULL) | |
284 { | |
285 LOG(INFO) << MISSING << "LookupResourceAndParent()"; | |
286 isOptimal = false; | |
287 } | |
288 | |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
289 if (isOptimal) |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
290 { |
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
|
291 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
|
292 << "is optimal for this version of Orthanc"; |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
293 } |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
294 else |
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
295 { |
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
|
296 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
|
297 << "Some extensions are missing in the plugin"; |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
298 } |
3105
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
299 |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
300 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
|
301 { |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
302 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
|
303 } |
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
|
304 |
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 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
|
306 { |
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
|
307 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
|
308 << "(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
|
309 } |
1314 | 310 } |
311 | |
312 | |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
313 void OrthancPluginDatabase::Open() |
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 CheckSuccess(backend_.open(payload_)); |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
316 |
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 Transaction transaction(*this); |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
319 transaction.Begin(); |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
320 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
321 std::string tmp; |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
322 fastGetTotalSize_ = |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
323 (LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast) && |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
324 tmp == "1"); |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
325 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
326 if (fastGetTotalSize_) |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
327 { |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
328 currentDiskSize_ = 0; // Unused |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
329 } |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
330 else |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
331 { |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
332 // 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
|
333 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
|
334 currentDiskSize_ = GetTotalCompressedSize(); |
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 transaction.Commit(0); |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
338 } |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
339 } |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
340 |
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
341 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 void OrthancPluginDatabase::AddAttachment(int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 const FileInfo& attachment) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
345 OrthancPluginAttachment tmp; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 tmp.uuid = attachment.GetUuid().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 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
|
348 tmp.uncompressedSize = attachment.GetUncompressedSize(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 tmp.uncompressedHash = attachment.GetUncompressedMD5().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 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
|
351 tmp.compressedSize = attachment.GetCompressedSize(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 tmp.compressedHash = attachment.GetCompressedMD5().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
354 CheckSuccess(backend_.addAttachment(payload_, id, &tmp)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 void OrthancPluginDatabase::AttachChild(int64_t parent, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 int64_t child) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
361 CheckSuccess(backend_.attachChild(payload_, parent, child)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 void OrthancPluginDatabase::ClearChanges() |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
367 CheckSuccess(backend_.clearChanges(payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 void OrthancPluginDatabase::ClearExportedResources() |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
373 CheckSuccess(backend_.clearExportedResources(payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 |
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 OrthancPluginDatabase::CreateResource(const std::string& publicId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 ResourceType type) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 int64_t id; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
381 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
|
382 return id; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 void OrthancPluginDatabase::DeleteAttachment(int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 FileContentType attachment) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
389 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
|
390 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
393 void OrthancPluginDatabase::DeleteMetadata(int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 MetadataType type) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
396 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
|
397 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
398 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 void OrthancPluginDatabase::DeleteResource(int64_t id) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
402 CheckSuccess(backend_.deleteResource(payload_, id)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 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
|
407 int64_t id) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 { |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
409 if (extensions_.getAllMetadata == NULL) |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
410 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
411 // 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
|
412 target.clear(); |
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 ResetAnswers(); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
415 CheckSuccess(backend_.listAvailableMetadata(GetContext(), payload_, id)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
417 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
418 type_ != _OrthancPluginDatabaseAnswerType_Int32) |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
419 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
420 throw OrthancException(ErrorCode_DatabasePlugin); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
421 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
422 |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
423 target.clear(); |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
424 |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
425 if (type_ == _OrthancPluginDatabaseAnswerType_Int32) |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 { |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
427 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
|
428 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
|
429 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
430 MetadataType type = static_cast<MetadataType>(*it); |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
431 |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
432 std::string value; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
433 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
|
434 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
435 target[type] = value; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
436 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
437 } |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
438 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 } |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
440 else |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
441 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
442 ResetAnswers(); |
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 answerMetadata_ = ⌖ |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
445 target.clear(); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
446 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
447 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
|
448 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
449 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
450 type_ != _OrthancPluginDatabaseAnswerType_Metadata) |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
451 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
452 throw OrthancException(ErrorCode_DatabasePlugin); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
453 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
454 } |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
455 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
458 void OrthancPluginDatabase::GetAllInternalIds(std::list<int64_t>& target, |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
459 ResourceType resourceType) |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
460 { |
1760
51db4a25a741
LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
461 if (extensions_.getAllInternalIds == NULL) |
51db4a25a741
LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
462 { |
2956 | 463 throw OrthancException(ErrorCode_DatabasePlugin, |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
464 "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
|
465 } |
51db4a25a741
LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
466 |
51db4a25a741
LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
467 ResetAnswers(); |
51db4a25a741
LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
468 CheckSuccess(extensions_.getAllInternalIds(GetContext(), payload_, Plugins::Convert(resourceType))); |
51db4a25a741
LookupIdentifier is plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1750
diff
changeset
|
469 ForwardAnswers(target); |
1750
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
470 } |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
471 |
55d52567bebb
LookupResource implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1746
diff
changeset
|
472 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 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
|
474 ResourceType resourceType) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
477 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
|
478 ForwardAnswers(target); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
482 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
|
483 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
|
484 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
|
485 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
|
486 { |
1609
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
487 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
|
488 { |
1609
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
489 // 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
|
490 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
491 CheckSuccess(extensions_.getAllPublicIdsWithLimit |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
492 (GetContext(), payload_, Plugins::Convert(resourceType), since, limit)); |
1609
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
493 ForwardAnswers(target); |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
494 } |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
495 else |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
496 { |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
497 // 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
|
498 // fallback implementation |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
499 target.clear(); |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
500 |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
501 if (limit == 0) |
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 return; |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
504 } |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
505 |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
506 std::list<std::string> tmp; |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
507 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
|
508 |
1609
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
509 if (tmp.size() <= since) |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
510 { |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
511 // Not enough results => empty answer |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
512 return; |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
513 } |
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 std::list<std::string>::iterator current = tmp.begin(); |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
516 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
|
517 |
1609
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
518 while (limit > 0 && current != tmp.end()) |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
519 { |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
520 target.push_back(*current); |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
521 --limit; |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
522 ++current; |
c74495267acf
Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1545
diff
changeset
|
523 } |
1509
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
524 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
525 } |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
526 |
0586ed8897f1
limit and since arguments while retrieving DICOM resources in the REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1486
diff
changeset
|
527 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 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
|
530 bool& done /*out*/, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
531 int64_t since, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 uint32_t maxResults) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 answerChanges_ = ⌖ |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 answerDone_ = &done; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 done = false; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
539 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
|
540 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 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
|
544 int64_t id) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
547 CheckSuccess(backend_.getChildrenInternalId(GetContext(), payload_, id)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 ForwardAnswers(target); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 |
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 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
|
553 int64_t id) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
556 CheckSuccess(backend_.getChildrenPublicId(GetContext(), payload_, id)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 ForwardAnswers(target); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 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
|
562 bool& done /*out*/, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 int64_t since, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 uint32_t maxResults) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 answerExportedResources_ = ⌖ |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 answerDone_ = &done; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 done = false; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
571 CheckSuccess(backend_.getExportedResources(GetContext(), payload_, since, maxResults)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 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
|
576 { |
4204 | 577 answerDoneIgnored_ = false; |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 answerChanges_ = ⌖ |
4204 | 581 answerDone_ = &answerDoneIgnored_; |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
583 CheckSuccess(backend_.getLastChange(GetContext(), payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 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
|
588 { |
4204 | 589 answerDoneIgnored_ = false; |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 answerExportedResources_ = ⌖ |
4204 | 593 answerDone_ = &answerDoneIgnored_; |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
595 CheckSuccess(backend_.getLastExportedResource(GetContext(), payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 |
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 void OrthancPluginDatabase::GetMainDicomTags(DicomMap& map, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 int64_t id) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 answerDicomMap_ = ↦ |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
605 CheckSuccess(backend_.getMainDicomTags(GetContext(), payload_, id)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 } |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 std::string OrthancPluginDatabase::GetPublicId(int64_t resourceId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 std::string s; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
614 CheckSuccess(backend_.getPublicId(GetContext(), payload_, resourceId)); |
1629
bad4772b605c
OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
615 |
bad4772b605c
OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
616 if (!ForwardSingleAnswer(s)) |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 { |
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
|
618 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
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 return s; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 uint64_t OrthancPluginDatabase::GetResourceCount(ResourceType resourceType) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 uint64_t count; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
628 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
|
629 return count; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 } |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 ResourceType OrthancPluginDatabase::GetResourceType(int64_t resourceId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 OrthancPluginResourceType type; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
636 CheckSuccess(backend_.getResourceType(&type, payload_, resourceId)); |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
637 return Plugins::Convert(type); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 } |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 uint64_t OrthancPluginDatabase::GetTotalCompressedSize() |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 uint64_t size; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
644 CheckSuccess(backend_.getTotalCompressedSize(&size, payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 return size; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 uint64_t OrthancPluginDatabase::GetTotalUncompressedSize() |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 uint64_t size; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
652 CheckSuccess(backend_.getTotalUncompressedSize(&size, payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 return size; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 bool OrthancPluginDatabase::IsExistingResource(int64_t internalId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 int32_t existing; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
660 CheckSuccess(backend_.isExistingResource(&existing, payload_, internalId)); |
1545 | 661 return (existing != 0); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 bool OrthancPluginDatabase::IsProtectedPatient(int64_t internalId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 int32_t isProtected; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
668 CheckSuccess(backend_.isProtectedPatient(&isProtected, payload_, internalId)); |
1545 | 669 return (isProtected != 0); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 |
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 void OrthancPluginDatabase::ListAvailableAttachments(std::list<FileContentType>& target, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 int64_t id) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
678 CheckSuccess(backend_.listAvailableAttachments(GetContext(), payload_, id)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
680 if (type_ != _OrthancPluginDatabaseAnswerType_None && |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
681 type_ != _OrthancPluginDatabaseAnswerType_Int32) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 { |
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
|
683 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 target.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 if (type_ == _OrthancPluginDatabaseAnswerType_Int32) |
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 for (std::list<int32_t>::const_iterator |
1314 | 691 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
|
692 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 target.push_back(static_cast<FileContentType>(*it)); |
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 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
698 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 void OrthancPluginDatabase::LogChange(int64_t internalId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 const ServerIndexChange& change) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
702 OrthancPluginChange tmp; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 tmp.seq = change.GetSeq(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 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
|
705 tmp.resourceType = Plugins::Convert(change.GetResourceType()); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 tmp.publicId = change.GetPublicId().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 tmp.date = change.GetDate().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
709 CheckSuccess(backend_.logChange(payload_, &tmp)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 } |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 void OrthancPluginDatabase::LogExportedResource(const ExportedResource& resource) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 OrthancPluginExportedResource tmp; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 tmp.seq = resource.GetSeq(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
717 tmp.resourceType = Plugins::Convert(resource.GetResourceType()); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 tmp.publicId = resource.GetPublicId().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 tmp.modality = resource.GetModality().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
720 tmp.date = resource.GetDate().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
721 tmp.patientId = resource.GetPatientId().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 tmp.studyInstanceUid = resource.GetStudyInstanceUid().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 tmp.seriesInstanceUid = resource.GetSeriesInstanceUid().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 tmp.sopInstanceUid = resource.GetSopInstanceUid().c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
725 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
726 CheckSuccess(backend_.logExportedResource(payload_, &tmp)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 bool OrthancPluginDatabase::LookupAttachment(FileInfo& attachment, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 FileContentType contentType) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
736 CheckSuccess(backend_.lookupAttachment |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
737 (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
|
738 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
739 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 return false; |
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 else if (type_ == _OrthancPluginDatabaseAnswerType_Attachment && |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
744 answerAttachments_.size() == 1) |
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 attachment = answerAttachments_.front(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 return true; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 else |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
750 { |
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
|
751 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
752 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 |
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 bool OrthancPluginDatabase::LookupGlobalProperty(std::string& target, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 GlobalProperty property) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
761 CheckSuccess(backend_.lookupGlobalProperty |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
762 (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
|
763 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 return ForwardSingleAnswer(target); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
767 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
768 bool OrthancPluginDatabase::LookupMetadata(std::string& target, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
769 int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
770 MetadataType type) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
771 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
772 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
773 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
|
774 return ForwardSingleAnswer(target); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 bool OrthancPluginDatabase::LookupParent(int64_t& parentId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 int64_t resourceId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
782 CheckSuccess(backend_.lookupParent(GetContext(), payload_, resourceId)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 return ForwardSingleAnswer(parentId); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 bool OrthancPluginDatabase::LookupResource(int64_t& id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 ResourceType& type, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 const std::string& publicId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 ResetAnswers(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
793 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
|
794 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 return false; |
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 else if (type_ == _OrthancPluginDatabaseAnswerType_Resource && |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 answerResources_.size() == 1) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 id = answerResources_.front().first; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 type = answerResources_.front().second; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 return true; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 else |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 { |
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
|
808 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
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 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 bool OrthancPluginDatabase::SelectPatientToRecycle(int64_t& internalId) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
816 CheckSuccess(backend_.selectPatientToRecycle(GetContext(), payload_)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 return ForwardSingleAnswer(internalId); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 |
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 bool OrthancPluginDatabase::SelectPatientToRecycle(int64_t& internalId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 int64_t patientIdToAvoid) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 ResetAnswers(); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
825 CheckSuccess(backend_.selectPatientToRecycle2(GetContext(), payload_, patientIdToAvoid)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
826 return ForwardSingleAnswer(internalId); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
829 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 void OrthancPluginDatabase::SetGlobalProperty(GlobalProperty property, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 const std::string& value) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
833 CheckSuccess(backend_.setGlobalProperty |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
834 (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
|
835 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
838 void OrthancPluginDatabase::ClearMainDicomTags(int64_t id) |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
839 { |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
840 if (extensions_.clearMainDicomTags == NULL) |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
841 { |
2956 | 842 throw OrthancException(ErrorCode_DatabasePlugin, |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
843 "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
|
844 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
845 |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
846 CheckSuccess(extensions_.clearMainDicomTags(payload_, id)); |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
847 } |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
848 |
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1651
diff
changeset
|
849 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 void OrthancPluginDatabase::SetMainDicomTag(int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 const DicomTag& tag, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 const std::string& value) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 OrthancPluginDicomTag tmp; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 tmp.group = tag.GetGroup(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 tmp.element = tag.GetElement(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 tmp.value = value.c_str(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 |
1713 | 859 CheckSuccess(backend_.setMainDicomTag(payload_, id, &tmp)); |
860 } | |
861 | |
1629
bad4772b605c
OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1625
diff
changeset
|
862 |
1713 | 863 void OrthancPluginDatabase::SetIdentifierTag(int64_t id, |
864 const DicomTag& tag, | |
865 const std::string& value) | |
866 { | |
867 OrthancPluginDicomTag tmp; | |
868 tmp.group = tag.GetGroup(); | |
869 tmp.element = tag.GetElement(); | |
870 tmp.value = value.c_str(); | |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
871 |
1713 | 872 CheckSuccess(backend_.setIdentifierTag(payload_, id, &tmp)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
873 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 void OrthancPluginDatabase::SetMetadata(int64_t id, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
877 MetadataType type, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
878 const std::string& value) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
880 CheckSuccess(backend_.setMetadata |
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
881 (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
|
882 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 void OrthancPluginDatabase::SetProtectedPatient(int64_t internalId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 bool isProtected) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
888 CheckSuccess(backend_.setProtectedPatient(payload_, internalId, isProtected)); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
892 IDatabaseWrapper::ITransaction* OrthancPluginDatabase::StartTransaction() |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 { |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
894 return new Transaction(*this); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1314
diff
changeset
|
898 static void ProcessEvent(IDatabaseListener& listener, |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 const _OrthancPluginDatabaseAnswer& answer) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 switch (answer.type) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 case _OrthancPluginDatabaseAnswerType_DeletedAttachment: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 const OrthancPluginAttachment& attachment = |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 listener.SignalFileDeleted(Convert(attachment)); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 case _OrthancPluginDatabaseAnswerType_RemainingAncestor: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
913 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
|
914 listener.SignalRemainingAncestor(type, answer.valueString); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 case _OrthancPluginDatabaseAnswerType_DeletedResource: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 { |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
920 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
|
921 ServerIndexChange change(ChangeType_Deleted, type, answer.valueString); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 listener.SignalChange(change); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 } |
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 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
|
927 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
928 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
929 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
932 unsigned int OrthancPluginDatabase::GetDatabaseVersion() |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
933 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
934 if (extensions_.getDatabaseVersion != NULL) |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
935 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
936 uint32_t version; |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
937 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
|
938 return version; |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
939 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
940 else |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
941 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
942 // 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
|
943 // (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
|
944 // version 5. |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
945 return 5; |
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 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
948 |
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 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
|
951 IStorageArea& storageArea) |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
952 { |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
953 if (extensions_.upgradeDatabase != NULL) |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
954 { |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
955 Transaction transaction(*this); |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
956 transaction.Begin(); |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
957 |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
958 OrthancPluginErrorCode code = extensions_.upgradeDatabase( |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
959 payload_, targetVersion, |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
960 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
961 |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
962 if (code == OrthancPluginErrorCode_Success) |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
963 { |
3019
8336204d95dc
refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2956
diff
changeset
|
964 transaction.Commit(0); |
1673
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
965 } |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
966 else |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
967 { |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
968 transaction.Rollback(); |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
969 errorDictionary_.LogError(code, true); |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
970 throw OrthancException(static_cast<ErrorCode>(code)); |
0bbcfd9695e5
UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1672
diff
changeset
|
971 } |
1615
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
972 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
973 } |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
974 |
c40fe92a68e7
Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1609
diff
changeset
|
975 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
976 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
977 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
978 if (answer.type == _OrthancPluginDatabaseAnswerType_None) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
979 { |
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
|
980 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
981 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
982 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
983 if (answer.type == _OrthancPluginDatabaseAnswerType_DeletedAttachment || |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
984 answer.type == _OrthancPluginDatabaseAnswerType_DeletedResource || |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
985 answer.type == _OrthancPluginDatabaseAnswerType_RemainingAncestor) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
986 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
987 assert(listener_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
988 ProcessEvent(*listener_, answer); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
989 return; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
992 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
993 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
994 type_ = answer.type; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
995 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
996 switch (type_) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
997 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
998 case _OrthancPluginDatabaseAnswerType_Int32: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
999 answerInt32_.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1000 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1001 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1002 case _OrthancPluginDatabaseAnswerType_Int64: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1003 answerInt64_.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1004 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1005 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1006 case _OrthancPluginDatabaseAnswerType_Resource: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1007 answerResources_.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1008 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1009 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1010 case _OrthancPluginDatabaseAnswerType_Attachment: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1011 answerAttachments_.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1012 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1013 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1014 case _OrthancPluginDatabaseAnswerType_String: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1015 answerStrings_.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1016 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1017 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1018 case _OrthancPluginDatabaseAnswerType_DicomTag: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1019 assert(answerDicomMap_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1020 answerDicomMap_->Clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1021 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1022 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1023 case _OrthancPluginDatabaseAnswerType_Change: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1024 assert(answerChanges_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1025 answerChanges_->clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1026 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1027 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1028 case _OrthancPluginDatabaseAnswerType_ExportedResource: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1029 assert(answerExportedResources_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1030 answerExportedResources_->clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1031 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1032 |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1033 case _OrthancPluginDatabaseAnswerType_MatchingResource: |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1034 assert(answerMatchingResources_ != NULL); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1035 answerMatchingResources_->clear(); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1036 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1037 if (answerMatchingInstances_ != NULL) |
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 answerMatchingInstances_->clear(); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1040 } |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1041 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1042 break; |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1043 |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1044 case _OrthancPluginDatabaseAnswerType_Metadata: |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1045 assert(answerMetadata_ != NULL); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1046 answerMetadata_->clear(); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1047 break; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1048 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1049 default: |
2956 | 1050 throw OrthancException(ErrorCode_DatabasePlugin, |
1051 "Unhandled type of answer for custom index plugin: " + | |
1052 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
|
1053 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1054 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1055 else if (type_ != answer.type) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1056 { |
2956 | 1057 throw OrthancException(ErrorCode_DatabasePlugin, |
1058 "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
|
1059 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1060 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1061 switch (answer.type) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1062 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1063 case _OrthancPluginDatabaseAnswerType_Int32: |
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 answerInt32_.push_back(answer.valueInt32); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1066 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1067 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1068 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1069 case _OrthancPluginDatabaseAnswerType_Int64: |
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 answerInt64_.push_back(answer.valueInt64); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1072 break; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1075 case _OrthancPluginDatabaseAnswerType_Resource: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1076 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1077 OrthancPluginResourceType type = static_cast<OrthancPluginResourceType>(answer.valueInt32); |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
1078 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
|
1079 break; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1082 case _OrthancPluginDatabaseAnswerType_Attachment: |
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 const OrthancPluginAttachment& attachment = |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1085 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric); |
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 answerAttachments_.push_back(Convert(attachment)); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1088 break; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1091 case _OrthancPluginDatabaseAnswerType_DicomTag: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1092 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1093 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
|
1094 assert(answerDicomMap_ != NULL); |
2007
655489d9165d
DicomMap::ParseDicomMetaInformation()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
1095 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
|
1096 break; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1099 case _OrthancPluginDatabaseAnswerType_String: |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1100 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1101 if (answer.valueString == NULL) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1102 { |
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
|
1103 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1106 if (type_ == _OrthancPluginDatabaseAnswerType_None) |
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 type_ = _OrthancPluginDatabaseAnswerType_String; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1109 answerStrings_.clear(); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1110 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1111 else if (type_ != _OrthancPluginDatabaseAnswerType_String) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1112 { |
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
|
1113 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1114 } |
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 answerStrings_.push_back(std::string(answer.valueString)); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1117 break; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1120 case _OrthancPluginDatabaseAnswerType_Change: |
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 assert(answerDone_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1123 if (answer.valueUint32 == 1) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1124 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1125 *answerDone_ = true; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1126 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1127 else if (*answerDone_) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1128 { |
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
|
1129 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1130 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1131 else |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1132 { |
3078 | 1133 const OrthancPluginChange& change = |
1134 *reinterpret_cast<const OrthancPluginChange*>(answer.valueGeneric); | |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1135 assert(answerChanges_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1136 answerChanges_->push_back |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1137 (ServerIndexChange(change.seq, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1138 static_cast<ChangeType>(change.changeType), |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
1139 Plugins::Convert(change.resourceType), |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1140 change.publicId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1141 change.date)); |
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 break; |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1147 case _OrthancPluginDatabaseAnswerType_ExportedResource: |
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 assert(answerDone_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1150 if (answer.valueUint32 == 1) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1151 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1152 *answerDone_ = true; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1153 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1154 else if (*answerDone_) |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1155 { |
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
|
1156 throw OrthancException(ErrorCode_DatabasePlugin); |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1157 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1158 else |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1159 { |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1160 const OrthancPluginExportedResource& exported = |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1161 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1162 assert(answerExportedResources_ != NULL); |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1163 answerExportedResources_->push_back |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1164 (ExportedResource(exported.seq, |
1672
4c5a85c3ff43
sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1668
diff
changeset
|
1165 Plugins::Convert(exported.resourceType), |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1166 exported.publicId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1167 exported.modality, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1168 exported.date, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1169 exported.patientId, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1170 exported.studyInstanceUid, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1171 exported.seriesInstanceUid, |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1172 exported.sopInstanceUid)); |
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 |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1175 break; |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1176 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1177 |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1178 case _OrthancPluginDatabaseAnswerType_MatchingResource: |
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 const OrthancPluginMatchingResource& match = |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1181 *reinterpret_cast<const OrthancPluginMatchingResource*>(answer.valueGeneric); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1182 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1183 if (match.resourceId == NULL) |
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 throw OrthancException(ErrorCode_DatabasePlugin); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1186 } |
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 assert(answerMatchingResources_ != NULL); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1189 answerMatchingResources_->push_back(match.resourceId); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1190 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1191 if (answerMatchingInstances_ != NULL) |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1192 { |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1193 if (match.someInstanceId == NULL) |
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 throw OrthancException(ErrorCode_DatabasePlugin); |
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 answerMatchingInstances_->push_back(match.someInstanceId); |
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 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1201 break; |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1202 } |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1203 |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1204 case _OrthancPluginDatabaseAnswerType_Metadata: |
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 const OrthancPluginResourcesContentMetadata& metadata = |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1207 *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
|
1208 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1209 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
|
1210 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1211 if (metadata.value == NULL) |
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 throw OrthancException(ErrorCode_DatabasePlugin); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1214 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1215 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1216 assert(answerMetadata_ != NULL && |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1217 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
|
1218 (*answerMetadata_) [type] = metadata.value; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1219 break; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1220 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1221 |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1222 default: |
2956 | 1223 throw OrthancException(ErrorCode_DatabasePlugin, |
1224 "Unhandled type of answer for custom index plugin: " + | |
1225 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
|
1226 } |
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1227 } |
3020
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 |
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
1230 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
|
1231 { |
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
1232 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
|
1233 { |
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
1234 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
|
1235 } |
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
1236 else |
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 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
|
1239 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
|
1240 } |
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
1241 } |
3025
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
1242 |
039a9d262d64
preparing to speed up find in databases
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3020
diff
changeset
|
1243 |
3075
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1244 void OrthancPluginDatabase::ApplyLookupResources(std::list<std::string>& resourcesId, |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1245 std::list<std::string>* instancesId, |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1246 const std::vector<DatabaseConstraint>& lookup, |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1247 ResourceType queryLevel, |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1248 size_t limit) |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1249 { |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1250 if (extensions_.lookupResources == NULL) |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1251 { |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1252 // Fallback to compatibility mode |
3085 | 1253 ILookupResources::Apply |
1254 (*this, *this, resourcesId, instancesId, lookup, queryLevel, limit); | |
3075
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1255 } |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1256 else |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1257 { |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1258 std::vector<OrthancPluginDatabaseConstraint> constraints; |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1259 std::vector< std::vector<const char*> > constraintsValues; |
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 constraints.resize(lookup.size()); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1262 constraintsValues.resize(lookup.size()); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1263 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1264 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
|
1265 { |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1266 lookup[i].EncodeForPlugins(constraints[i], constraintsValues[i]); |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1267 } |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1268 |
3078 | 1269 ResetAnswers(); |
3076
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1270 answerMatchingResources_ = &resourcesId; |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1271 answerMatchingInstances_ = instancesId; |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1272 |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1273 CheckSuccess(extensions_.lookupResources(GetContext(), payload_, lookup.size(), |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1274 (lookup.empty() ? NULL : &constraints[0]), |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1275 Plugins::Convert(queryLevel), |
8bc2cb1335f4
OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3075
diff
changeset
|
1276 limit, (instancesId == NULL ? 0 : 1))); |
3075
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1277 } |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1278 } |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1279 |
ead8576a02ef
IDatabaseWrapper::ApplyLookupResources now returns lists
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3074
diff
changeset
|
1280 |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1281 bool OrthancPluginDatabase::CreateInstance( |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1282 IDatabaseWrapper::CreateInstanceResult& result, |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1283 int64_t& instanceId, |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1284 const std::string& patient, |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1285 const std::string& study, |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1286 const std::string& series, |
3082
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1287 const std::string& instance) |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1288 { |
3082
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1289 if (extensions_.createInstance == NULL) |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1290 { |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1291 // Fallback to compatibility mode |
3084 | 1292 return ICreateInstance::Apply |
3091
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1293 (*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
|
1294 } |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1295 else |
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 OrthancPluginCreateInstanceResult output; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1298 memset(&output, 0, sizeof(output)); |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1299 |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1300 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
|
1301 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
|
1302 |
3082
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1303 instanceId = output.instanceId; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1304 |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1305 if (output.isNewInstance) |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1306 { |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1307 result.isNewPatient_ = output.isNewPatient; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1308 result.isNewStudy_ = output.isNewStudy; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1309 result.isNewSeries_ = output.isNewSeries; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1310 result.patientId_ = output.patientId; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1311 result.studyId_ = output.studyId; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1312 result.seriesId_ = output.seriesId; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1313 return true; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1314 } |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1315 else |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1316 { |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1317 return false; |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1318 } |
847a0ed92654
new extension for database plugin SDK: createInstance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3080
diff
changeset
|
1319 } |
3080
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1320 } |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1321 |
1a75595d8e44
started refactoring of ServerIndex::Store()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3079
diff
changeset
|
1322 |
3052
c7db469bbe8e
new class: Compatibility::DatabaseLookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3051
diff
changeset
|
1323 void OrthancPluginDatabase::LookupIdentifier(std::list<int64_t>& result, |
3051 | 1324 ResourceType level, |
1325 const DicomTag& tag, | |
3054
3638de45a08c
backward compatibility with filtering identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3053
diff
changeset
|
1326 Compatibility::IdentifierConstraintType type, |
3051 | 1327 const std::string& value) |
1328 { | |
1329 if (extensions_.lookupIdentifier3 == NULL) | |
1330 { | |
1331 throw OrthancException(ErrorCode_DatabasePlugin, | |
3101
b2b6db5ad9a5
warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3099
diff
changeset
|
1332 "The database plugin does not implement the mandatory LookupIdentifier3() extension"); |
3051 | 1333 } |
1334 | |
1335 OrthancPluginDicomTag tmp; | |
1336 tmp.group = tag.GetGroup(); | |
1337 tmp.element = tag.GetElement(); | |
1338 tmp.value = value.c_str(); | |
1339 | |
1340 ResetAnswers(); | |
1341 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
|
1342 &tmp, Compatibility::Convert(type))); |
3051 | 1343 ForwardAnswers(result); |
1344 } | |
1345 | |
1346 | |
1347 void OrthancPluginDatabase::LookupIdentifierRange(std::list<int64_t>& result, | |
1348 ResourceType level, | |
1349 const DicomTag& tag, | |
1350 const std::string& start, | |
1351 const std::string& end) | |
1352 { | |
1353 if (extensions_.lookupIdentifierRange == NULL) | |
1354 { | |
1355 // Default implementation, for plugins using Orthanc SDK <= 1.3.2 | |
1356 | |
3054
3638de45a08c
backward compatibility with filtering identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3053
diff
changeset
|
1357 LookupIdentifier(result, level, tag, Compatibility::IdentifierConstraintType_GreaterOrEqual, start); |
3051 | 1358 |
1359 std::list<int64_t> b; | |
3054
3638de45a08c
backward compatibility with filtering identifiers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3053
diff
changeset
|
1360 LookupIdentifier(result, level, tag, Compatibility::IdentifierConstraintType_SmallerOrEqual, end); |
3051 | 1361 |
1362 result.splice(result.end(), b); | |
1363 } | |
1364 else | |
1365 { | |
1366 ResetAnswers(); | |
1367 CheckSuccess(extensions_.lookupIdentifierRange(GetContext(), payload_, Plugins::Convert(level), | |
1368 tag.GetGroup(), tag.GetElement(), | |
1369 start.c_str(), end.c_str())); | |
1370 ForwardAnswers(result); | |
1371 } | |
1372 } | |
3089
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 |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1375 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
|
1376 { |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1377 if (extensions_.setResourcesContent == NULL) |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1378 { |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1379 ISetResourcesContent::Apply(*this, content); |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1380 } |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1381 else |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1382 { |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1383 std::vector<OrthancPluginResourcesContentTags> identifierTags; |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1384 std::vector<OrthancPluginResourcesContentTags> mainDicomTags; |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1385 std::vector<OrthancPluginResourcesContentMetadata> metadata; |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1386 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1387 identifierTags.reserve(content.GetListTags().size()); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1388 mainDicomTags.reserve(content.GetListTags().size()); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1389 metadata.reserve(content.GetListMetadata().size()); |
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 for (ResourcesContent::ListTags::const_iterator |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1392 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
|
1393 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1394 OrthancPluginResourcesContentTags tmp; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1395 tmp.resource = it->resourceId_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1396 tmp.group = it->tag_.GetGroup(); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1397 tmp.element = it->tag_.GetElement(); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1398 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
|
1399 |
3099
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1400 if (it->isIdentifier_) |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1401 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1402 identifierTags.push_back(tmp); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1403 } |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1404 else |
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 mainDicomTags.push_back(tmp); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1407 } |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1408 } |
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 for (ResourcesContent::ListMetadata::const_iterator |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1411 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
|
1412 { |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1413 OrthancPluginResourcesContentMetadata tmp; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1414 tmp.resource = it->resourceId_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1415 tmp.metadata = it->metadata_; |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1416 tmp.value = it->value_.c_str(); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1417 metadata.push_back(tmp); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1418 } |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1419 |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1420 assert(identifierTags.size() + mainDicomTags.size() == content.GetListTags().size() && |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1421 metadata.size() == content.GetListMetadata().size()); |
9c71abbff70f
removing build dependency on plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3092
diff
changeset
|
1422 |
3089
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1423 CheckSuccess(extensions_.setResourcesContent( |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1424 payload_, |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1425 identifierTags.size(), |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1426 (identifierTags.empty() ? NULL : &identifierTags[0]), |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1427 mainDicomTags.size(), |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1428 (mainDicomTags.empty() ? NULL : &mainDicomTags[0]), |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1429 metadata.size(), |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1430 (metadata.empty() ? NULL : &metadata[0]))); |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1431 } |
fb8ee0786b1e
new extension for database plugin SDK: setResourcesContent
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3085
diff
changeset
|
1432 } |
3091
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1433 |
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1434 |
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1435 |
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1436 void OrthancPluginDatabase::GetChildrenMetadata(std::list<std::string>& target, |
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1437 int64_t resourceId, |
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1438 MetadataType metadata) |
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1439 { |
3092
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1440 if (extensions_.getChildrenMetadata == NULL) |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1441 { |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1442 IGetChildrenMetadata::Apply(*this, target, resourceId, metadata); |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1443 } |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1444 else |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1445 { |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1446 ResetAnswers(); |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1447 CheckSuccess(extensions_.getChildrenMetadata |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1448 (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
|
1449 ForwardAnswers(target); |
fc57988dbfd8
new extension for database plugin SDK: getChildrenMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3091
diff
changeset
|
1450 } |
3091
476cba12c2b0
IDatabaseWrapper::GetChildrenMetadata()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3089
diff
changeset
|
1451 } |
3105
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 |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1454 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
|
1455 { |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1456 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
|
1457 { |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1458 // 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
|
1459 // 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
|
1460 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
|
1461 } |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1462 else |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1463 { |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1464 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
|
1465 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
|
1466 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
|
1467 } |
2e1711f80f74
More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3101
diff
changeset
|
1468 } |
3121 | 1469 |
1470 | |
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
|
1471 void OrthancPluginDatabase::TagMostRecentPatient(int64_t patient) |
3121 | 1472 { |
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
|
1473 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
|
1474 { |
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
|
1475 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
|
1476 } |
3121 | 1477 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1478 |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1479 |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1480 bool OrthancPluginDatabase::LookupResourceAndParent(int64_t& id, |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1481 ResourceType& type, |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1482 std::string& parentPublicId, |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1483 const std::string& publicId) |
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1484 { |
3189
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1485 if (extensions_.lookupResourceAndParent == NULL) |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1486 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1487 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
|
1488 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1489 else |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1490 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1491 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
|
1492 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1493 uint8_t isExisting; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1494 OrthancPluginResourceType pluginType = OrthancPluginResourceType_Patient; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1495 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1496 ResetAnswers(); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1497 CheckSuccess(extensions_.lookupResourceAndParent |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1498 (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
|
1499 ForwardAnswers(parent); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1500 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1501 if (isExisting) |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1502 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1503 type = Plugins::Convert(pluginType); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1504 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1505 if (parent.empty()) |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1506 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1507 if (type != ResourceType_Patient) |
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 throw OrthancException(ErrorCode_DatabasePlugin); |
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 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1512 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
|
1513 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1514 if ((type != ResourceType_Study && |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1515 type != ResourceType_Series && |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1516 type != ResourceType_Instance) || |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1517 parent.front().empty()) |
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 throw OrthancException(ErrorCode_DatabasePlugin); |
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 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1522 parentPublicId = parent.front(); |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1523 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1524 else |
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 throw OrthancException(ErrorCode_DatabasePlugin); |
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 |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1529 return true; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1530 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1531 else |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1532 { |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1533 return false; |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1534 } |
6f89d22a6ec0
New extensions in the database SDK: LookupResourceAndParent and GetAllMetadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3187
diff
changeset
|
1535 } |
3187
4bbadcd03966
refactoring retrieval of metadata from database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3124
diff
changeset
|
1536 } |
1309
8f4487d8f79e
new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1537 } |