annotate OrthancServer/Plugins/Engine/OrthancPluginDatabase.cpp @ 5216:450ac804d3af db-protobuf

simplifying IDatabaseWrapper::LogChange()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Apr 2023 14:49:33 +0200
parents 8b6da4fdf9fe
children df39c7583a49
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1762
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5185
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
0ea402b4d901 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4892
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * 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
10 * 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
11 * 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
12 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * 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
14 * 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
15 * 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
16 * General Public License for more details.
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * 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
19 * 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
20 **/
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
23 #include "../../Sources/PrecompiledHeadersServer.h"
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "OrthancPluginDatabase.h"
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
2136
dd609a99d39a uniformization of the macro naming
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2007
diff changeset
26 #if ORTHANC_ENABLE_PLUGINS != 1
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
27 # error The plugin support is disabled
1632
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
28 #endif
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
29
eb8fbcf008b5 fix build with plugins disabled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1630
diff changeset
30
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
31 #include "../../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
32 #include "../../../OrthancFramework/Sources/OrthancException.h"
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
33 #include "../../Sources/Database/Compatibility/ICreateInstance.h"
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
34 #include "../../Sources/Database/Compatibility/IGetChildrenMetadata.h"
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
35 #include "../../Sources/Database/Compatibility/ILookupResourceAndParent.h"
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
36 #include "../../Sources/Database/Compatibility/ILookupResources.h"
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
37 #include "../../Sources/Database/Compatibility/ISetResourcesContent.h"
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
38 #include "../../Sources/Database/VoidDatabaseListener.h"
1629
bad4772b605c OrthancPluginErrorCode in database plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1625
diff changeset
39 #include "PluginsEnumerations.h"
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <cassert>
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 namespace Orthanc
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
45 class OrthancPluginDatabase::Transaction :
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
46 public IDatabaseWrapper::ITransaction,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
47 public Compatibility::ICreateInstance,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
48 public Compatibility::IGetChildrenMetadata,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
49 public Compatibility::ILookupResources,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
50 public Compatibility::ILookupResourceAndParent,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
51 public Compatibility::ISetResourcesContent
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
52 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
53 private:
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
54 typedef std::pair<int64_t, ResourceType> AnswerResource;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
55 typedef std::map<MetadataType, std::string> AnswerMetadata;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
56
4594
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
57 OrthancPluginDatabase& that_;
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
58 boost::recursive_mutex::scoped_lock lock_;
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
59 IDatabaseListener& listener_;
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
60 _OrthancPluginDatabaseAnswerType type_;
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
61
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
62 std::list<std::string> answerStrings_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
63 std::list<int32_t> answerInt32_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
64 std::list<int64_t> answerInt64_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
65 std::list<AnswerResource> answerResources_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
66 std::list<FileInfo> answerAttachments_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
67
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
68 DicomMap* answerDicomMap_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
69 std::list<ServerIndexChange>* answerChanges_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
70 std::list<ExportedResource>* answerExportedResources_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
71 bool* answerDone_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
72 bool answerDoneIgnored_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
73 std::list<std::string>* answerMatchingResources_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
74 std::list<std::string>* answerMatchingInstances_;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
75 AnswerMetadata* answerMetadata_;
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 void CheckSuccess(OrthancPluginErrorCode code) const
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
78 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
79 that_.CheckSuccess(code);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
80 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
81
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
82
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
83 static FileInfo Convert(const OrthancPluginAttachment& attachment)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
84 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
85 return FileInfo(attachment.uuid,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
86 static_cast<FileContentType>(attachment.contentType),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
87 attachment.uncompressedSize,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
88 attachment.uncompressedHash,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
89 static_cast<CompressionType>(attachment.compressionType),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
90 attachment.compressedSize,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
91 attachment.compressedHash);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
92 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
93
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
94
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
95 void ResetAnswers()
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
96 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
97 type_ = _OrthancPluginDatabaseAnswerType_None;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
98
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
99 answerDicomMap_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
100 answerChanges_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
101 answerExportedResources_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
102 answerDone_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
103 answerMatchingResources_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
104 answerMatchingInstances_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
105 answerMetadata_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
106 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
107
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
108
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
109 void ForwardAnswers(std::list<int64_t>& target)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
110 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
111 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
112 type_ != _OrthancPluginDatabaseAnswerType_Int64)
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
113 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
114 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
115 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
116
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
117 target.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
118
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
119 if (type_ == _OrthancPluginDatabaseAnswerType_Int64)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
120 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
121 for (std::list<int64_t>::const_iterator
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
122 it = answerInt64_.begin(); it != answerInt64_.end(); ++it)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
123 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
124 target.push_back(*it);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
125 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
126 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
127 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
128
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
129
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
130 void ForwardAnswers(std::list<std::string>& target)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
131 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
132 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
133 type_ != _OrthancPluginDatabaseAnswerType_String)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
134 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
135 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
136 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
137
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
138 target.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
139
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
140 if (type_ == _OrthancPluginDatabaseAnswerType_String)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
141 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
142 for (std::list<std::string>::const_iterator
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
143 it = answerStrings_.begin(); it != answerStrings_.end(); ++it)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
144 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
145 target.push_back(*it);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
146 }
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
147 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
148 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
149
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
150
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
151 bool ForwardSingleAnswer(std::string& target)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
152 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
153 if (type_ == _OrthancPluginDatabaseAnswerType_None)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
154 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
155 return false;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
156 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
157 else if (type_ == _OrthancPluginDatabaseAnswerType_String &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
158 answerStrings_.size() == 1)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
159 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
160 target = answerStrings_.front();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
161 return true;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
162 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
163 else
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
164 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
165 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
166 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
167 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
168
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
169
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
170 bool ForwardSingleAnswer(int64_t& target)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
171 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
172 if (type_ == _OrthancPluginDatabaseAnswerType_None)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
173 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
174 return false;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
175 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
176 else if (type_ == _OrthancPluginDatabaseAnswerType_Int64 &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
177 answerInt64_.size() == 1)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
178 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
179 target = answerInt64_.front();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
180 return true;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
181 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
182 else
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
183 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
184 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
185 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
186 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
187
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
188
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
189 void ProcessEvent(const _OrthancPluginDatabaseAnswer& answer)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
190 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
191 switch (answer.type)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
192 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
193 case _OrthancPluginDatabaseAnswerType_DeletedAttachment:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
194 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
195 const OrthancPluginAttachment& attachment =
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
196 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
197 listener_.SignalAttachmentDeleted(Convert(attachment));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
198 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
199 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
200
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
201 case _OrthancPluginDatabaseAnswerType_RemainingAncestor:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
202 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
203 ResourceType type = Plugins::Convert(static_cast<OrthancPluginResourceType>(answer.valueInt32));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
204 listener_.SignalRemainingAncestor(type, answer.valueString);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
205 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
206 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
207
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
208 case _OrthancPluginDatabaseAnswerType_DeletedResource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
209 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
210 ResourceType type = Plugins::Convert(static_cast<OrthancPluginResourceType>(answer.valueInt32));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
211 listener_.SignalResourceDeleted(type, answer.valueString);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
212 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
213 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
214
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
215 default:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
216 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
217 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
218 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
219
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
220
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
221 public:
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
222 explicit Transaction(OrthancPluginDatabase& that,
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
223 IDatabaseListener& listener) :
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
224 that_(that),
4594
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
225 lock_(that.mutex_),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
226 listener_(listener),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
227 type_(_OrthancPluginDatabaseAnswerType_None),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
228 answerDoneIgnored_(false)
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
229 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
230 if (that_.activeTransaction_ != NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
231 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
232 throw OrthancException(ErrorCode_InternalError);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
233 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
234
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
235 that_.activeTransaction_ = this;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
236
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
237 ResetAnswers();
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
238 }
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
239
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
240 virtual ~Transaction()
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
241 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
242 assert(that_.activeTransaction_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
243 that_.activeTransaction_ = NULL;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
244 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
245
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
246 IDatabaseListener& GetDatabaseListener() const
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
247 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
248 return listener_;
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
249 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
250
4556
2a0f8031fb93 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
251 void Begin()
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
252 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
253 CheckSuccess(that_.backend_.startTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
254 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
255
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
256 virtual void Rollback() ORTHANC_OVERRIDE
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
257 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
258 CheckSuccess(that_.backend_.rollbackTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
259 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
260
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
261 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
262 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
263 if (that_.fastGetTotalSize_)
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
264 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
265 CheckSuccess(that_.backend_.commitTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
266 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
267 else
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
268 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
269 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
270 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
271 throw OrthancException(ErrorCode_DatabasePlugin);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
272 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
273
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
274 uint64_t newDiskSize = (that_.currentDiskSize_ + diskSizeDelta);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
275
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
276 assert(newDiskSize == GetTotalCompressedSize());
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
277
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
278 CheckSuccess(that_.backend_.commitTransaction(that_.payload_));
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
279
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
280 // 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
281 that_.currentDiskSize_ = newDiskSize;
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
282 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
283 }
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
284
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
285
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
286 void AnswerReceived(const _OrthancPluginDatabaseAnswer& answer)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
287 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
288 if (answer.type == _OrthancPluginDatabaseAnswerType_None)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
289 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
290 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
291 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
292
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
293 if (answer.type == _OrthancPluginDatabaseAnswerType_DeletedAttachment ||
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
294 answer.type == _OrthancPluginDatabaseAnswerType_DeletedResource ||
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
295 answer.type == _OrthancPluginDatabaseAnswerType_RemainingAncestor)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
296 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
297 ProcessEvent(answer);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
298 return;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
299 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
300
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
301 if (type_ == _OrthancPluginDatabaseAnswerType_None)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
302 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
303 type_ = answer.type;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
304
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
305 switch (type_)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
306 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
307 case _OrthancPluginDatabaseAnswerType_Int32:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
308 answerInt32_.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
309 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
310
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
311 case _OrthancPluginDatabaseAnswerType_Int64:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
312 answerInt64_.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
313 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
314
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
315 case _OrthancPluginDatabaseAnswerType_Resource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
316 answerResources_.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
317 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
318
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
319 case _OrthancPluginDatabaseAnswerType_Attachment:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
320 answerAttachments_.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
321 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
322
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
323 case _OrthancPluginDatabaseAnswerType_String:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
324 answerStrings_.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
325 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
326
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
327 case _OrthancPluginDatabaseAnswerType_DicomTag:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
328 assert(answerDicomMap_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
329 answerDicomMap_->Clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
330 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
331
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
332 case _OrthancPluginDatabaseAnswerType_Change:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
333 assert(answerChanges_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
334 answerChanges_->clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
335 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
336
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
337 case _OrthancPluginDatabaseAnswerType_ExportedResource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
338 assert(answerExportedResources_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
339 answerExportedResources_->clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
340 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
341
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
342 case _OrthancPluginDatabaseAnswerType_MatchingResource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
343 assert(answerMatchingResources_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
344 answerMatchingResources_->clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
345
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
346 if (answerMatchingInstances_ != NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
347 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
348 answerMatchingInstances_->clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
349 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
350
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
351 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
352
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
353 case _OrthancPluginDatabaseAnswerType_Metadata:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
354 assert(answerMetadata_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
355 answerMetadata_->clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
356 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
357
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
358 default:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
359 throw OrthancException(ErrorCode_DatabasePlugin,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
360 "Unhandled type of answer for custom index plugin: " +
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
361 boost::lexical_cast<std::string>(answer.type));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
362 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
363 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
364 else if (type_ != answer.type)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
365 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
366 throw OrthancException(ErrorCode_DatabasePlugin,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
367 "Error in the plugin protocol: Cannot change the answer type");
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
368 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
369
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
370 switch (answer.type)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
371 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
372 case _OrthancPluginDatabaseAnswerType_Int32:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
373 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
374 answerInt32_.push_back(answer.valueInt32);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
375 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
376 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
377
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
378 case _OrthancPluginDatabaseAnswerType_Int64:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
379 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
380 answerInt64_.push_back(answer.valueInt64);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
381 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
382 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
383
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
384 case _OrthancPluginDatabaseAnswerType_Resource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
385 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
386 OrthancPluginResourceType type = static_cast<OrthancPluginResourceType>(answer.valueInt32);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
387 answerResources_.push_back(std::make_pair(answer.valueInt64, Plugins::Convert(type)));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
388 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
389 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
390
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
391 case _OrthancPluginDatabaseAnswerType_Attachment:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
392 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
393 const OrthancPluginAttachment& attachment =
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
394 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
395
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
396 answerAttachments_.push_back(Convert(attachment));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
397 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
398 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
399
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
400 case _OrthancPluginDatabaseAnswerType_DicomTag:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
401 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
402 const OrthancPluginDicomTag& tag = *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
403 assert(answerDicomMap_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
404 answerDicomMap_->SetValue(tag.group, tag.element, std::string(tag.value), false);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
405 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
406 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
407
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
408 case _OrthancPluginDatabaseAnswerType_String:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
409 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
410 if (answer.valueString == NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
411 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
412 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
413 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
414
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
415 if (type_ == _OrthancPluginDatabaseAnswerType_None)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
416 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
417 type_ = _OrthancPluginDatabaseAnswerType_String;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
418 answerStrings_.clear();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
419 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
420 else if (type_ != _OrthancPluginDatabaseAnswerType_String)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
421 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
422 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
423 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
424
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
425 answerStrings_.push_back(std::string(answer.valueString));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
426 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
427 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
428
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
429 case _OrthancPluginDatabaseAnswerType_Change:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
430 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
431 assert(answerDone_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
432 if (answer.valueUint32 == 1)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
433 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
434 *answerDone_ = true;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
435 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
436 else if (*answerDone_)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
437 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
438 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
439 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
440 else
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
441 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
442 const OrthancPluginChange& change =
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
443 *reinterpret_cast<const OrthancPluginChange*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
444 assert(answerChanges_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
445 answerChanges_->push_back
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
446 (ServerIndexChange(change.seq,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
447 static_cast<ChangeType>(change.changeType),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
448 Plugins::Convert(change.resourceType),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
449 change.publicId,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
450 change.date));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
451 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
452
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
453 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
454 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
455
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
456 case _OrthancPluginDatabaseAnswerType_ExportedResource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
457 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
458 assert(answerDone_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
459 if (answer.valueUint32 == 1)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
460 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
461 *answerDone_ = true;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
462 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
463 else if (*answerDone_)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
464 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
465 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
466 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
467 else
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
468 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
469 const OrthancPluginExportedResource& exported =
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
470 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
471 assert(answerExportedResources_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
472 answerExportedResources_->push_back
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
473 (ExportedResource(exported.seq,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
474 Plugins::Convert(exported.resourceType),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
475 exported.publicId,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
476 exported.modality,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
477 exported.date,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
478 exported.patientId,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
479 exported.studyInstanceUid,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
480 exported.seriesInstanceUid,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
481 exported.sopInstanceUid));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
482 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
483
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
484 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
485 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
486
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
487 case _OrthancPluginDatabaseAnswerType_MatchingResource:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
488 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
489 const OrthancPluginMatchingResource& match =
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
490 *reinterpret_cast<const OrthancPluginMatchingResource*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
491
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
492 if (match.resourceId == NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
493 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
494 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
495 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
496
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
497 assert(answerMatchingResources_ != NULL);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
498 answerMatchingResources_->push_back(match.resourceId);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
499
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
500 if (answerMatchingInstances_ != NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
501 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
502 if (match.someInstanceId == NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
503 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
504 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
505 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
506
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
507 answerMatchingInstances_->push_back(match.someInstanceId);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
508 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
509
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
510 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
511 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
512
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
513 case _OrthancPluginDatabaseAnswerType_Metadata:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
514 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
515 const OrthancPluginResourcesContentMetadata& metadata =
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
516 *reinterpret_cast<const OrthancPluginResourcesContentMetadata*>(answer.valueGeneric);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
517
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
518 MetadataType type = static_cast<MetadataType>(metadata.metadata);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
519
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
520 if (metadata.value == NULL)
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
521 {
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
522 throw OrthancException(ErrorCode_DatabasePlugin);
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
523 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
524
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
525 assert(answerMetadata_ != NULL &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
526 answerMetadata_->find(type) == answerMetadata_->end());
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
527 (*answerMetadata_) [type] = metadata.value;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
528 break;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
529 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
530
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
531 default:
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
532 throw OrthancException(ErrorCode_DatabasePlugin,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
533 "Unhandled type of answer for custom index plugin: " +
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
534 boost::lexical_cast<std::string>(answer.type));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
535 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
536 }
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
537
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
538
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
539 // From the "ILookupResources" interface
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
540 virtual void LookupIdentifier(std::list<int64_t>& result,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
541 ResourceType level,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
542 const DicomTag& tag,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
543 Compatibility::IdentifierConstraintType type,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
544 const std::string& value) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
545 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
546 if (that_.extensions_.lookupIdentifier3 == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
547 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
548 throw OrthancException(ErrorCode_DatabasePlugin,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
549 "The database plugin does not implement the mandatory LookupIdentifier3() extension");
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
550 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
551
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
552 OrthancPluginDicomTag tmp;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
553 tmp.group = tag.GetGroup();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
554 tmp.element = tag.GetElement();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
555 tmp.value = value.c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
556
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
557 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
558 CheckSuccess(that_.extensions_.lookupIdentifier3(that_.GetContext(), that_.payload_, Plugins::Convert(level),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
559 &tmp, Compatibility::Convert(type)));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
560 ForwardAnswers(result);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
561 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
562
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
563
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
564 virtual void ApplyLookupResources(std::list<std::string>& resourcesId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
565 std::list<std::string>* instancesId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
566 const std::vector<DatabaseConstraint>& lookup,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
567 ResourceType queryLevel,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
568 uint32_t limit) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
569 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
570 if (that_.extensions_.lookupResources == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
571 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
572 // Fallback to compatibility mode
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
573 ILookupResources::Apply
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
574 (*this, *this, resourcesId, instancesId, lookup, queryLevel, limit);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
575 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
576 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
577 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
578 std::vector<OrthancPluginDatabaseConstraint> constraints;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
579 std::vector< std::vector<const char*> > constraintsValues;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
580
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
581 constraints.resize(lookup.size());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
582 constraintsValues.resize(lookup.size());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
583
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
584 for (size_t i = 0; i < lookup.size(); i++)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
585 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
586 lookup[i].EncodeForPlugins(constraints[i], constraintsValues[i]);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
587 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
588
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
589 ResetAnswers();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
590 answerMatchingResources_ = &resourcesId;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
591 answerMatchingInstances_ = instancesId;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
592
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
593 CheckSuccess(that_.extensions_.lookupResources(that_.GetContext(), that_.payload_, lookup.size(),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
594 (lookup.empty() ? NULL : &constraints[0]),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
595 Plugins::Convert(queryLevel),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
596 limit, (instancesId == NULL ? 0 : 1)));
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
597 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
598 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
599
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
600
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
601 virtual bool CreateInstance(IDatabaseWrapper::CreateInstanceResult& result,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
602 int64_t& instanceId,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
603 const std::string& patient,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
604 const std::string& study,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
605 const std::string& series,
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
606 const std::string& instance) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
607 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
608 if (that_.extensions_.createInstance == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
609 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
610 // Fallback to compatibility mode
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
611 return ICreateInstance::Apply
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
612 (*this, result, instanceId, patient, study, series, instance);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
613 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
614 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
615 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
616 OrthancPluginCreateInstanceResult output;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
617 memset(&output, 0, sizeof(output));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
618
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
619 CheckSuccess(that_.extensions_.createInstance(&output, that_.payload_, patient.c_str(),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
620 study.c_str(), series.c_str(), instance.c_str()));
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
621
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
622 instanceId = output.instanceId;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
623
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
624 if (output.isNewInstance)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
625 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
626 result.isNewPatient_ = output.isNewPatient;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
627 result.isNewStudy_ = output.isNewStudy;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
628 result.isNewSeries_ = output.isNewSeries;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
629 result.patientId_ = output.patientId;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
630 result.studyId_ = output.studyId;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
631 result.seriesId_ = output.seriesId;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
632 return true;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
633 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
634 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
635 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
636 return false;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
637 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
638 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
639 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
640
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
641
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
642 virtual void AddAttachment(int64_t id,
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
643 const FileInfo& attachment,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
644 int64_t revision) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
645 {
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
646 // "revision" is not used, as it was added in Orthanc 1.9.2
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
647 OrthancPluginAttachment tmp;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
648 tmp.uuid = attachment.GetUuid().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
649 tmp.contentType = static_cast<int32_t>(attachment.GetContentType());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
650 tmp.uncompressedSize = attachment.GetUncompressedSize();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
651 tmp.uncompressedHash = attachment.GetUncompressedMD5().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
652 tmp.compressionType = static_cast<int32_t>(attachment.GetCompressionType());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
653 tmp.compressedSize = attachment.GetCompressedSize();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
654 tmp.compressedHash = attachment.GetCompressedMD5().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
655
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
656 CheckSuccess(that_.backend_.addAttachment(that_.payload_, id, &tmp));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
657 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
658
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
659
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
660 // From the "ICreateInstance" interface
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
661 virtual void AttachChild(int64_t parent,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
662 int64_t child) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
663 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
664 CheckSuccess(that_.backend_.attachChild(that_.payload_, parent, child));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
665 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
666
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
667
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
668 virtual void ClearChanges() ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
669 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
670 CheckSuccess(that_.backend_.clearChanges(that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
671 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
672
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
673
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
674 virtual void ClearExportedResources() ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
675 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
676 CheckSuccess(that_.backend_.clearExportedResources(that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
677 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
678
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
679
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
680 virtual void ClearMainDicomTags(int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
681 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
682 if (that_.extensions_.clearMainDicomTags == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
683 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
684 throw OrthancException(ErrorCode_DatabasePlugin,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
685 "Your custom index plugin does not implement the mandatory ClearMainDicomTags() extension");
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
686 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
687
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
688 CheckSuccess(that_.extensions_.clearMainDicomTags(that_.payload_, id));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
689 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
690
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
691
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
692 // From the "ICreateInstance" interface
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
693 virtual int64_t CreateResource(const std::string& publicId,
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
694 ResourceType type) ORTHANC_OVERRIDE
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
695 {
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
696 int64_t id;
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
697 CheckSuccess(that_.backend_.createResource(&id, that_.payload_, publicId.c_str(), Plugins::Convert(type)));
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
698 return id;
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
699 }
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
700
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
701
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
702 virtual void DeleteAttachment(int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
703 FileContentType attachment) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
704 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
705 CheckSuccess(that_.backend_.deleteAttachment(that_.payload_, id, static_cast<int32_t>(attachment)));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
706 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
707
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
708
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
709 virtual void DeleteMetadata(int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
710 MetadataType type) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
711 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
712 CheckSuccess(that_.backend_.deleteMetadata(that_.payload_, id, static_cast<int32_t>(type)));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
713 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
714
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
715
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
716 virtual void DeleteResource(int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
717 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
718 CheckSuccess(that_.backend_.deleteResource(that_.payload_, id));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
719 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
720
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
721
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
722 // From the "ILookupResources" interface
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
723 void GetAllInternalIds(std::list<int64_t>& target,
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
724 ResourceType resourceType) ORTHANC_OVERRIDE
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
725 {
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
726 if (that_.extensions_.getAllInternalIds == NULL)
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
727 {
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
728 throw OrthancException(ErrorCode_DatabasePlugin,
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
729 "The database plugin does not implement the mandatory GetAllInternalIds() extension");
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
730 }
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
731
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
732 ResetAnswers();
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
733 CheckSuccess(that_.extensions_.getAllInternalIds(that_.GetContext(), that_.payload_, Plugins::Convert(resourceType)));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
734 ForwardAnswers(target);
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
735 }
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
736
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
737
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
738
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
739 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
740 int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
741 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
742 if (that_.extensions_.getAllMetadata == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
743 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
744 // Fallback implementation if extension is missing
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
745 target.clear();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
746
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
747 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
748 CheckSuccess(that_.backend_.listAvailableMetadata(that_.GetContext(), that_.payload_, id));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
749
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
750 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
751 type_ != _OrthancPluginDatabaseAnswerType_Int32)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
752 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
753 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
754 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
755
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
756 target.clear();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
757
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
758 if (type_ == _OrthancPluginDatabaseAnswerType_Int32)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
759 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
760 for (std::list<int32_t>::const_iterator
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
761 it = answerInt32_.begin(); it != answerInt32_.end(); ++it)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
762 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
763 MetadataType type = static_cast<MetadataType>(*it);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
764
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
765 std::string value;
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
766 int64_t revision; // Ignored
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
767 if (LookupMetadata(value, revision, id, type))
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
768 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
769 target[type] = value;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
770 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
771 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
772 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
773 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
774 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
775 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
776 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
777
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
778 answerMetadata_ = &target;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
779 target.clear();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
780
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
781 CheckSuccess(that_.extensions_.getAllMetadata(that_.GetContext(), that_.payload_, id));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
782
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
783 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
784 type_ != _OrthancPluginDatabaseAnswerType_Metadata)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
785 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
786 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
787 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
788 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
789 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
790
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
791
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
792 virtual void GetAllPublicIds(std::list<std::string>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
793 ResourceType resourceType) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
794 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
795 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
796 CheckSuccess(that_.backend_.getAllPublicIds(that_.GetContext(), that_.payload_, Plugins::Convert(resourceType)));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
797 ForwardAnswers(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
798 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
799
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
800
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
801 virtual void GetAllPublicIds(std::list<std::string>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
802 ResourceType resourceType,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
803 int64_t since,
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
804 uint32_t limit) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
805 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
806 if (that_.extensions_.getAllPublicIdsWithLimit != NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
807 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
808 // This extension is available since Orthanc 0.9.4
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
809 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
810 CheckSuccess(that_.extensions_.getAllPublicIdsWithLimit
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
811 (that_.GetContext(), that_.payload_, Plugins::Convert(resourceType), since, limit));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
812 ForwardAnswers(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
813 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
814 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
815 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
816 // The extension is not available in the database plugin, use a
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
817 // fallback implementation
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
818 target.clear();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
819
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
820 if (limit == 0)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
821 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
822 return;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
823 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
824
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
825 std::list<std::string> tmp;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
826 GetAllPublicIds(tmp, resourceType);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
827
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
828 if (tmp.size() <= static_cast<size_t>(since))
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
829 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
830 // Not enough results => empty answer
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
831 return;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
832 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
833
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
834 std::list<std::string>::iterator current = tmp.begin();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
835 std::advance(current, since);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
836
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
837 while (limit > 0 && current != tmp.end())
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
838 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
839 target.push_back(*current);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
840 --limit;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
841 ++current;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
842 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
843 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
844 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
845
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
846
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
847 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
848 bool& done /*out*/,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
849 int64_t since,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
850 uint32_t limit) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
851 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
852 ResetAnswers();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
853 answerChanges_ = &target;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
854 answerDone_ = &done;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
855 done = false;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
856
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
857 CheckSuccess(that_.backend_.getChanges(that_.GetContext(), that_.payload_, since, limit));
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
858 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
859
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
860
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
861 virtual void GetChildrenInternalId(std::list<int64_t>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
862 int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
863 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
864 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
865 CheckSuccess(that_.backend_.getChildrenInternalId(that_.GetContext(), that_.payload_, id));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
866 ForwardAnswers(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
867 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
868
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
869
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
870 virtual void GetChildrenMetadata(std::list<std::string>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
871 int64_t resourceId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
872 MetadataType metadata) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
873 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
874 if (that_.extensions_.getChildrenMetadata == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
875 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
876 IGetChildrenMetadata::Apply(*this, target, resourceId, metadata);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
877 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
878 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
879 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
880 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
881 CheckSuccess(that_.extensions_.getChildrenMetadata
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
882 (that_.GetContext(), that_.payload_, resourceId, static_cast<int32_t>(metadata)));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
883 ForwardAnswers(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
884 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
885 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
886
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
887
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
888 virtual void GetChildrenPublicId(std::list<std::string>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
889 int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
890 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
891 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
892 CheckSuccess(that_.backend_.getChildrenPublicId(that_.GetContext(), that_.payload_, id));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
893 ForwardAnswers(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
894 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
895
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
896
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
897 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
898 bool& done /*out*/,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
899 int64_t since,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
900 uint32_t limit) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
901 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
902 ResetAnswers();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
903 answerExportedResources_ = &target;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
904 answerDone_ = &done;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
905 done = false;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
906
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5193
diff changeset
907 CheckSuccess(that_.backend_.getExportedResources(that_.GetContext(), that_.payload_, since, limit));
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
908 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
909
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
910
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
911 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
912 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
913 answerDoneIgnored_ = false;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
914
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
915 ResetAnswers();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
916 answerChanges_ = &target;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
917 answerDone_ = &answerDoneIgnored_;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
918
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
919 CheckSuccess(that_.backend_.getLastChange(that_.GetContext(), that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
920 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
921
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
922
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
923 int64_t GetLastChangeIndex() ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
924 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
925 if (that_.extensions_.getLastChangeIndex == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
926 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
927 // This was the default behavior in Orthanc <= 1.5.1
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
928 // https://groups.google.com/d/msg/orthanc-users/QhzB6vxYeZ0/YxabgqpfBAAJ
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
929 return 0;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
930 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
931 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
932 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
933 int64_t result = 0;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
934 CheckSuccess(that_.extensions_.getLastChangeIndex(&result, that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
935 return result;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
936 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
937 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
938
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
939
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
940 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
941 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
942 answerDoneIgnored_ = false;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
943
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
944 ResetAnswers();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
945 answerExportedResources_ = &target;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
946 answerDone_ = &answerDoneIgnored_;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
947
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
948 CheckSuccess(that_.backend_.getLastExportedResource(that_.GetContext(), that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
949 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
950
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
951
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
952 virtual void GetMainDicomTags(DicomMap& map,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
953 int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
954 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
955 ResetAnswers();
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
956 answerDicomMap_ = &map;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
957
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
958 CheckSuccess(that_.backend_.getMainDicomTags(that_.GetContext(), that_.payload_, id));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
959 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
960
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
961
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
962 virtual std::string GetPublicId(int64_t resourceId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
963 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
964 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
965 std::string s;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
966
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
967 CheckSuccess(that_.backend_.getPublicId(that_.GetContext(), that_.payload_, resourceId));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
968
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
969 if (!ForwardSingleAnswer(s))
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
970 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
971 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
972 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
973
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
974 return s;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
975 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
976
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
977
4595
cc64385593ef added OrthancPluginRegisterDatabaseBackendV3() to plugin sdk
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4594
diff changeset
978 virtual uint64_t GetResourcesCount(ResourceType resourceType) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
979 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
980 uint64_t count;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
981 CheckSuccess(that_.backend_.getResourceCount(&count, that_.payload_, Plugins::Convert(resourceType)));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
982 return count;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
983 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
984
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
985
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
986 virtual ResourceType GetResourceType(int64_t resourceId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
987 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
988 OrthancPluginResourceType type;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
989 CheckSuccess(that_.backend_.getResourceType(&type, that_.payload_, resourceId));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
990 return Plugins::Convert(type);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
991 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
992
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
993
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
994 virtual uint64_t GetTotalCompressedSize() ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
995 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
996 uint64_t size;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
997 CheckSuccess(that_.backend_.getTotalCompressedSize(&size, that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
998 return size;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
999 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1000
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1001
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1002 virtual uint64_t GetTotalUncompressedSize() ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1003 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1004 uint64_t size;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1005 CheckSuccess(that_.backend_.getTotalUncompressedSize(&size, that_.payload_));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1006 return size;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1007 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1008
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1009
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1010 virtual bool IsDiskSizeAbove(uint64_t threshold) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1011 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1012 if (that_.fastGetTotalSize_)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1013 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1014 return GetTotalCompressedSize() > threshold;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1015 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1016 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1017 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1018 assert(GetTotalCompressedSize() == that_.currentDiskSize_);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1019 return that_.currentDiskSize_ > threshold;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1020 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1021 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1022
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1023
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1024 virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1025 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1026 int32_t isProtected;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1027 CheckSuccess(that_.backend_.isProtectedPatient(&isProtected, that_.payload_, internalId));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1028 return (isProtected != 0);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1029 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1030
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1031
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1032 virtual void ListAvailableAttachments(std::set<FileContentType>& target,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1033 int64_t id) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1034 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1035 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1036
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1037 CheckSuccess(that_.backend_.listAvailableAttachments(that_.GetContext(), that_.payload_, id));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1038
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1039 if (type_ != _OrthancPluginDatabaseAnswerType_None &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1040 type_ != _OrthancPluginDatabaseAnswerType_Int32)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1041 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1042 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1043 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1044
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1045 target.clear();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1046
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1047 if (type_ == _OrthancPluginDatabaseAnswerType_Int32)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1048 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1049 for (std::list<int32_t>::const_iterator
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1050 it = answerInt32_.begin(); it != answerInt32_.end(); ++it)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1051 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1052 target.insert(static_cast<FileContentType>(*it));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1053 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1054 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1055 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1056
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1057
5216
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1058 virtual void LogChange(ChangeType changeType,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1059 ResourceType resourceType,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1060 int64_t internalId,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1061 const std::string& publicId,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1062 const std::string& date) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1063 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1064 OrthancPluginChange tmp;
5216
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1065 tmp.seq = -1; // Unused (it is attributed by the database engine)
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1066 tmp.changeType = static_cast<int32_t>(changeType);
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1067 tmp.resourceType = Plugins::Convert(resourceType);
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1068 tmp.publicId = publicId.c_str();
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
1069 tmp.date = date.c_str();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1070
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1071 CheckSuccess(that_.backend_.logChange(that_.payload_, &tmp));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1072 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1073
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1074
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1075 virtual void LogExportedResource(const ExportedResource& resource) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1076 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1077 OrthancPluginExportedResource tmp;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1078 tmp.seq = resource.GetSeq();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1079 tmp.resourceType = Plugins::Convert(resource.GetResourceType());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1080 tmp.publicId = resource.GetPublicId().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1081 tmp.modality = resource.GetModality().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1082 tmp.date = resource.GetDate().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1083 tmp.patientId = resource.GetPatientId().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1084 tmp.studyInstanceUid = resource.GetStudyInstanceUid().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1085 tmp.seriesInstanceUid = resource.GetSeriesInstanceUid().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1086 tmp.sopInstanceUid = resource.GetSopInstanceUid().c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1087
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1088 CheckSuccess(that_.backend_.logExportedResource(that_.payload_, &tmp));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1089 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1090
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1091
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1092 virtual bool LookupAttachment(FileInfo& attachment,
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1093 int64_t& revision,
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1094 int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1095 FileContentType contentType) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1096 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1097 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1098
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1099 CheckSuccess(that_.backend_.lookupAttachment
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1100 (that_.GetContext(), that_.payload_, id, static_cast<int32_t>(contentType)));
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1101
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4623
diff changeset
1102 revision = 0; // Dummy value, as revisions were added in Orthanc 1.9.2
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1103
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1104 if (type_ == _OrthancPluginDatabaseAnswerType_None)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1105 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1106 return false;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1107 }
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1108 else if (type_ == _OrthancPluginDatabaseAnswerType_Attachment &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1109 answerAttachments_.size() == 1)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1110 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1111 attachment = answerAttachments_.front();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1112 return true;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1113 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1114 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1115 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1116 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1117 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1118 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1119
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1120
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1121 virtual bool LookupGlobalProperty(std::string& target,
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1122 GlobalProperty property,
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1123 bool shared) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1124 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1125 // "shared" is unused, as database plugins using Orthanc SDK <=
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1126 // 1.9.1 are not compatible with multiple readers/writers
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1127
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1128 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1129
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1130 CheckSuccess(that_.backend_.lookupGlobalProperty
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1131 (that_.GetContext(), that_.payload_, static_cast<int32_t>(property)));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1132
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1133 return ForwardSingleAnswer(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1134 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1135
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1136
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
1137 // From the "ILookupResources" interface
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1138 virtual void LookupIdentifierRange(std::list<int64_t>& result,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1139 ResourceType level,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1140 const DicomTag& tag,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1141 const std::string& start,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1142 const std::string& end) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1143 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1144 if (that_.extensions_.lookupIdentifierRange == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1145 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1146 // Default implementation, for plugins using Orthanc SDK <= 1.3.2
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1147
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1148 LookupIdentifier(result, level, tag, Compatibility::IdentifierConstraintType_GreaterOrEqual, start);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1149
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1150 std::list<int64_t> b;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1151 LookupIdentifier(result, level, tag, Compatibility::IdentifierConstraintType_SmallerOrEqual, end);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1152
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1153 result.splice(result.end(), b);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1154 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1155 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1156 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1157 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1158 CheckSuccess(that_.extensions_.lookupIdentifierRange(that_.GetContext(), that_.payload_, Plugins::Convert(level),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1159 tag.GetGroup(), tag.GetElement(),
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1160 start.c_str(), end.c_str()));
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1161 ForwardAnswers(result);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1162 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1163 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1164
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1165
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1166 virtual bool LookupMetadata(std::string& target,
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1167 int64_t& revision,
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1168 int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1169 MetadataType type) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1170 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1171 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1172 CheckSuccess(that_.backend_.lookupMetadata(that_.GetContext(), that_.payload_, id, static_cast<int32_t>(type)));
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1173 revision = 0; // Dummy value, as revisions were added in Orthanc 1.9.2
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1174 return ForwardSingleAnswer(target);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1175 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1176
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1177
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1178 virtual bool LookupParent(int64_t& parentId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1179 int64_t resourceId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1180 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1181 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1182 CheckSuccess(that_.backend_.lookupParent(that_.GetContext(), that_.payload_, resourceId));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1183 return ForwardSingleAnswer(parentId);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1184 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1185
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1186
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1187 virtual bool LookupResource(int64_t& id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1188 ResourceType& type,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1189 const std::string& publicId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1190 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1191 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1192
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1193 CheckSuccess(that_.backend_.lookupResource(that_.GetContext(), that_.payload_, publicId.c_str()));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1194
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1195 if (type_ == _OrthancPluginDatabaseAnswerType_None)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1196 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1197 return false;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1198 }
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1199 else if (type_ == _OrthancPluginDatabaseAnswerType_Resource &&
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1200 answerResources_.size() == 1)
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1201 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1202 id = answerResources_.front().first;
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1203 type = answerResources_.front().second;
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1204 return true;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1205 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1206 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1207 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1208 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1209 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1210 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1211
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1212
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1213 virtual bool LookupResourceAndParent(int64_t& id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1214 ResourceType& type,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1215 std::string& parentPublicId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1216 const std::string& publicId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1217 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1218 if (that_.extensions_.lookupResourceAndParent == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1219 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1220 return ILookupResourceAndParent::Apply(*this, id, type, parentPublicId, publicId);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1221 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1222 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1223 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1224 std::list<std::string> parent;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1225
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1226 uint8_t isExisting;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1227 OrthancPluginResourceType pluginType = OrthancPluginResourceType_Patient;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1228
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1229 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1230 CheckSuccess(that_.extensions_.lookupResourceAndParent
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1231 (that_.GetContext(), &isExisting, &id, &pluginType, that_.payload_, publicId.c_str()));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1232 ForwardAnswers(parent);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1233
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1234 if (isExisting)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1235 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1236 type = Plugins::Convert(pluginType);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1237
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1238 if (parent.empty())
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1239 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1240 if (type != ResourceType_Patient)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1241 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1242 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1243 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1244 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1245 else if (parent.size() == 1)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1246 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1247 if ((type != ResourceType_Study &&
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1248 type != ResourceType_Series &&
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1249 type != ResourceType_Instance) ||
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1250 parent.front().empty())
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1251 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1252 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1253 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1254
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1255 parentPublicId = parent.front();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1256 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1257 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1258 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1259 throw OrthancException(ErrorCode_DatabasePlugin);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1260 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1261
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1262 return true;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1263 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1264 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1265 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1266 return false;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1267 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1268 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1269 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1270
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1271
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1272 virtual bool SelectPatientToRecycle(int64_t& internalId) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1273 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1274 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1275 CheckSuccess(that_.backend_.selectPatientToRecycle(that_.GetContext(), that_.payload_));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1276 return ForwardSingleAnswer(internalId);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1277 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1278
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1279
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1280 virtual bool SelectPatientToRecycle(int64_t& internalId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1281 int64_t patientIdToAvoid) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1282 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1283 ResetAnswers();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1284 CheckSuccess(that_.backend_.selectPatientToRecycle2(that_.GetContext(), that_.payload_, patientIdToAvoid));
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1285 return ForwardSingleAnswer(internalId);
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1286 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1287
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1288
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1289 virtual void SetGlobalProperty(GlobalProperty property,
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1290 bool shared,
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1291 const std::string& value) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1292 {
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1293 // "shared" is unused, as database plugins using Orthanc SDK <=
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1294 // 1.9.1 are not compatible with multiple readers/writers
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1295
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1296 CheckSuccess(that_.backend_.setGlobalProperty
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1297 (that_.payload_, static_cast<int32_t>(property), value.c_str()));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1298 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1299
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1300
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
1301 // From the "ISetResourcesContent" interface
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1302 virtual void SetIdentifierTag(int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1303 const DicomTag& tag,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1304 const std::string& value) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1305 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1306 OrthancPluginDicomTag tmp;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1307 tmp.group = tag.GetGroup();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1308 tmp.element = tag.GetElement();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1309 tmp.value = value.c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1310
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1311 CheckSuccess(that_.backend_.setIdentifierTag(that_.payload_, id, &tmp));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1312 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1313
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1314
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
1315 // From the "ISetResourcesContent" interface
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1316 virtual void SetMainDicomTag(int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1317 const DicomTag& tag,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1318 const std::string& value) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1319 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1320 OrthancPluginDicomTag tmp;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1321 tmp.group = tag.GetGroup();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1322 tmp.element = tag.GetElement();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1323 tmp.value = value.c_str();
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1324
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1325 CheckSuccess(that_.backend_.setMainDicomTag(that_.payload_, id, &tmp));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1326 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1327
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1328
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1329 virtual void SetMetadata(int64_t id,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1330 MetadataType type,
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1331 const std::string& value,
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1332 int64_t revision) ORTHANC_OVERRIDE
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1333 {
4623
95ffe3b6ef7c handling of revisions for metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4607
diff changeset
1334 // "revision" is not used, as it was added in Orthanc 1.9.2
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1335 CheckSuccess(that_.backend_.setMetadata
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1336 (that_.payload_, id, static_cast<int32_t>(type), value.c_str()));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1337 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1338
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1339
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1340 virtual void SetProtectedPatient(int64_t internalId,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1341 bool isProtected) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1342 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1343 CheckSuccess(that_.backend_.setProtectedPatient(that_.payload_, internalId, isProtected));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1344 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1345
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1346
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
1347 // From the "ISetResourcesContent" interface
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1348 virtual void SetResourcesContent(const Orthanc::ResourcesContent& content) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1349 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1350 if (that_.extensions_.setResourcesContent == NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1351 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1352 ISetResourcesContent::Apply(*this, content);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1353 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1354 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1355 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1356 std::vector<OrthancPluginResourcesContentTags> identifierTags;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1357 std::vector<OrthancPluginResourcesContentTags> mainDicomTags;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1358 std::vector<OrthancPluginResourcesContentMetadata> metadata;
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1359
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1360 identifierTags.reserve(content.GetListTags().size());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1361 mainDicomTags.reserve(content.GetListTags().size());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1362 metadata.reserve(content.GetListMetadata().size());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1363
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1364 for (ResourcesContent::ListTags::const_iterator
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1365 it = content.GetListTags().begin(); it != content.GetListTags().end(); ++it)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1366 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1367 OrthancPluginResourcesContentTags tmp;
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1368 tmp.resource = it->GetResourceId();
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1369 tmp.group = it->GetTag().GetGroup();
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1370 tmp.element = it->GetTag().GetElement();
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1371 tmp.value = it->GetValue().c_str();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1372
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1373 if (it->IsIdentifier())
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1374 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1375 identifierTags.push_back(tmp);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1376 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1377 else
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1378 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1379 mainDicomTags.push_back(tmp);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1380 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1381 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1382
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1383 for (ResourcesContent::ListMetadata::const_iterator
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1384 it = content.GetListMetadata().begin(); it != content.GetListMetadata().end(); ++it)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1385 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1386 OrthancPluginResourcesContentMetadata tmp;
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1387 tmp.resource = it->GetResourceId();
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1388 tmp.metadata = it->GetType();
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1389 tmp.value = it->GetValue().c_str();
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1390 metadata.push_back(tmp);
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1391 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1392
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1393 assert(identifierTags.size() + mainDicomTags.size() == content.GetListTags().size() &&
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1394 metadata.size() == content.GetListMetadata().size());
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1395
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1396 CheckSuccess(that_.extensions_.setResourcesContent(
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1397 that_.payload_,
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1398 identifierTags.size(),
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1399 (identifierTags.empty() ? NULL : &identifierTags[0]),
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1400 mainDicomTags.size(),
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1401 (mainDicomTags.empty() ? NULL : &mainDicomTags[0]),
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1402 metadata.size(),
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1403 (metadata.empty() ? NULL : &metadata[0])));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1404 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1405 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1406
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1407
4592
36bbf3169a27 comments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4591
diff changeset
1408 // From the "ICreateInstance" interface
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1409 virtual void TagMostRecentPatient(int64_t patient) ORTHANC_OVERRIDE
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1410 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1411 if (that_.extensions_.tagMostRecentPatient != NULL)
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1412 {
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1413 CheckSuccess(that_.extensions_.tagMostRecentPatient(that_.payload_, patient));
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1414 }
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1415 }
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1416 };
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1417
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1418
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1419 void OrthancPluginDatabase::CheckSuccess(OrthancPluginErrorCode code)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1420 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1421 if (code != OrthancPluginErrorCode_Success)
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1422 {
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1423 errorDictionary_.LogError(code, true);
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1424 throw OrthancException(static_cast<ErrorCode>(code));
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1425 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1426 }
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1427
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1428
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
1429 OrthancPluginDatabase::OrthancPluginDatabase(SharedLibrary& library,
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1430 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
1431 const OrthancPluginDatabaseBackend& backend,
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1432 const OrthancPluginDatabaseExtensions* extensions,
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1433 size_t extensionsSize,
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1434 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
1435 library_(library),
1651
2e692c83e2f3 improved custom error login
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1646
diff changeset
1436 errorDictionary_(errorDictionary),
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1437 backend_(backend),
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1438 payload_(payload),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1439 activeTransaction_(NULL),
4204
318c16cfccab cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4045
diff changeset
1440 fastGetTotalSize_(false),
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1441 currentDiskSize_(0)
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1442 {
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1443 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
1444
1609
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1445 memset(&extensions_, 0, sizeof(extensions_));
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1446
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1447 size_t size = sizeof(extensions_);
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1448 if (extensionsSize < size)
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1449 {
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1450 size = extensionsSize; // Not all the extensions are available
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1451 }
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1452
c74495267acf Implementation of the "GetAllPublicIdsWithLimit" extension
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
1453 memcpy(&extensions_, extensions, size);
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1454
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1455 bool isOptimal = true;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1456
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1457 if (extensions_.lookupResources == NULL)
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1458 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1459 CLOG(INFO, PLUGINS) << MISSING << "LookupIdentifierRange()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1460 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1461 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1462
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1463 if (extensions_.createInstance == NULL)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1464 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1465 CLOG(INFO, PLUGINS) << MISSING << "CreateInstance()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1466 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1467 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1468
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1469 if (extensions_.setResourcesContent == NULL)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1470 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1471 CLOG(INFO, PLUGINS) << MISSING << "SetResourcesContent()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1472 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1473 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1474
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1475 if (extensions_.getChildrenMetadata == NULL)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1476 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1477 CLOG(INFO, PLUGINS) << MISSING << "GetChildrenMetadata()";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1478 isOptimal = false;
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1479 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1480
3190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1481 if (extensions_.getAllMetadata == NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1482 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1483 CLOG(INFO, PLUGINS) << MISSING << "GetAllMetadata()";
3190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1484 isOptimal = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1485 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1486
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1487 if (extensions_.lookupResourceAndParent == NULL)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1488 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1489 CLOG(INFO, PLUGINS) << MISSING << "LookupResourceAndParent()";
3190
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1490 isOptimal = false;
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1491 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3189
diff changeset
1492
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1493 if (isOptimal)
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1494 {
4271
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1495 CLOG(INFO, PLUGINS) << "The performance of the database index plugin "
1bd14c900699 LogCategory_PLUGINS
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4204
diff changeset
1496 << "is optimal for this version of Orthanc";
3101
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1497 }
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1498 else
b2b6db5ad9a5 warn about missing extensions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3099
diff changeset
1499 {
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
1500 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
1501 << "Some extensions are missing in the plugin";
3076
8bc2cb1335f4 OrthancPluginDatabase::ApplyLookupResources() using fast lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3075
diff changeset
1502 }
3105
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1503
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1504 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
1505 {
2e1711f80f74 More consistent handling of the "Last" field returned by the "/changes" URI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3101
diff changeset
1506 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
1507 }
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
1508
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
1509 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
1510 {
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
1511 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
1512 << "(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
1513 }
1314
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1514 }
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1515
01be1432bda9 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1309
diff changeset
1516
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1517 void OrthancPluginDatabase::Open()
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1518 {
4594
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1519 {
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1520 boost::recursive_mutex::scoped_lock lock(mutex_);
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1521 CheckSuccess(backend_.open(payload_));
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1522 }
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1523
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1524 VoidDatabaseListener listener;
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1525
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1526 {
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1527 Transaction transaction(*this, listener);
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1528 transaction.Begin();
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1529
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1530 std::string tmp;
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1531 fastGetTotalSize_ =
4607
f75c63aa9de0 differentiating between shared and private global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4595
diff changeset
1532 (transaction.LookupGlobalProperty(tmp, GlobalProperty_GetTotalSizeIsFast, true /* unused in old databases */) &&
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1533 tmp == "1");
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1534
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1535 if (fastGetTotalSize_)
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1536 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1537 currentDiskSize_ = 0; // Unused
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1538 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1539 else
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1540 {
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1541 // 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
1542 LOG(WARNING) << "Your database index plugin is not compatible with multiple Orthanc writers";
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1543 currentDiskSize_ = transaction.GetTotalCompressedSize();
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1544 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1545
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1546 transaction.Commit(0);
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1547 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1548 }
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1549
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1550
4594
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1551 void OrthancPluginDatabase::Close()
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1552 {
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1553 boost::recursive_mutex::scoped_lock lock(mutex_);
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1554 CheckSuccess(backend_.close(payload_));
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1555 }
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1556
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1557
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1558 IDatabaseWrapper::ITransaction* OrthancPluginDatabase::StartTransaction(TransactionType type,
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1559 IDatabaseListener& listener)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1560 {
4570
648defffc8cc new enum: TransactionType
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4556
diff changeset
1561 // TODO - Take advantage of "type"
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1562
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1563 std::unique_ptr<Transaction> transaction(new Transaction(*this, listener));
4556
2a0f8031fb93 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
1564 transaction->Begin();
2a0f8031fb93 removed abstraction IDatabaseWrapper::ITransaction::Begin(), must be done by IDatabaseWrapper::StartTransaction()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4514
diff changeset
1565 return transaction.release();
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1566 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1567
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1568
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1569 unsigned int OrthancPluginDatabase::GetDatabaseVersion()
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1570 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1571 if (extensions_.getDatabaseVersion != NULL)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1572 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1573 uint32_t version;
1672
4c5a85c3ff43 sample database plugin now working
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1668
diff changeset
1574 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
1575 return version;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1576 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1577 else
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1578 {
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1579 // 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
1580 // (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
1581 // version 5.
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1582 return 5;
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1583 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1584 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1585
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1586
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1587 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
1588 IStorageArea& storageArea)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1589 {
4591
ff8170d17d90 moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4589
diff changeset
1590 VoidDatabaseListener listener;
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1591
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1592 if (extensions_.upgradeDatabase != NULL)
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1593 {
4589
bec74e29f86b attaching the listener to transactions in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4571
diff changeset
1594 Transaction transaction(*this, listener);
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1595 transaction.Begin();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1596
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1597 OrthancPluginErrorCode code = extensions_.upgradeDatabase(
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1598 payload_, targetVersion,
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1599 reinterpret_cast<OrthancPluginStorageArea*>(&storageArea));
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1600
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1601 if (code == OrthancPluginErrorCode_Success)
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1602 {
3019
8336204d95dc refactoring computation of disk size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2956
diff changeset
1603 transaction.Commit(0);
1673
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1604 }
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1605 else
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1606 {
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1607 transaction.Rollback();
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1608 errorDictionary_.LogError(code, true);
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1609 throw OrthancException(static_cast<ErrorCode>(code));
0bbcfd9695e5 UpgradeDatabase in the sample plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1672
diff changeset
1610 }
1615
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1611 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1612 }
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1613
c40fe92a68e7 Primitives to upgrade the database version in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1609
diff changeset
1614
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1615 void OrthancPluginDatabase::AnswerReceived(const _OrthancPluginDatabaseAnswer& answer)
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1616 {
4594
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1617 boost::recursive_mutex::scoped_lock lock(mutex_);
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1618
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1619 if (activeTransaction_ != NULL)
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1620 {
4593
60a860942c5e moved handling of answers from database plugins from OrthancPluginDatabase to its Transaction subclass
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4592
diff changeset
1621 activeTransaction_->AnswerReceived(answer);
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1622 }
4594
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1623 else
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1624 {
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1625 LOG(WARNING) << "Received an answer from the database index plugin, but not transaction is active";
d494b4f1103e removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4593
diff changeset
1626 }
1309
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1627 }
8f4487d8f79e new files for custom database back-end
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1628 }