annotate Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 403:91124cc8a8c7 db-protobuf

database plugins are informed about the identifier tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Apr 2023 11:10:19 +0200
parents a8774581adfc
children ecd0b719cff5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
389
3d6886f3e5b3 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
3d6886f3e5b3 upgrade to year 2023
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 378
diff changeset
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU Affero General Public License
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * as published by the Free Software Foundation, either version 3 of
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * the License, or (at your option) any later version.
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful, but
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * Affero General Public License for more details.
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 *
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU Affero General Public License
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "DatabaseBackendAdapterV3.h"
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 9, 2)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
28 #include "IndexConnectionsPool.h"
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
29
260
793bbbe11287 IDatabaseBackend::HasRevisionsSupport()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 256
diff changeset
30 #include <Logging.h>
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #include <OrthancException.h>
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include <stdexcept>
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include <list>
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include <string>
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include <cassert>
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 #define ORTHANC_PLUGINS_DATABASE_CATCH(context) \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 catch (::Orthanc::OrthancException& e) \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 { \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 return static_cast<OrthancPluginErrorCode>(e.GetErrorCode()); \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 } \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 catch (::std::runtime_error& e) \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 { \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 const std::string message = "Exception in database back-end: " + std::string(e.what()); \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 OrthancPluginLogError(context, message.c_str()); \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 return OrthancPluginErrorCode_DatabasePlugin; \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 } \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 catch (...) \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 { \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 OrthancPluginLogError(context, "Native exception"); \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 return OrthancPluginErrorCode_DatabasePlugin; \
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 namespace OrthancDatabases
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
59 static bool isBackendInUse_ = false; // Only for sanity checks
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
60
235
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
61
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
62 template <typename T>
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
63 static void CopyListToVector(std::vector<T>& target,
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
64 const std::list<T>& source)
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
65 {
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
66 /**
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
67 * This has the the same effect as:
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
68 *
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
69 * target.reserve(source.size());
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
70 * std::copy(std::begin(source), std::end(source), std::back_inserter(target));
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
71 *
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
72 * However, this implementation is compatible with C++03 (Linux
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
73 * Standard Base), whereas "std::back_inserter" requires C++11.
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
74 **/
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
75
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
76 target.clear();
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
77 target.reserve(source.size());
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
78
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
79 for (typename std::list<T>::const_iterator it = source.begin(); it != source.end(); ++it)
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
80 {
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
81 target.push_back(*it);
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
82 }
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
83 }
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
84
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
85
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 class DatabaseBackendAdapterV3::Output : public IDatabaseBackendOutput
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 private:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 struct Metadata
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 int32_t metadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 const char* value;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 };
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 _OrthancPluginDatabaseAnswerType answerType_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 std::list<std::string> stringsStore_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 std::vector<OrthancPluginAttachment> attachments_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 std::vector<OrthancPluginChange> changes_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 std::vector<OrthancPluginDicomTag> tags_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 std::vector<OrthancPluginExportedResource> exported_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 std::vector<OrthancPluginDatabaseEvent> events_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 std::vector<int32_t> integers32_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 std::vector<int64_t> integers64_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 std::vector<OrthancPluginMatchingResource> matches_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 std::vector<Metadata> metadata_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 std::vector<std::string> stringAnswers_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 const char* StoreString(const std::string& s)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 stringsStore_.push_back(s);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 return stringsStore_.back().c_str();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 void SetupAnswerType(_OrthancPluginDatabaseAnswerType type)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 if (answerType_ == _OrthancPluginDatabaseAnswerType_None)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 answerType_ = type;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 else if (answerType_ != type)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 public:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 Output() :
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 answerType_(_OrthancPluginDatabaseAnswerType_None)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 void Clear()
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 // We don't systematically clear all the vectors, in order to
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 // avoid spending unnecessary time
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 switch (answerType_)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 case _OrthancPluginDatabaseAnswerType_None:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 case _OrthancPluginDatabaseAnswerType_Attachment:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 attachments_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 case _OrthancPluginDatabaseAnswerType_Change:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 changes_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 case _OrthancPluginDatabaseAnswerType_DicomTag:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 tags_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 case _OrthancPluginDatabaseAnswerType_ExportedResource:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 exported_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 case _OrthancPluginDatabaseAnswerType_Int32:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 integers32_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 case _OrthancPluginDatabaseAnswerType_Int64:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 integers64_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 case _OrthancPluginDatabaseAnswerType_MatchingResource:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 matches_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 case _OrthancPluginDatabaseAnswerType_Metadata:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 metadata_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 case _OrthancPluginDatabaseAnswerType_String:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 stringAnswers_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 default:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 answerType_ = _OrthancPluginDatabaseAnswerType_None;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 stringsStore_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 events_.clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 assert(attachments_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 assert(changes_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 assert(tags_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 assert(exported_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 assert(events_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 assert(integers32_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 assert(integers64_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 assert(matches_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195 assert(metadata_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 assert(stringAnswers_.empty());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 OrthancPluginErrorCode ReadAnswersCount(uint32_t& target) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 switch (answerType_)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 case _OrthancPluginDatabaseAnswerType_None:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 target = static_cast<uint32_t>(0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 case _OrthancPluginDatabaseAnswerType_Attachment:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 target = static_cast<uint32_t>(attachments_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 case _OrthancPluginDatabaseAnswerType_Change:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 target = static_cast<uint32_t>(changes_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 case _OrthancPluginDatabaseAnswerType_DicomTag:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 target = static_cast<uint32_t>(tags_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 case _OrthancPluginDatabaseAnswerType_ExportedResource:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 target = static_cast<uint32_t>(exported_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 case _OrthancPluginDatabaseAnswerType_Int32:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 target = static_cast<uint32_t>(integers32_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 case _OrthancPluginDatabaseAnswerType_Int64:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 target = static_cast<uint32_t>(integers64_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 case _OrthancPluginDatabaseAnswerType_MatchingResource:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 target = static_cast<uint32_t>(matches_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 case _OrthancPluginDatabaseAnswerType_Metadata:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 target = static_cast<uint32_t>(metadata_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 case _OrthancPluginDatabaseAnswerType_String:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 target = static_cast<uint32_t>(stringAnswers_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 default:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 return OrthancPluginErrorCode_InternalError;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 OrthancPluginErrorCode ReadAnswerAttachment(OrthancPluginAttachment& target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 if (index < attachments_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 target = attachments_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 OrthancPluginErrorCode ReadAnswerChange(OrthancPluginChange& target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 if (index < changes_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 target = changes_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 OrthancPluginErrorCode ReadAnswerDicomTag(uint16_t& group,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 uint16_t& element,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 const char*& value,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 if (index < tags_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 const OrthancPluginDicomTag& tag = tags_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 group = tag.group;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 element = tag.element;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 value = tag.value;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 OrthancPluginErrorCode ReadAnswerExportedResource(OrthancPluginExportedResource& target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 if (index < exported_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 target = exported_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
317 OrthancPluginErrorCode ReadAnswerInt32(int32_t& target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320 if (index < integers32_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 target = integers32_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
323 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
324 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
325 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 OrthancPluginErrorCode ReadAnswerInt64(int64_t& target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 if (index < integers64_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 target = integers64_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
338 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
339 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
340 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
341 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
342 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
343 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
344 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
345
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347 OrthancPluginErrorCode ReadAnswerMatchingResource(OrthancPluginMatchingResource& target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 if (index < matches_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
351 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 target = matches_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
357 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 OrthancPluginErrorCode ReadAnswerMetadata(int32_t& metadata,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 const char*& value,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 if (index < metadata_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 const Metadata& tmp = metadata_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 metadata = tmp.metadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 value = tmp.value;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
379
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
380 OrthancPluginErrorCode ReadAnswerString(const char*& target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
381 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
382 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 if (index < stringAnswers_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385 target = stringAnswers_[index].c_str();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
388 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
389 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
390 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
391 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
392 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395 OrthancPluginErrorCode ReadEventsCount(uint32_t& target /* out */) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
396 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
397 target = static_cast<uint32_t>(events_.size());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
398 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
399 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
400
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
401
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
402 OrthancPluginErrorCode ReadEvent(OrthancPluginDatabaseEvent& event /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
403 uint32_t index) const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
404 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
405 if (index < events_.size())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
406 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
407 event = events_[index];
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
408 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
409 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412 return OrthancPluginErrorCode_ParameterOutOfRange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 virtual void SignalDeletedAttachment(const std::string& uuid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
418 int32_t contentType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 uint64_t uncompressedSize,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 const std::string& uncompressedHash,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421 int32_t compressionType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
422 uint64_t compressedSize,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 const std::string& compressedHash) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425 OrthancPluginDatabaseEvent event;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
426 event.type = OrthancPluginDatabaseEventType_DeletedAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 event.content.attachment.uuid = StoreString(uuid);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 event.content.attachment.contentType = contentType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429 event.content.attachment.uncompressedSize = uncompressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 event.content.attachment.uncompressedHash = StoreString(uncompressedHash);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 event.content.attachment.compressionType = compressionType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 event.content.attachment.compressedSize = compressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433 event.content.attachment.compressedHash = StoreString(compressedHash);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
435 events_.push_back(event);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 virtual void SignalDeletedResource(const std::string& publicId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 OrthancPluginResourceType resourceType) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
442 OrthancPluginDatabaseEvent event;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
443 event.type = OrthancPluginDatabaseEventType_DeletedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
444 event.content.resource.level = resourceType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
445 event.content.resource.publicId = StoreString(publicId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
447 events_.push_back(event);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
448 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
449
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
450
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
451 virtual void SignalRemainingAncestor(const std::string& ancestorId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
452 OrthancPluginResourceType ancestorType) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454 OrthancPluginDatabaseEvent event;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455 event.type = OrthancPluginDatabaseEventType_RemainingAncestor;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 event.content.resource.level = ancestorType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 event.content.resource.publicId = StoreString(ancestorId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
458
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 events_.push_back(event);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
462
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
463 virtual void AnswerAttachment(const std::string& uuid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
464 int32_t contentType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
465 uint64_t uncompressedSize,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
466 const std::string& uncompressedHash,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
467 int32_t compressionType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 uint64_t compressedSize,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 const std::string& compressedHash) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
470 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
471 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Attachment);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
472
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
473 OrthancPluginAttachment attachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 attachment.uuid = StoreString(uuid);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475 attachment.contentType = contentType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476 attachment.uncompressedSize = uncompressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 attachment.uncompressedHash = StoreString(uncompressedHash);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 attachment.compressionType = compressionType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 attachment.compressedSize = compressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
480 attachment.compressedHash = StoreString(compressedHash);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 attachments_.push_back(attachment);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
484
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 virtual void AnswerChange(int64_t seq,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
487 int32_t changeType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
488 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
489 const std::string& publicId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
490 const std::string& date) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
491 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
492 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Change);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494 OrthancPluginChange change;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 change.seq = seq;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 change.changeType = changeType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 change.resourceType = resourceType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498 change.publicId = StoreString(publicId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 change.date = StoreString(date);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 changes_.push_back(change);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
502 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
503
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
504
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
505 virtual void AnswerDicomTag(uint16_t group,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
506 uint16_t element,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
507 const std::string& value) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
508 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
509 SetupAnswerType(_OrthancPluginDatabaseAnswerType_DicomTag);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
510
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
511 OrthancPluginDicomTag tag;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
512 tag.group = group;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 tag.element = element;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514 tag.value = StoreString(value);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 tags_.push_back(tag);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
519
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
520 virtual void AnswerExportedResource(int64_t seq,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
521 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
522 const std::string& publicId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
523 const std::string& modality,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
524 const std::string& date,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
525 const std::string& patientId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
526 const std::string& studyInstanceUid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
527 const std::string& seriesInstanceUid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
528 const std::string& sopInstanceUid) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
529 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 SetupAnswerType(_OrthancPluginDatabaseAnswerType_ExportedResource);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532 OrthancPluginExportedResource exported;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 exported.seq = seq;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 exported.resourceType = resourceType;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 exported.publicId = StoreString(publicId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 exported.modality = StoreString(modality);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 exported.date = StoreString(date);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
538 exported.patientId = StoreString(patientId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
539 exported.studyInstanceUid = StoreString(studyInstanceUid);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
540 exported.seriesInstanceUid = StoreString(seriesInstanceUid);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
541 exported.sopInstanceUid = StoreString(sopInstanceUid);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
542
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 exported_.push_back(exported);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
544 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
545
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
547 virtual void AnswerMatchingResource(const std::string& resourceId) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
549 SetupAnswerType(_OrthancPluginDatabaseAnswerType_MatchingResource);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
550
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
551 OrthancPluginMatchingResource match;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 match.resourceId = StoreString(resourceId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553 match.someInstanceId = NULL;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
554
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
555 matches_.push_back(match);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
556 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
559 virtual void AnswerMatchingResource(const std::string& resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 const std::string& someInstanceId) ORTHANC_OVERRIDE
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 SetupAnswerType(_OrthancPluginDatabaseAnswerType_MatchingResource);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564 OrthancPluginMatchingResource match;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
565 match.resourceId = StoreString(resourceId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 match.someInstanceId = StoreString(someInstanceId);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 matches_.push_back(match);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570
235
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
571
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 void AnswerIntegers32(const std::list<int32_t>& values)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int32);
235
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
575 CopyListToVector(integers32_, values);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
576 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579 void AnswerIntegers64(const std::list<int64_t>& values)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64);
235
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
582 CopyListToVector(integers64_, values);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
584
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
585
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
586 void AnswerInteger64(int64_t value)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
587 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
588 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
589
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
590 integers64_.resize(1);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
591 integers64_[0] = value;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
592 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
593
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
594
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
595 void AnswerMetadata(int32_t metadata,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 const std::string& value)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Metadata);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
599
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600 Metadata tmp;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
601 tmp.metadata = metadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
602 tmp.value = StoreString(value);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
603
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 metadata_.push_back(tmp);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 void AnswerStrings(const std::list<std::string>& values)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String);
235
f2b32d31fc99 fix lsb build, fix backward compatibility with SDK <= 1.9.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 234
diff changeset
611 CopyListToVector(stringAnswers_, values);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
615 void AnswerString(const std::string& value)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 if (stringAnswers_.empty())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621 stringAnswers_.push_back(value);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
622 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
623 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
624 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
625 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
626 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628 };
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 IDatabaseBackendOutput* DatabaseBackendAdapterV3::Factory::CreateOutput()
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
632 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
633 return new DatabaseBackendAdapterV3::Output;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
634 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
635
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
636
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
637 class DatabaseBackendAdapterV3::Transaction : public boost::noncopyable
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639 private:
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
640 IndexConnectionsPool& pool_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
641 std::unique_ptr<IndexConnectionsPool::Accessor> accessor_;
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
642 std::unique_ptr<Output> output_;
232
4e15eace9b90 reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
643
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
644 public:
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
645 Transaction(IndexConnectionsPool& pool) :
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
646 pool_(pool),
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
647 accessor_(new IndexConnectionsPool::Accessor(pool)),
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648 output_(new Output)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
651
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
652 ~Transaction()
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
653 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656 IndexBackend& GetBackend() const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 {
232
4e15eace9b90 reorganization in DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 226
diff changeset
658 return accessor_->GetBackend();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
659 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
660
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
661 Output& GetOutput() const
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
662 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 return *output_;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
664 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
666 DatabaseManager& GetManager() const
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667 {
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
668 return accessor_->GetManager();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 };
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
671
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
672
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
673 static OrthancPluginErrorCode ReadAnswersCount(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
674 uint32_t* target /* out */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
675 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
676 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
677 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
678 return that.GetOutput().ReadAnswersCount(*target);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
679 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
680
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
681
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
682 static OrthancPluginErrorCode ReadAnswerAttachment(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
683 OrthancPluginAttachment* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
684 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
685 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
686 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
687 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
688 return that.GetOutput().ReadAnswerAttachment(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
689 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
690
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692 static OrthancPluginErrorCode ReadAnswerChange(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693 OrthancPluginChange* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
694 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
695 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
696 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
697 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
698 return that.GetOutput().ReadAnswerChange(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
700
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
701
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
702 static OrthancPluginErrorCode ReadAnswerDicomTag(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
703 uint16_t* group,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
704 uint16_t* element,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
705 const char** value,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
706 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708 assert(group != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709 assert(element != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 assert(value != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
712 return that.GetOutput().ReadAnswerDicomTag(*group, *element, *value, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
713 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
714
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
715
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
716 static OrthancPluginErrorCode ReadAnswerExportedResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717 OrthancPluginExportedResource* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
718 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
719 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
720 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
721 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
722 return that.GetOutput().ReadAnswerExportedResource(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
723 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
724
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726 static OrthancPluginErrorCode ReadAnswerInt32(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727 int32_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 return that.GetOutput().ReadAnswerInt32(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
733 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
734
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
735
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
736 static OrthancPluginErrorCode ReadAnswerInt64(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
737 int64_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
738 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
739 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
740 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
741 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
742 return that.GetOutput().ReadAnswerInt64(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
743 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
744
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
745
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
746 static OrthancPluginErrorCode ReadAnswerMatchingResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
747 OrthancPluginMatchingResource* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
748 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
749 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752 return that.GetOutput().ReadAnswerMatchingResource(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 static OrthancPluginErrorCode ReadAnswerMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
757 int32_t* metadata,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
758 const char** value,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
759 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
760 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
761 assert(metadata != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
762 assert(value != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
763 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
764 return that.GetOutput().ReadAnswerMetadata(*metadata, *value, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
765 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
766
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
767
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
768 static OrthancPluginErrorCode ReadAnswerString(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
769 const char** target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
770 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
771 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
772 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774 return that.GetOutput().ReadAnswerString(*target, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
775 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
776
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
777
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
778 static OrthancPluginErrorCode ReadEventsCount(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
779 uint32_t* target /* out */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
780 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
781 assert(target != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
782 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
783 return that.GetOutput().ReadEventsCount(*target);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
784 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
785
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
786
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
787 static OrthancPluginErrorCode ReadEvent(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
788 OrthancPluginDatabaseEvent* event /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
789 uint32_t index)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
790 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
791 assert(event != NULL);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
792 const DatabaseBackendAdapterV3::Transaction& that = *reinterpret_cast<const DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
793 return that.GetOutput().ReadEvent(*event, index);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
794 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
795
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
796
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
797 static OrthancPluginErrorCode Open(void* database)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
798 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
799 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
801 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802 {
403
91124cc8a8c7 database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
803 std::list<IdentifierTag> identifierTags;
91124cc8a8c7 database plugins are informed about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 401
diff changeset
804 pool->OpenConnections(false, identifierTags);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
806 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
807 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
808 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 static OrthancPluginErrorCode Close(void* database)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
813 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
816 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
817 pool->CloseConnections();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
819 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
820 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
821 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
822
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
823
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 static OrthancPluginErrorCode DestructDatabase(void* database)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
825 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
826 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
827
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
828 if (pool == NULL)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 return OrthancPluginErrorCode_InternalError;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 {
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
834 if (isBackendInUse_)
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
835 {
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
836 isBackendInUse_ = false;
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
837 }
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
838 else
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
839 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
840 OrthancPluginLogError(pool->GetContext(), "More than one index backend was registered, internal error");
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
841 }
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
842
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
843 delete pool;
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
844
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
849
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 static OrthancPluginErrorCode GetDatabaseVersion(void* database,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 uint32_t* version)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
853 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
857 IndexConnectionsPool::Accessor accessor(*pool);
233
7d46c99523a2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 232
diff changeset
858 *version = accessor.GetBackend().GetDatabaseVersion(accessor.GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
861 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
862 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
863
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
864
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 static OrthancPluginErrorCode UpgradeDatabase(void* database,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 OrthancPluginStorageArea* storageArea,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 uint32_t targetVersion)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
868 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
869 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
872 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
873 IndexConnectionsPool::Accessor accessor(*pool);
233
7d46c99523a2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 232
diff changeset
874 accessor.GetBackend().UpgradeDatabase(accessor.GetManager(), targetVersion, storageArea);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
877 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
880
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
881 static OrthancPluginErrorCode HasRevisionsSupport(void* database,
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
882 uint8_t* target)
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
883 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
884 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
885
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
886 try
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
887 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
888 IndexConnectionsPool::Accessor accessor(*pool);
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
889 *target = (accessor.GetBackend().HasRevisionsSupport() ? 1 : 0);
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
890 return OrthancPluginErrorCode_Success;
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
891 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
892 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
893 }
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
894
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
895
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 static OrthancPluginErrorCode StartTransaction(void* database,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 OrthancPluginDatabaseTransaction** target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 OrthancPluginDatabaseTransactionType type)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
899 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
900 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
903 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
904 std::unique_ptr<DatabaseBackendAdapterV3::Transaction> transaction(new DatabaseBackendAdapterV3::Transaction(*pool));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906 switch (type)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
908 case OrthancPluginDatabaseTransactionType_ReadOnly:
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
909 transaction->GetManager().StartTransaction(TransactionType_ReadOnly);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
912 case OrthancPluginDatabaseTransactionType_ReadWrite:
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
913 transaction->GetManager().StartTransaction(TransactionType_ReadWrite);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 default:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920 *target = reinterpret_cast<OrthancPluginDatabaseTransaction*>(transaction.release());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
923 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
924 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
925 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 static OrthancPluginErrorCode DestructTransaction(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 if (transaction == NULL)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
932 return OrthancPluginErrorCode_NullPointer;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 delete reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 static OrthancPluginErrorCode Rollback(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
948 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
949 t->GetManager().RollbackTransaction();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
952 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 static OrthancPluginErrorCode Commit(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957 int64_t fileSizeDelta /* TODO - not used? */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
964 t->GetManager().CommitTransaction();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
966 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
967 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
968 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
969
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
970
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971 static OrthancPluginErrorCode AddAttachment(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
972 int64_t id,
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
973 const OrthancPluginAttachment* attachment,
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
974 int64_t revision)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
978 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
980 t->GetOutput().Clear();
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
981 t->GetBackend().AddAttachment(t->GetManager(), id, *attachment, revision);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
983 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
984 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
985 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988 static OrthancPluginErrorCode ClearChanges(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
990 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
991
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
993 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
994 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
995 t->GetBackend().ClearChanges(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
997 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
998 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
999 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1000
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 static OrthancPluginErrorCode ClearExportedResources(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1005
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1008 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1009 t->GetBackend().ClearExportedResources(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1010 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1011 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1012 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1013 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1014
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1015
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016 static OrthancPluginErrorCode ClearMainDicomTags(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1019 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1023 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1024 t->GetBackend().ClearMainDicomTags(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1027 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1028 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1029
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 static OrthancPluginErrorCode CreateInstance(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 OrthancPluginCreateInstanceResult* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033 const char* hashPatient,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 const char* hashStudy,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 const char* hashSeries,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 const char* hashInstance)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044 if (t->GetBackend().HasCreateInstance())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1045 {
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1046 t->GetBackend().CreateInstance(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1049 {
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1050 t->GetBackend().CreateInstanceGeneric(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1054 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1055 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1056 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1057
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1058
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059 static OrthancPluginErrorCode DeleteAttachment(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 int32_t contentType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1068 t->GetBackend().DeleteAttachment(t->GetOutput(), t->GetManager(), id, contentType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1070 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1071 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1072 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1073
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1074
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1075 static OrthancPluginErrorCode DeleteMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1076 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1077 int32_t metadataType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1078 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1079 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1080
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1082 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1083 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1084 t->GetBackend().DeleteMetadata(t->GetManager(), id, metadataType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1086 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1087 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 static OrthancPluginErrorCode DeleteResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1092 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1097 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1098 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1099 t->GetBackend().DeleteResource(t->GetOutput(), t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1100 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1101 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1102 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1103 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1104
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1105
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1111 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1112 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1114
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1115 std::map<int32_t, std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1116 t->GetBackend().GetAllMetadata(values, t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1118 for (std::map<int32_t, std::string>::const_iterator it = values.begin(); it != values.end(); ++it)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1119 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1120 t->GetOutput().AnswerMetadata(it->first, it->second);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1121 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1122
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1123 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1124 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1125 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1126 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1127
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1128
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1129 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1130 OrthancPluginResourceType resourceType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1131 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1132 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1133
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1134 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1135 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1136 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1137
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1138 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1139 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1140 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1141
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1142 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1143 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1144 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1145 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1146
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1147
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1148 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1149 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1150 uint64_t since,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1151 uint64_t limit)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1152 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1153 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1154
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1155 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1156 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1157 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1158
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1159 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1160 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType, since, limit);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1161 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1162
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1163 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1164 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1165 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1166 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1167
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1168
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 uint8_t* targetDone /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171 int64_t since,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 uint32_t maxResults)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1175
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1176 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1177 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1180 bool done;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1181 t->GetBackend().GetChanges(t->GetOutput(), done, t->GetManager(), since, maxResults);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1182 *targetDone = (done ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1183
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1184 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1185 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1186 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1187 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1188
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1189
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1190 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1191 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1192 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1194
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1195 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1196 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1197 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1198
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1199 std::list<int64_t> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1200 t->GetBackend().GetChildrenInternalId(values, t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1201 t->GetOutput().AnswerIntegers64(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1202
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1203 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1204 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1205 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1206 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1207
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1208
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 static OrthancPluginErrorCode GetChildrenMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210 int64_t resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 int32_t metadata)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1213 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1214
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1215 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1216 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1218
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1219 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1220 t->GetBackend().GetChildrenMetadata(values, t->GetManager(), resourceId, metadata);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1221 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1222
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1223 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1224 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1225 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1226 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1227
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1228
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1229 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1230 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1231 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1232 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1233
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1234 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1235 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1236 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1237
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1238 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1239 t->GetBackend().GetChildrenPublicId(values, t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1240 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1241
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1242 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1243 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1244 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1245 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1246
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1247
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1248 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1249 uint8_t* targetDone /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1250 int64_t since,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1251 uint32_t maxResults)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1252 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1253 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1254
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1255 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1256 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1257 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1258
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1259 bool done;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1260 t->GetBackend().GetExportedResources(t->GetOutput(), done, t->GetManager(), since, maxResults);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1261 *targetDone = (done ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1262
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1263 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1264 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1265 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1266 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1267
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1268
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1269 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1270 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1271 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1272
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1273 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1274 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1275 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1276 t->GetBackend().GetLastChange(t->GetOutput(), t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1277 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1278 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1279 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1280 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1281
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1282
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1283 static OrthancPluginErrorCode GetLastChangeIndex(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1284 int64_t* target)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1285 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1286 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1287
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1288 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1289 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1290 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1291 *target = t->GetBackend().GetLastChangeIndex(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1292 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1293 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1294 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1295 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1296
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1297
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1298 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1299 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1300 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1301
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1302 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1303 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1304 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1305 t->GetBackend().GetLastExportedResource(t->GetOutput(), t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1306 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1307 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1308 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1309 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1310
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1311
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1312 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1313 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1314 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1315 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1316
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1317 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1318 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1319 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1320 t->GetBackend().GetMainDicomTags(t->GetOutput(), t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1321 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1322 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1323 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1324 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1325
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1326
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1327 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1328 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1329 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1330 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1331
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1332 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1333 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1334 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1335 t->GetOutput().AnswerString(t->GetBackend().GetPublicId(t->GetManager(), id));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1336 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1337 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1338 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1339 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1340
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1341
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1342 static OrthancPluginErrorCode GetResourcesCount(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343 uint64_t* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344 OrthancPluginResourceType resourceType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1347
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1348 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1349 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1350 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1351 *target = t->GetBackend().GetResourcesCount(t->GetManager(), resourceType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1352 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1353 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1354 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1355 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1356
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1357
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1358 static OrthancPluginErrorCode GetResourceType(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1359 OrthancPluginResourceType* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1360 uint64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1361 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1362 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1363
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1364 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1365 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1366 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1367 *target = t->GetBackend().GetResourceType(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1368 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1369 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1370 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1371 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1372
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1373
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1374 static OrthancPluginErrorCode GetTotalCompressedSize(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1375 uint64_t* target /* out */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1376 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1377 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1378
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1379 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1380 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1381 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1382 *target = t->GetBackend().GetTotalCompressedSize(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1383 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1384 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1385 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1386 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1387
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1388
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1389 static OrthancPluginErrorCode GetTotalUncompressedSize(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1390 uint64_t* target /* out */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1392 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1393
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1394 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1395 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1396 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1397 *target = t->GetBackend().GetTotalUncompressedSize(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1398 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1399 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1400 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1401 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1402
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1403
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1404 static OrthancPluginErrorCode IsDiskSizeAbove(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1405 uint8_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1406 uint64_t threshold)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1407 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1408 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1409
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1410 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1411 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1412 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1413 bool above = (t->GetBackend().GetTotalCompressedSize(t->GetManager()) >= threshold);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1414 *target = (above ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1415 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1416 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1417 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1418 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1419
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1420
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1421 static OrthancPluginErrorCode IsExistingResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1422 uint8_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1423 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1424 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1425 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1426
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1427 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1428 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1429 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1430 bool exists = t->GetBackend().IsExistingResource(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1431 *target = (exists ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1432 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1433 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1434 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1435 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1436
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1437
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1438 static OrthancPluginErrorCode IsProtectedPatient(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1439 uint8_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1440 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1441 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1442 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1443
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1444 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1445 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1446 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1447 bool isProtected = t->GetBackend().IsProtectedPatient(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1448 *target = (isProtected ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1449 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1450 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1451 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1452 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1453
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1454
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1455 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1456 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1457 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1458 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1459
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1460 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1461 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1462 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1463
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1464 std::list<int32_t> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1465 t->GetBackend().ListAvailableAttachments(values, t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1466 t->GetOutput().AnswerIntegers32(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1467 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1468 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1469 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1470 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1471
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1472
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1473 static OrthancPluginErrorCode LogChange(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1474 int32_t changeType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1475 int64_t resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1476 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1477 const char* date)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1478 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1479 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1480
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1481 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1482 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1483 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1484 t->GetBackend().LogChange(t->GetManager(), changeType, resourceId, resourceType, date);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1485 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1486 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1487 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1488 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1489
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1490
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1491 static OrthancPluginErrorCode LogExportedResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1492 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1493 const char* publicId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1494 const char* modality,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1495 const char* date,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1496 const char* patientId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1497 const char* studyInstanceUid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1498 const char* seriesInstanceUid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1499 const char* sopInstanceUid)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1500 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1501 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1502
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1503 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1504 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1505 t->GetOutput().Clear();
378
9db9e0275ec0 refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 374
diff changeset
1506 t->GetBackend().LogExportedResource(t->GetManager(), resourceType, publicId, modality, date,
9db9e0275ec0 refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 374
diff changeset
1507 patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1508 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1509 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1510 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1511 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1512
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1513
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1514 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseTransaction* transaction,
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1515 int64_t* revision /* out */,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1516 int64_t resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1517 int32_t contentType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1518 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1519 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1520
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1521 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1522 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1523 t->GetOutput().Clear();
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1524 t->GetBackend().LookupAttachment(t->GetOutput(), *revision, t->GetManager(), resourceId, contentType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1525 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1526 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1527 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1528 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1529
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1530
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1531 static OrthancPluginErrorCode LookupGlobalProperty(OrthancPluginDatabaseTransaction* transaction,
221
73cc85f3d9c1 implementation of the "serverIdentifier" information for global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
1532 const char* serverIdentifier,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1533 int32_t property)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1534 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1535 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1536
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1537 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1538 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1539 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1540
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1541 std::string s;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1542 if (t->GetBackend().LookupGlobalProperty(s, t->GetManager(), serverIdentifier, property))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1543 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1544 t->GetOutput().AnswerString(s);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1545 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1546
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1547 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1548 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1549 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1550 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1551
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1552
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1553 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseTransaction* transaction,
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1554 int64_t* revision /* out */,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1555 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1556 int32_t metadata)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1557 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1558 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1559
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1560 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1561 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1562 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1563
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1564 std::string s;
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1565 if (t->GetBackend().LookupMetadata(s, *revision, t->GetManager(), id, metadata))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1566 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1567 t->GetOutput().AnswerString(s);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1568 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1569
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1570 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1571 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1572 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1573 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1574
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1575
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1576 static OrthancPluginErrorCode LookupParent(OrthancPluginDatabaseTransaction* transaction,
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1577 uint8_t* existing /* out */,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1578 int64_t* parentId /* out */,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1579 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1580 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1581 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1582
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1583 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1584 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1585 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1586
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1587 if (t->GetBackend().LookupParent(*parentId, t->GetManager(), id))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1588 {
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1589 *existing = 1;
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1590 }
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1591 else
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1592 {
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1593 *existing = 0;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1594 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1595
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1596 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1597 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1598 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1599 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1600
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1601
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1602 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1603 uint8_t* isExisting /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1604 int64_t* id /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1605 OrthancPluginResourceType* type /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1606 const char* publicId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1607 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1608 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1609
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1610 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1611 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1612 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1613
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1614 if (t->GetBackend().LookupResource(*id, *type, t->GetManager(), publicId))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1615 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1616 *isExisting = 1;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1617 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1618 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1619 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1620 *isExisting = 0;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1621 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1622
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1623 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1624 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1625 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1626 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1627
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1628
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1629 static OrthancPluginErrorCode LookupResources(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1630 uint32_t constraintsCount,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1631 const OrthancPluginDatabaseConstraint* constraints,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1632 OrthancPluginResourceType queryLevel,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1633 uint32_t limit,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1634 uint8_t requestSomeInstanceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1635 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1636 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1637
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1638 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1639 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1640 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1641
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1642 std::vector<Orthanc::DatabaseConstraint> lookup;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1643 lookup.reserve(constraintsCount);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1644
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1645 for (uint32_t i = 0; i < constraintsCount; i++)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1646 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1647 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i]));
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1648 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1649
401
a8774581adfc replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 391
diff changeset
1650 std::set<std::string> noLabel;
a8774581adfc replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 391
diff changeset
1651 t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel, noLabel,
a8774581adfc replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 391
diff changeset
1652 Orthanc::LabelsConstraint_All, limit, (requestSomeInstanceId != 0));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1653 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1654 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1655 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1656 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1657
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1658
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1659 static OrthancPluginErrorCode LookupResourceAndParent(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1660 uint8_t* isExisting /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1661 int64_t* id /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1662 OrthancPluginResourceType* type /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1663 const char* publicId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1664 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1665 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1666
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1667 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1668 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1669 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1670
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1671 std::string parent;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1672 if (t->GetBackend().LookupResourceAndParent(*id, *type, parent, t->GetManager(), publicId))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1673 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1674 *isExisting = 1;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1675
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1676 if (!parent.empty())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1677 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1678 t->GetOutput().AnswerString(parent);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1679 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1680 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1681 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1682 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1683 *isExisting = 0;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1684 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1685
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1686 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1687 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1688 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1689 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1690
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1691
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1692 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseTransaction* transaction,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1693 uint8_t* patientAvailable,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1694 int64_t* patientId)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1695 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1696 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1697
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1698 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1699 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1700 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1701
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1702 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager()))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1703 {
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1704 *patientAvailable = 1;
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1705 }
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1706 else
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1707 {
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1708 *patientAvailable = 0;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1709 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1710
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1711 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1712 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1713 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1714 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1715
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1716
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1717 static OrthancPluginErrorCode SelectPatientToRecycle2(OrthancPluginDatabaseTransaction* transaction,
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1718 uint8_t* patientAvailable,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1719 int64_t* patientId,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1720 int64_t patientIdToAvoid)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1721 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1722 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1723
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1724 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1725 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1726 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1727
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1728 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager(), patientIdToAvoid))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1729 {
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1730 *patientAvailable = 1;
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1731 }
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1732 else
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1733 {
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1734 *patientAvailable = 0;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1735 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1736
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1737 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1738 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1739 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1740 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1741
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1742
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1743 static OrthancPluginErrorCode SetGlobalProperty(OrthancPluginDatabaseTransaction* transaction,
221
73cc85f3d9c1 implementation of the "serverIdentifier" information for global properties
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 212
diff changeset
1744 const char* serverIdentifier,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1745 int32_t property,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1746 const char* value)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1747 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1748 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1749
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1750 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1751 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1752 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1753 t->GetBackend().SetGlobalProperty(t->GetManager(), serverIdentifier, property, value);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1754 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1755 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1756 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1757 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1758
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1759
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1760 static OrthancPluginErrorCode SetMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1761 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1762 int32_t metadata,
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1763 const char* value,
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1764 int64_t revision)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1765 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1766 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1767
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1768 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1769 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1770 t->GetOutput().Clear();
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1771 t->GetBackend().SetMetadata(t->GetManager(), id, metadata, value, revision);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1772 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1773 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1774 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1775 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1776
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1777
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1778 static OrthancPluginErrorCode SetProtectedPatient(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1779 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1780 uint8_t isProtected)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1781 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1782 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1783
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1784 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1785 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1786 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1787 t->GetBackend().SetProtectedPatient(t->GetManager(), id, (isProtected != 0));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1788 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1789 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1790 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1791 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1792
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1793
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1794 static OrthancPluginErrorCode SetResourcesContent(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1795 uint32_t countIdentifierTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1796 const OrthancPluginResourcesContentTags* identifierTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1797 uint32_t countMainDicomTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1798 const OrthancPluginResourcesContentTags* mainDicomTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1799 uint32_t countMetadata,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1800 const OrthancPluginResourcesContentMetadata* metadata)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1801 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1802 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1803
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1804 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1805 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1806 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1807 t->GetBackend().SetResourcesContent(t->GetManager(), countIdentifierTags, identifierTags,
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1808 countMainDicomTags, mainDicomTags, countMetadata, metadata);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1809 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1810 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1811 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1812 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1813
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1814
234
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1815 void DatabaseBackendAdapterV3::Register(IndexBackend* backend,
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1816 size_t countConnections,
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1817 unsigned int maxDatabaseRetries)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1818 {
373
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1819 std::unique_ptr<IndexBackend> protection(backend);
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1820
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1821 if (isBackendInUse_)
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1822 {
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1823 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1824 }
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1825
222
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1826 if (backend == NULL)
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1827 {
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1828 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1829 }
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1830
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1831 OrthancPluginDatabaseBackendV3 params;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1832 memset(&params, 0, sizeof(params));
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1833
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1834 params.readAnswersCount = ReadAnswersCount;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1835 params.readAnswerAttachment = ReadAnswerAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1836 params.readAnswerChange = ReadAnswerChange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1837 params.readAnswerDicomTag = ReadAnswerDicomTag;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1838 params.readAnswerExportedResource = ReadAnswerExportedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1839 params.readAnswerInt32 = ReadAnswerInt32;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1840 params.readAnswerInt64 = ReadAnswerInt64;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1841 params.readAnswerMatchingResource = ReadAnswerMatchingResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1842 params.readAnswerMetadata = ReadAnswerMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1843 params.readAnswerString = ReadAnswerString;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1844
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1845 params.readEventsCount = ReadEventsCount;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1846 params.readEvent = ReadEvent;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1847
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1848 params.open = Open;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1849 params.close = Close;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1850 params.destructDatabase = DestructDatabase;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1851 params.getDatabaseVersion = GetDatabaseVersion;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1852 params.upgradeDatabase = UpgradeDatabase;
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
1853 params.hasRevisionsSupport = HasRevisionsSupport;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1854 params.startTransaction = StartTransaction;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1855 params.destructTransaction = DestructTransaction;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1856 params.rollback = Rollback;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1857 params.commit = Commit;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1858
262
b0c65094b299 adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1859 params.addAttachment = AddAttachment;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1860 params.clearChanges = ClearChanges;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1861 params.clearExportedResources = ClearExportedResources;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1862 params.clearMainDicomTags = ClearMainDicomTags;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1863 params.createInstance = CreateInstance;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1864 params.deleteAttachment = DeleteAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1865 params.deleteMetadata = DeleteMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1866 params.deleteResource = DeleteResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1867 params.getAllMetadata = GetAllMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1868 params.getAllPublicIds = GetAllPublicIds;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1869 params.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1870 params.getChanges = GetChanges;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1871 params.getChildrenInternalId = GetChildrenInternalId;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1872 params.getChildrenMetadata = GetChildrenMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1873 params.getChildrenPublicId = GetChildrenPublicId;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1874 params.getExportedResources = GetExportedResources;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1875 params.getLastChange = GetLastChange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1876 params.getLastChangeIndex = GetLastChangeIndex;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1877 params.getLastExportedResource = GetLastExportedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1878 params.getMainDicomTags = GetMainDicomTags;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1879 params.getPublicId = GetPublicId;
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1880 params.getResourceType = GetResourceType;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1881 params.getResourcesCount = GetResourcesCount;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1882 params.getTotalCompressedSize = GetTotalCompressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1883 params.getTotalUncompressedSize = GetTotalUncompressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1884 params.isDiskSizeAbove = IsDiskSizeAbove;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1885 params.isExistingResource = IsExistingResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1886 params.isProtectedPatient = IsProtectedPatient;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1887 params.listAvailableAttachments = ListAvailableAttachments;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1888 params.logChange = LogChange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1889 params.logExportedResource = LogExportedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1890 params.lookupAttachment = LookupAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1891 params.lookupGlobalProperty = LookupGlobalProperty;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1892 params.lookupMetadata = LookupMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1893 params.lookupParent = LookupParent;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1894 params.lookupResource = LookupResource;
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1895 params.lookupResourceAndParent = LookupResourceAndParent;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1896 params.lookupResources = LookupResources;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1897 params.selectPatientToRecycle = SelectPatientToRecycle;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1898 params.selectPatientToRecycle2 = SelectPatientToRecycle2;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1899 params.setGlobalProperty = SetGlobalProperty;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1900 params.setMetadata = SetMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1901 params.setProtectedPatient = SetProtectedPatient;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1902 params.setResourcesContent = SetResourcesContent;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1903
373
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1904 OrthancPluginContext* context = protection->GetContext();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1905
234
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1906 if (OrthancPluginRegisterDatabaseBackendV3(
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1907 context, &params, sizeof(params), maxDatabaseRetries,
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
1908 new IndexConnectionsPool(protection.release(), countConnections)) != OrthancPluginErrorCode_Success)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1909 {
373
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1910 delete backend;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1911 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend");
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1912 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1913
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1914 backend->SetOutputFactory(new Factory);
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1915
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1916 isBackendInUse_ = true;
222
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1917 }
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1918
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1919
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1920 void DatabaseBackendAdapterV3::Finalize()
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1921 {
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1922 if (isBackendInUse_)
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1923 {
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1924 fprintf(stderr, "The Orthanc core has not destructed the index backend, internal error\n");
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1925 }
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1926 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1927 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1928
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1929 # endif
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1930 #endif