annotate Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 395:a7a029043670 db-protobuf

integration mainline->db-protobuf
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 05 Apr 2023 14:53:57 +0200
parents d14e6ff04a5c
children a8774581adfc
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 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
803 pool->OpenConnections();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
804 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
805 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
806 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
807 }
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 static OrthancPluginErrorCode Close(void* database)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
812 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
814 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
815 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
816 pool->CloseConnections();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
817 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
818 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
819 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
820 }
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 static OrthancPluginErrorCode DestructDatabase(void* database)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
824 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
825 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
826
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
827 if (pool == NULL)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
828 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
829 return OrthancPluginErrorCode_InternalError;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
830 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832 {
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
833 if (isBackendInUse_)
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
834 {
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
835 isBackendInUse_ = false;
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
836 }
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
837 else
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
838 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
839 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
840 }
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
841
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
842 delete pool;
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
843
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 }
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 static OrthancPluginErrorCode GetDatabaseVersion(void* database,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850 uint32_t* version)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
851 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
852 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
856 IndexConnectionsPool::Accessor accessor(*pool);
233
7d46c99523a2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 232
diff changeset
857 *version = accessor.GetBackend().GetDatabaseVersion(accessor.GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
860 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
861 }
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 static OrthancPluginErrorCode UpgradeDatabase(void* database,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
865 OrthancPluginStorageArea* storageArea,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
866 uint32_t targetVersion)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
867 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
868 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
869
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
870 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
871 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
872 IndexConnectionsPool::Accessor accessor(*pool);
233
7d46c99523a2 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 232
diff changeset
873 accessor.GetBackend().UpgradeDatabase(accessor.GetManager(), targetVersion, storageArea);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
874 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
876 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
880 static OrthancPluginErrorCode HasRevisionsSupport(void* database,
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
881 uint8_t* target)
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
882 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
883 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
884
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
885 try
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
886 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
887 IndexConnectionsPool::Accessor accessor(*pool);
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
888 *target = (accessor.GetBackend().HasRevisionsSupport() ? 1 : 0);
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
889 return OrthancPluginErrorCode_Success;
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
890 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
891 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
892 }
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
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 static OrthancPluginErrorCode StartTransaction(void* database,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 OrthancPluginDatabaseTransaction** target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 OrthancPluginDatabaseTransactionType type)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
898 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
899 IndexConnectionsPool* pool = reinterpret_cast<IndexConnectionsPool*>(database);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
900
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
901 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
902 {
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
903 std::unique_ptr<DatabaseBackendAdapterV3::Transaction> transaction(new DatabaseBackendAdapterV3::Transaction(*pool));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
904
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905 switch (type)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
906 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
907 case OrthancPluginDatabaseTransactionType_ReadOnly:
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
908 transaction->GetManager().StartTransaction(TransactionType_ReadOnly);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
909 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
910
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
911 case OrthancPluginDatabaseTransactionType_ReadWrite:
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
912 transaction->GetManager().StartTransaction(TransactionType_ReadWrite);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 break;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915 default:
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 *target = reinterpret_cast<OrthancPluginDatabaseTransaction*>(transaction.release());
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
920
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
921 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
922 }
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
923 ORTHANC_PLUGINS_DATABASE_CATCH(pool->GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
924 }
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 static OrthancPluginErrorCode DestructTransaction(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929 if (transaction == NULL)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 return OrthancPluginErrorCode_NullPointer;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
932 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
933 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 delete reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937 }
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 static OrthancPluginErrorCode Rollback(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
943 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
944
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
945 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
946 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
947 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
948 t->GetManager().RollbackTransaction();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
949 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
951 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952 }
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 static OrthancPluginErrorCode Commit(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
956 int64_t fileSizeDelta /* TODO - not used? */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
957 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
958 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
959
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
960 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
963 t->GetManager().CommitTransaction();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
966 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
967 }
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 static OrthancPluginErrorCode AddAttachment(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
971 int64_t id,
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
972 const OrthancPluginAttachment* attachment,
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
973 int64_t revision)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
978 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979 t->GetOutput().Clear();
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
980 t->GetBackend().AddAttachment(t->GetManager(), id, *attachment, revision);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
981 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
982 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
983 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
984 }
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 static OrthancPluginErrorCode ClearChanges(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
988 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
990
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
991 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
992 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
993 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
994 t->GetBackend().ClearChanges(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
995 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
996 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
997 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
998 }
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 static OrthancPluginErrorCode ClearExportedResources(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1005 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1008 t->GetBackend().ClearExportedResources(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1009 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1010 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1011 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1012 }
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 static OrthancPluginErrorCode ClearMainDicomTags(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1016 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1018 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1019
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1020 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1021 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1022 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1023 t->GetBackend().ClearMainDicomTags(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1024 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1025 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1026 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027 }
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 static OrthancPluginErrorCode CreateInstance(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1031 OrthancPluginCreateInstanceResult* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1032 const char* hashPatient,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1033 const char* hashStudy,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1034 const char* hashSeries,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1035 const char* hashInstance)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1036 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1037 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1038
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1041 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1042
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043 if (t->GetBackend().HasCreateInstance())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1044 {
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1045 t->GetBackend().CreateInstance(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1046 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1047 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1048 {
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1049 t->GetBackend().CreateInstanceGeneric(*target, t->GetManager(), hashPatient, hashStudy, hashSeries, hashInstance);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1050 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1051
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1052 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1053 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1054 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1055 }
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 static OrthancPluginErrorCode DeleteAttachment(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1059 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1060 int32_t contentType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1061 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1062 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1063
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1064 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1065 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1066 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1067 t->GetBackend().DeleteAttachment(t->GetOutput(), t->GetManager(), id, contentType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1068 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1069 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1070 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1071 }
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 static OrthancPluginErrorCode DeleteMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1075 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1076 int32_t metadataType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1077 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1078 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1079
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1080 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1081 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1082 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1083 t->GetBackend().DeleteMetadata(t->GetManager(), id, metadataType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1084 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1086 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 }
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 static OrthancPluginErrorCode DeleteResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1092 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1097 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1098 t->GetBackend().DeleteResource(t->GetOutput(), t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1099 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1100 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1101 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1102 }
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 static OrthancPluginErrorCode GetAllMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1106 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1107 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1108 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1109
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1110 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1111 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1112 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1113
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1114 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
1115 t->GetBackend().GetAllMetadata(values, t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1116
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1117 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
1118 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1119 t->GetOutput().AnswerMetadata(it->first, it->second);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1120 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1121
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1122 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1123 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1124 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1125 }
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 static OrthancPluginErrorCode GetAllPublicIds(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1129 OrthancPluginResourceType resourceType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1130 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1131 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1132
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1133 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1134 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1135 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1136
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1137 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1138 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1139 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1140
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1141 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1142 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1143 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1144 }
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 static OrthancPluginErrorCode GetAllPublicIdsWithLimit(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1148 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1149 uint64_t since,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1150 uint64_t limit)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1151 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1152 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1153
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1154 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1155 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1156 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1157
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1158 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1159 t->GetBackend().GetAllPublicIds(values, t->GetManager(), resourceType, since, limit);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1160 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1161
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1162 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1163 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1164 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1165 }
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 static OrthancPluginErrorCode GetChanges(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1169 uint8_t* targetDone /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 int64_t since,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171 uint32_t maxResults)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1175 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1176 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1177 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179 bool done;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1180 t->GetBackend().GetChanges(t->GetOutput(), done, t->GetManager(), since, maxResults);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1181 *targetDone = (done ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1182
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1183 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1184 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1185 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1186 }
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 static OrthancPluginErrorCode GetChildrenInternalId(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1190 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1191 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1192 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1193
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1194 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1195 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1196 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1197
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1198 std::list<int64_t> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1199 t->GetBackend().GetChildrenInternalId(values, t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1200 t->GetOutput().AnswerIntegers64(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1201
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1202 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1203 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1204 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1205 }
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 static OrthancPluginErrorCode GetChildrenMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1209 int64_t resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1210 int32_t metadata)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1211 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1212 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1213
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1214 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1215 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1216 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1217
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1218 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1219 t->GetBackend().GetChildrenMetadata(values, t->GetManager(), resourceId, metadata);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1220 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1221
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1222 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1223 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1224 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1225 }
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 static OrthancPluginErrorCode GetChildrenPublicId(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1229 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1230 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1231 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1232
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1233 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1234 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1235 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1236
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1237 std::list<std::string> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1238 t->GetBackend().GetChildrenPublicId(values, t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1239 t->GetOutput().AnswerStrings(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1240
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1241 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1242 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1243 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1244 }
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 static OrthancPluginErrorCode GetExportedResources(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1248 uint8_t* targetDone /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1249 int64_t since,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1250 uint32_t maxResults)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1251 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1252 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1253
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1254 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1255 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1256 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1257
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1258 bool done;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1259 t->GetBackend().GetExportedResources(t->GetOutput(), done, t->GetManager(), since, maxResults);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1260 *targetDone = (done ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1261
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1262 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1263 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1264 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1265 }
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 static OrthancPluginErrorCode GetLastChange(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1269 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1270 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1271
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1272 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1273 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1274 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1275 t->GetBackend().GetLastChange(t->GetOutput(), t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1276 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1277 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1278 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1279 }
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 static OrthancPluginErrorCode GetLastChangeIndex(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1283 int64_t* target)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1284 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1285 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1286
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1287 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1288 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1289 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1290 *target = t->GetBackend().GetLastChangeIndex(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1291 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1292 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1293 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1294 }
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 static OrthancPluginErrorCode GetLastExportedResource(OrthancPluginDatabaseTransaction* transaction)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1298 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1299 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1300
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1301 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1302 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1303 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1304 t->GetBackend().GetLastExportedResource(t->GetOutput(), t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1305 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1306 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1307 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1308 }
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 static OrthancPluginErrorCode GetMainDicomTags(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1312 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1313 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1314 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1315
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1316 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1317 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1318 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1319 t->GetBackend().GetMainDicomTags(t->GetOutput(), t->GetManager(), id);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1320 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1321 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1322 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1323 }
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 static OrthancPluginErrorCode GetPublicId(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1327 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1328 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1329 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1330
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1331 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1332 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1333 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1334 t->GetOutput().AnswerString(t->GetBackend().GetPublicId(t->GetManager(), id));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1335 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1336 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1337 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1338 }
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 static OrthancPluginErrorCode GetResourcesCount(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1342 uint64_t* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343 OrthancPluginResourceType resourceType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1347 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1348 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1349 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1350 *target = t->GetBackend().GetResourcesCount(t->GetManager(), resourceType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1351 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1352 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1353 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1354 }
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 static OrthancPluginErrorCode GetResourceType(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1358 OrthancPluginResourceType* target /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1359 uint64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1360 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1361 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1362
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1363 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1364 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1365 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1366 *target = t->GetBackend().GetResourceType(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1367 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1368 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1369 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1370 }
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 static OrthancPluginErrorCode GetTotalCompressedSize(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1374 uint64_t* target /* out */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1375 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1376 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1377
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1378 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1379 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1380 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1381 *target = t->GetBackend().GetTotalCompressedSize(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1382 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1383 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1384 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1385 }
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 static OrthancPluginErrorCode GetTotalUncompressedSize(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1389 uint64_t* target /* out */)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1390 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1392
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1393 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1394 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1395 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1396 *target = t->GetBackend().GetTotalUncompressedSize(t->GetManager());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1397 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1398 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1399 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1400 }
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 static OrthancPluginErrorCode IsDiskSizeAbove(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1404 uint8_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1405 uint64_t threshold)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1406 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1407 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1408
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1409 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1410 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1411 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1412 bool above = (t->GetBackend().GetTotalCompressedSize(t->GetManager()) >= threshold);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1413 *target = (above ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1414 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1415 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1416 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1417 }
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 static OrthancPluginErrorCode IsExistingResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1421 uint8_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1422 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1423 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1424 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1425
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1426 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1427 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1428 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1429 bool exists = t->GetBackend().IsExistingResource(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1430 *target = (exists ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1431 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1432 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1433 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1434 }
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 static OrthancPluginErrorCode IsProtectedPatient(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1438 uint8_t* target,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1439 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1440 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1441 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1442
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1443 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1444 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1445 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1446 bool isProtected = t->GetBackend().IsProtectedPatient(t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1447 *target = (isProtected ? 1 : 0);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1448 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1449 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1450 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1451 }
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 static OrthancPluginErrorCode ListAvailableAttachments(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1455 int64_t resourceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1456 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1457 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1458
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1459 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1460 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1461 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1462
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1463 std::list<int32_t> values;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1464 t->GetBackend().ListAvailableAttachments(values, t->GetManager(), resourceId);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1465 t->GetOutput().AnswerIntegers32(values);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1466 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1467 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1468 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1469 }
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 static OrthancPluginErrorCode LogChange(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1473 int32_t changeType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1474 int64_t resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1475 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1476 const char* date)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1477 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1478 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1479
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1480 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1481 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1482 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1483 t->GetBackend().LogChange(t->GetManager(), changeType, resourceId, resourceType, date);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1484 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1485 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1486 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1487 }
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 static OrthancPluginErrorCode LogExportedResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1491 OrthancPluginResourceType resourceType,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1492 const char* publicId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1493 const char* modality,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1494 const char* date,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1495 const char* patientId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1496 const char* studyInstanceUid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1497 const char* seriesInstanceUid,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1498 const char* sopInstanceUid)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1499 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1500 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1501
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1502 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1503 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1504 t->GetOutput().Clear();
378
9db9e0275ec0 refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 374
diff changeset
1505 t->GetBackend().LogExportedResource(t->GetManager(), resourceType, publicId, modality, date,
9db9e0275ec0 refactoring IndexBackend::LogExportedResource()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 374
diff changeset
1506 patientId, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1507 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1508 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1509 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1510 }
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 static OrthancPluginErrorCode LookupAttachment(OrthancPluginDatabaseTransaction* transaction,
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1514 int64_t* revision /* out */,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1515 int64_t resourceId,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1516 int32_t contentType)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1517 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1518 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1519
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1520 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1521 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1522 t->GetOutput().Clear();
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1523 t->GetBackend().LookupAttachment(t->GetOutput(), *revision, t->GetManager(), resourceId, contentType);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1524 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1525 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1526 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1527 }
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 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
1531 const char* serverIdentifier,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1532 int32_t property)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1533 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1534 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1535
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1536 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1537 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1538 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1539
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1540 std::string s;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1541 if (t->GetBackend().LookupGlobalProperty(s, t->GetManager(), serverIdentifier, property))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1542 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1543 t->GetOutput().AnswerString(s);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1544 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1545
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1546 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1547 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1548 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1549 }
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 static OrthancPluginErrorCode LookupMetadata(OrthancPluginDatabaseTransaction* transaction,
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1553 int64_t* revision /* out */,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1554 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1555 int32_t metadata)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1556 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1557 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1558
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1559 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1560 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1561 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1562
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1563 std::string s;
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1564 if (t->GetBackend().LookupMetadata(s, *revision, t->GetManager(), id, metadata))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1565 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1566 t->GetOutput().AnswerString(s);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1567 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1568
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1569 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1570 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1571 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1572 }
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 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
1576 uint8_t* existing /* out */,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1577 int64_t* parentId /* out */,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1578 int64_t id)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1579 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1580 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1581
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1582 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1583 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1584 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1585
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1586 if (t->GetBackend().LookupParent(*parentId, t->GetManager(), id))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1587 {
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1588 *existing = 1;
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1589 }
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1590 else
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1591 {
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1592 *existing = 0;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1593 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1594
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1595 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1596 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1597 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1598 }
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 static OrthancPluginErrorCode LookupResource(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1602 uint8_t* isExisting /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1603 int64_t* id /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1604 OrthancPluginResourceType* type /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1605 const char* publicId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1606 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1607 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1608
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1609 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1610 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1611 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1612
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1613 if (t->GetBackend().LookupResource(*id, *type, t->GetManager(), publicId))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1614 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1615 *isExisting = 1;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1616 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1617 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1618 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1619 *isExisting = 0;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1620 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1621
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1622 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1623 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1624 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1625 }
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 static OrthancPluginErrorCode LookupResources(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1629 uint32_t constraintsCount,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1630 const OrthancPluginDatabaseConstraint* constraints,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1631 OrthancPluginResourceType queryLevel,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1632 uint32_t limit,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1633 uint8_t requestSomeInstanceId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1634 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1635 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1636
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1637 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1638 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1639 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1640
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1641 std::vector<Orthanc::DatabaseConstraint> lookup;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1642 lookup.reserve(constraintsCount);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1643
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1644 for (uint32_t i = 0; i < constraintsCount; i++)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1645 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1646 lookup.push_back(Orthanc::DatabaseConstraint(constraints[i]));
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1647 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1648
391
d14e6ff04a5c added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 389
diff changeset
1649 std::set<std::string> noLabels;
d14e6ff04a5c added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 389
diff changeset
1650 t->GetBackend().LookupResources(t->GetOutput(), t->GetManager(), lookup, queryLevel,
d14e6ff04a5c added primitives to handle labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 389
diff changeset
1651 noLabels, noLabels, limit, (requestSomeInstanceId != 0));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1652 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1653 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1654 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1655 }
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 static OrthancPluginErrorCode LookupResourceAndParent(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1659 uint8_t* isExisting /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1660 int64_t* id /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1661 OrthancPluginResourceType* type /* out */,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1662 const char* publicId)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1663 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1664 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1665
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1666 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1667 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1668 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1669
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1670 std::string parent;
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1671 if (t->GetBackend().LookupResourceAndParent(*id, *type, parent, t->GetManager(), publicId))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1672 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1673 *isExisting = 1;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1674
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1675 if (!parent.empty())
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1676 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1677 t->GetOutput().AnswerString(parent);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1678 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1679 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1680 else
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1681 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1682 *isExisting = 0;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1683 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1684
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1685 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1686 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1687 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1688 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1689
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1690
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1691 static OrthancPluginErrorCode SelectPatientToRecycle(OrthancPluginDatabaseTransaction* transaction,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1692 uint8_t* patientAvailable,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1693 int64_t* patientId)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1694 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1695 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1696
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1697 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1698 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1699 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1700
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1701 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager()))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1702 {
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1703 *patientAvailable = 1;
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1704 }
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1705 else
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1706 {
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1707 *patientAvailable = 0;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1708 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1709
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1710 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1711 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1712 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1713 }
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 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
1717 uint8_t* patientAvailable,
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1718 int64_t* patientId,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1719 int64_t patientIdToAvoid)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1720 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1721 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1722
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1723 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1724 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1725 t->GetOutput().Clear();
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1726
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1727 if (t->GetBackend().SelectPatientToRecycle(*patientId, t->GetManager(), patientIdToAvoid))
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1728 {
251
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1729 *patientAvailable = 1;
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1730 }
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1731 else
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1732 {
ed12248ad791 implementation of minor api improvements in OrthancCDatabasePlugin.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 237
diff changeset
1733 *patientAvailable = 0;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1734 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1735
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1736 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1737 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1738 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1739 }
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 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
1743 const char* serverIdentifier,
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1744 int32_t property,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1745 const char* value)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1746 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1747 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1748
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1749 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1750 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1751 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1752 t->GetBackend().SetGlobalProperty(t->GetManager(), serverIdentifier, property, value);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1753 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1754 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1755 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1756 }
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 static OrthancPluginErrorCode SetMetadata(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1760 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1761 int32_t metadata,
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1762 const char* value,
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1763 int64_t revision)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1764 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1765 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1766
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1767 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1768 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1769 t->GetOutput().Clear();
256
e184dcadf163 handling of revisions in metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 255
diff changeset
1770 t->GetBackend().SetMetadata(t->GetManager(), id, metadata, value, revision);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1771 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1772 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1773 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1774 }
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 static OrthancPluginErrorCode SetProtectedPatient(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1778 int64_t id,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1779 uint8_t isProtected)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1780 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1781 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1782
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1783 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1784 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1785 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1786 t->GetBackend().SetProtectedPatient(t->GetManager(), id, (isProtected != 0));
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1787 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1788 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1789 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1790 }
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 static OrthancPluginErrorCode SetResourcesContent(OrthancPluginDatabaseTransaction* transaction,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1794 uint32_t countIdentifierTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1795 const OrthancPluginResourcesContentTags* identifierTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1796 uint32_t countMainDicomTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1797 const OrthancPluginResourcesContentTags* mainDicomTags,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1798 uint32_t countMetadata,
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1799 const OrthancPluginResourcesContentMetadata* metadata)
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1800 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1801 DatabaseBackendAdapterV3::Transaction* t = reinterpret_cast<DatabaseBackendAdapterV3::Transaction*>(transaction);
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1802
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1803 try
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1804 {
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1805 t->GetOutput().Clear();
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1806 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
1807 countMainDicomTags, mainDicomTags, countMetadata, metadata);
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1808 return OrthancPluginErrorCode_Success;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1809 }
225
94c9908e6aca removed DatabaseManager member out of class IndexBackend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 223
diff changeset
1810 ORTHANC_PLUGINS_DATABASE_CATCH(t->GetBackend().GetContext());
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1811 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1812
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1813
234
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1814 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
1815 size_t countConnections,
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1816 unsigned int maxDatabaseRetries)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1817 {
373
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1818 std::unique_ptr<IndexBackend> protection(backend);
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1819
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1820 if (isBackendInUse_)
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1821 {
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1822 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1823 }
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1824
222
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1825 if (backend == NULL)
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1826 {
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1827 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1828 }
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1829
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1830 OrthancPluginDatabaseBackendV3 params;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1831 memset(&params, 0, sizeof(params));
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1832
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1833 params.readAnswersCount = ReadAnswersCount;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1834 params.readAnswerAttachment = ReadAnswerAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1835 params.readAnswerChange = ReadAnswerChange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1836 params.readAnswerDicomTag = ReadAnswerDicomTag;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1837 params.readAnswerExportedResource = ReadAnswerExportedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1838 params.readAnswerInt32 = ReadAnswerInt32;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1839 params.readAnswerInt64 = ReadAnswerInt64;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1840 params.readAnswerMatchingResource = ReadAnswerMatchingResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1841 params.readAnswerMetadata = ReadAnswerMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1842 params.readAnswerString = ReadAnswerString;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1843
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1844 params.readEventsCount = ReadEventsCount;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1845 params.readEvent = ReadEvent;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1846
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1847 params.open = Open;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1848 params.close = Close;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1849 params.destructDatabase = DestructDatabase;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1850 params.getDatabaseVersion = GetDatabaseVersion;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1851 params.upgradeDatabase = UpgradeDatabase;
264
7ec412af11cb implementation of "hasRevisionsSupport" primitive in database SDK
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 262
diff changeset
1852 params.hasRevisionsSupport = HasRevisionsSupport;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1853 params.startTransaction = StartTransaction;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1854 params.destructTransaction = DestructTransaction;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1855 params.rollback = Rollback;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1856 params.commit = Commit;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1857
262
b0c65094b299 adding support for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 261
diff changeset
1858 params.addAttachment = AddAttachment;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1859 params.clearChanges = ClearChanges;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1860 params.clearExportedResources = ClearExportedResources;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1861 params.clearMainDicomTags = ClearMainDicomTags;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1862 params.createInstance = CreateInstance;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1863 params.deleteAttachment = DeleteAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1864 params.deleteMetadata = DeleteMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1865 params.deleteResource = DeleteResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1866 params.getAllMetadata = GetAllMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1867 params.getAllPublicIds = GetAllPublicIds;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1868 params.getAllPublicIdsWithLimit = GetAllPublicIdsWithLimit;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1869 params.getChanges = GetChanges;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1870 params.getChildrenInternalId = GetChildrenInternalId;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1871 params.getChildrenMetadata = GetChildrenMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1872 params.getChildrenPublicId = GetChildrenPublicId;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1873 params.getExportedResources = GetExportedResources;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1874 params.getLastChange = GetLastChange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1875 params.getLastChangeIndex = GetLastChangeIndex;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1876 params.getLastExportedResource = GetLastExportedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1877 params.getMainDicomTags = GetMainDicomTags;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1878 params.getPublicId = GetPublicId;
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1879 params.getResourceType = GetResourceType;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1880 params.getResourcesCount = GetResourcesCount;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1881 params.getTotalCompressedSize = GetTotalCompressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1882 params.getTotalUncompressedSize = GetTotalUncompressedSize;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1883 params.isDiskSizeAbove = IsDiskSizeAbove;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1884 params.isExistingResource = IsExistingResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1885 params.isProtectedPatient = IsProtectedPatient;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1886 params.listAvailableAttachments = ListAvailableAttachments;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1887 params.logChange = LogChange;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1888 params.logExportedResource = LogExportedResource;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1889 params.lookupAttachment = LookupAttachment;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1890 params.lookupGlobalProperty = LookupGlobalProperty;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1891 params.lookupMetadata = LookupMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1892 params.lookupParent = LookupParent;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1893 params.lookupResource = LookupResource;
261
34e2b93a7ac1 implementing interface for revisions in attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 260
diff changeset
1894 params.lookupResourceAndParent = LookupResourceAndParent;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1895 params.lookupResources = LookupResources;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1896 params.selectPatientToRecycle = SelectPatientToRecycle;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1897 params.selectPatientToRecycle2 = SelectPatientToRecycle2;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1898 params.setGlobalProperty = SetGlobalProperty;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1899 params.setMetadata = SetMetadata;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1900 params.setProtectedPatient = SetProtectedPatient;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1901 params.setResourcesContent = SetResourcesContent;
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1902
373
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1903 OrthancPluginContext* context = protection->GetContext();
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1904
234
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1905 if (OrthancPluginRegisterDatabaseBackendV3(
d1b124d116c1 PostgreSQL index plugin handles retries for collisions between multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 233
diff changeset
1906 context, &params, sizeof(params), maxDatabaseRetries,
374
4a3985088723 moved class IndexConnectionsPool out of DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 373
diff changeset
1907 new IndexConnectionsPool(protection.release(), countConnections)) != OrthancPluginErrorCode_Success)
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1908 {
373
be7de633695c started DatabaseBackendAdapterV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 359
diff changeset
1909 delete backend;
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1910 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError, "Unable to register the database backend");
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1911 }
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1912
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1913 backend->SetOutputFactory(new Factory);
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1914
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1915 isBackendInUse_ = true;
222
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1916 }
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 void DatabaseBackendAdapterV3::Finalize()
c8e06b41feec refactoring registration/finalization of index backend
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 221
diff changeset
1920 {
223
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1921 if (isBackendInUse_)
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1922 {
af049cd66661 removed singleton from DatabaseBackendAdapterV3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 222
diff changeset
1923 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
1924 }
212
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1925 }
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 # endif
821d4ba83dc3 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1929 #endif