annotate OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5839:7aef730c0859 default

cont
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 16 Oct 2024 19:34:42 +0200
parents 68fc5af30c03
children 77875b51cf95 8279eaab0d1d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5520
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5520
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5254
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "../../Sources/PrecompiledHeadersServer.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "OrthancPluginDatabaseV4.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #if ORTHANC_ENABLE_PLUGINS != 1
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # error The plugin support is disabled
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #endif
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
5254
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
31 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include "../../../OrthancFramework/Sources/Logging.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include "../../../OrthancFramework/Sources/OrthancException.h"
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
34 #include "../../Sources/Database/ResourcesContent.h"
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
35 #include "../../Sources/Database/VoidDatabaseListener.h"
5254
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
36 #include "../../Sources/ServerToolbox.h"
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #include "PluginsEnumerations.h"
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
39 #include "OrthancDatabasePlugin.pb.h" // Auto-generated file
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <cassert>
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace Orthanc
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
46 static void CheckSuccess(PluginsErrorDictionary& errorDictionary,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
47 OrthancPluginErrorCode code)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
48 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
49 if (code != OrthancPluginErrorCode_Success)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
50 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
51 errorDictionary.LogError(code, true);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
52 throw OrthancException(static_cast<ErrorCode>(code));
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
53 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
54 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
55
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
56
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
57 static ResourceType Convert(DatabasePluginMessages::ResourceType type)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
58 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
59 switch (type)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
60 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
61 case DatabasePluginMessages::RESOURCE_PATIENT:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
62 return ResourceType_Patient;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
63
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
64 case DatabasePluginMessages::RESOURCE_STUDY:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
65 return ResourceType_Study;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
66
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
67 case DatabasePluginMessages::RESOURCE_SERIES:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
68 return ResourceType_Series;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
69
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
70 case DatabasePluginMessages::RESOURCE_INSTANCE:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
71 return ResourceType_Instance;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
72
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
73 default:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
74 throw OrthancException(ErrorCode_ParameterOutOfRange);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
75 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
76 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
77
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
78
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
79 static DatabasePluginMessages::ResourceType Convert(ResourceType type)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
80 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
81 switch (type)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
82 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
83 case ResourceType_Patient:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
84 return DatabasePluginMessages::RESOURCE_PATIENT;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
85
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
86 case ResourceType_Study:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
87 return DatabasePluginMessages::RESOURCE_STUDY;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
88
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
89 case ResourceType_Series:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
90 return DatabasePluginMessages::RESOURCE_SERIES;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
91
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
92 case ResourceType_Instance:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
93 return DatabasePluginMessages::RESOURCE_INSTANCE;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
94
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
95 default:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
96 throw OrthancException(ErrorCode_ParameterOutOfRange);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
97 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
98 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
99
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
100
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
101 static FileInfo Convert(const DatabasePluginMessages::FileInfo& source)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
102 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
103 return FileInfo(source.uuid(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
104 static_cast<FileContentType>(source.content_type()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
105 source.uncompressed_size(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
106 source.uncompressed_hash(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
107 static_cast<CompressionType>(source.compression_type()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
108 source.compressed_size(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
109 source.compressed_hash());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
110 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
111
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
112
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
113 static ServerIndexChange Convert(const DatabasePluginMessages::ServerIndexChange& source)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
114 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
115 return ServerIndexChange(source.seq(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
116 static_cast<ChangeType>(source.change_type()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
117 Convert(source.resource_type()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
118 source.public_id(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
119 source.date());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
120 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
121
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
122
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
123 static ExportedResource Convert(const DatabasePluginMessages::ExportedResource& source)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
124 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
125 return ExportedResource(source.seq(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
126 Convert(source.resource_type()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
127 source.public_id(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
128 source.modality(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
129 source.date(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
130 source.patient_id(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
131 source.study_instance_uid(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
132 source.series_instance_uid(),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
133 source.sop_instance_uid());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
134 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
135
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
136
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
137 static void Execute(DatabasePluginMessages::Response& response,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
138 const OrthancPluginDatabaseV4& database,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
139 const DatabasePluginMessages::Request& request)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
140 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
141 std::string requestSerialized;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
142 request.SerializeToString(&requestSerialized);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
143
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
144 OrthancPluginMemoryBuffer64 responseSerialized;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
145 CheckSuccess(database.GetErrorDictionary(), database.GetDefinition().operations(
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
146 &responseSerialized, database.GetDefinition().backend,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
147 requestSerialized.empty() ? NULL : requestSerialized.c_str(),
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
148 requestSerialized.size()));
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
149
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
150 bool success = response.ParseFromArray(responseSerialized.data, responseSerialized.size);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
151
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
152 if (responseSerialized.size > 0)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
153 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
154 free(responseSerialized.data);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
155 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
156
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
157 if (!success)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
158 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
159 throw OrthancException(ErrorCode_DatabasePlugin, "Cannot unserialize protobuf originating from the database plugin");
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
160 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
161 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
162
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
163
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
164 static void ExecuteDatabase(DatabasePluginMessages::DatabaseResponse& response,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
165 const OrthancPluginDatabaseV4& database,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
166 DatabasePluginMessages::DatabaseOperation operation,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
167 const DatabasePluginMessages::DatabaseRequest& request)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
168 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
169 DatabasePluginMessages::Request fullRequest;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
170 fullRequest.set_type(DatabasePluginMessages::REQUEST_DATABASE);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
171 fullRequest.mutable_database_request()->CopyFrom(request);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
172 fullRequest.mutable_database_request()->set_operation(operation);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
173
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
174 DatabasePluginMessages::Response fullResponse;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
175 Execute(fullResponse, database, fullRequest);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
176
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
177 response.CopyFrom(fullResponse.database_response());
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
178 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
179
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
180
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 class OrthancPluginDatabaseV4::Transaction : public IDatabaseWrapper::ITransaction
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 private:
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
184 OrthancPluginDatabaseV4& database_;
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 IDatabaseListener& listener_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 void* transaction_;
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
187
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
188 void ExecuteTransaction(DatabasePluginMessages::TransactionResponse& response,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
189 DatabasePluginMessages::TransactionOperation operation,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
190 const DatabasePluginMessages::TransactionRequest& request)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
191 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
192 DatabasePluginMessages::Request fullRequest;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
193 fullRequest.set_type(DatabasePluginMessages::REQUEST_TRANSACTION);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
194 fullRequest.mutable_transaction_request()->CopyFrom(request);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
195 fullRequest.mutable_transaction_request()->set_transaction(reinterpret_cast<intptr_t>(transaction_));
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
196 fullRequest.mutable_transaction_request()->set_operation(operation);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
198 DatabasePluginMessages::Response fullResponse;
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
199 Execute(fullResponse, database_, fullRequest);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
200
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
201 response.CopyFrom(fullResponse.transaction_response());
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
204
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
205 void ExecuteTransaction(DatabasePluginMessages::TransactionResponse& response,
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
206 DatabasePluginMessages::TransactionOperation operation)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
207 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
208 DatabasePluginMessages::TransactionRequest request; // Ignored
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
209 ExecuteTransaction(response, operation, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
210 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
211
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
212
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
213 void ExecuteTransaction(DatabasePluginMessages::TransactionOperation operation,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
214 const DatabasePluginMessages::TransactionRequest& request)
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
215 {
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
216 DatabasePluginMessages::TransactionResponse response; // Ignored
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
217 ExecuteTransaction(response, operation, request);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
218 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
219
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
220
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
221 void ExecuteTransaction(DatabasePluginMessages::TransactionOperation operation)
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 {
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
223 DatabasePluginMessages::TransactionResponse response; // Ignored
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
224 DatabasePluginMessages::TransactionRequest request; // Ignored
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
225 ExecuteTransaction(response, operation, request);
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
226 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
227
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
228
5249
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
229 void ListLabelsInternal(std::set<std::string>& target,
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
230 bool isSingleResource,
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
231 int64_t resource)
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
232 {
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
233 if (database_.GetDatabaseCapabilities().HasLabelsSupport())
5249
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
234 {
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
235 DatabasePluginMessages::TransactionRequest request;
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
236 request.mutable_list_labels()->set_single_resource(isSingleResource);
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
237 request.mutable_list_labels()->set_id(resource);
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
238
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
239 DatabasePluginMessages::TransactionResponse response;
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
240 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LIST_LABELS, request);
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
241
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
242 target.clear();
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
243 for (int i = 0; i < response.list_labels().labels().size(); i++)
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
244 {
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
245 target.insert(response.list_labels().labels(i));
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
246 }
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
247 }
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
248 else
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
249 {
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
250 // This method shouldn't have been called
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
251 throw OrthancException(ErrorCode_InternalError);
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
252 }
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
253 }
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
254
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
255
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
256 public:
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
257 Transaction(OrthancPluginDatabaseV4& database,
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
258 IDatabaseListener& listener,
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
259 TransactionType type) :
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
260 database_(database),
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
261 listener_(listener),
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
262 transaction_(NULL)
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
263 {
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
264 DatabasePluginMessages::DatabaseRequest request;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
265
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
266 switch (type)
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
267 {
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
268 case TransactionType_ReadOnly:
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
269 request.mutable_start_transaction()->set_type(DatabasePluginMessages::TRANSACTION_READ_ONLY);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
270 break;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
271
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
272 case TransactionType_ReadWrite:
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
273 request.mutable_start_transaction()->set_type(DatabasePluginMessages::TRANSACTION_READ_WRITE);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
274 break;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
275
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
276 default:
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
277 throw OrthancException(ErrorCode_ParameterOutOfRange);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
278 }
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
279
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
280 DatabasePluginMessages::DatabaseResponse response;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
281 ExecuteDatabase(response, database, DatabasePluginMessages::OPERATION_START_TRANSACTION, request);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
282
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
283 transaction_ = reinterpret_cast<void*>(response.start_transaction().transaction());
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
284
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
285 if (transaction_ == NULL)
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
286 {
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
287 throw OrthancException(ErrorCode_NullPointer);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
288 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 virtual ~Transaction()
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 {
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
294 try
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
295 {
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
296 DatabasePluginMessages::DatabaseRequest request;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
297 request.mutable_finalize_transaction()->set_transaction(reinterpret_cast<intptr_t>(transaction_));
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
298
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
299 DatabasePluginMessages::DatabaseResponse response;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
300 ExecuteDatabase(response, database_, DatabasePluginMessages::OPERATION_FINALIZE_TRANSACTION, request);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
301 }
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
302 catch (OrthancException& e)
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
303 {
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
304 // Destructors must not throw exceptions
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
305 LOG(ERROR) << "Cannot finalize the database engine: " << e.What();
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
306 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 }
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
308
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
309 void* GetTransactionObject()
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
310 {
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
311 return transaction_;
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
312 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
314
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
315 virtual void Rollback() ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
316 {
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
317 ExecuteTransaction(DatabasePluginMessages::OPERATION_ROLLBACK);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
318 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
319
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
320
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
321 virtual void Commit(int64_t fileSizeDelta) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
322 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
323 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
324 request.mutable_commit()->set_file_size_delta(fileSizeDelta);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
325
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
326 ExecuteTransaction(DatabasePluginMessages::OPERATION_COMMIT, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 virtual void AddAttachment(int64_t id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 const FileInfo& attachment,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 int64_t revision) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
334 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
335 request.mutable_add_attachment()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
336 request.mutable_add_attachment()->mutable_attachment()->set_uuid(attachment.GetUuid());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
337 request.mutable_add_attachment()->mutable_attachment()->set_content_type(attachment.GetContentType());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
338 request.mutable_add_attachment()->mutable_attachment()->set_uncompressed_size(attachment.GetUncompressedSize());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
339 request.mutable_add_attachment()->mutable_attachment()->set_uncompressed_hash(attachment.GetUncompressedMD5());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
340 request.mutable_add_attachment()->mutable_attachment()->set_compression_type(attachment.GetCompressionType());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
341 request.mutable_add_attachment()->mutable_attachment()->set_compressed_size(attachment.GetCompressedSize());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
342 request.mutable_add_attachment()->mutable_attachment()->set_compressed_hash(attachment.GetCompressedMD5());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
343 request.mutable_add_attachment()->set_revision(revision);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
344
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
345 ExecuteTransaction(DatabasePluginMessages::OPERATION_ADD_ATTACHMENT, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
346 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
347
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
348
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
349 virtual void ClearChanges() ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
350 {
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
351 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_CHANGES);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
352 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
353
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
354
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
355 virtual void ClearExportedResources() ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
356 {
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
357 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_EXPORTED_RESOURCES);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
358 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
360
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 virtual void DeleteAttachment(int64_t id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362 FileContentType attachment) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
364 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
365 request.mutable_delete_attachment()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
366 request.mutable_delete_attachment()->set_type(attachment);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
367
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
368 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
369 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_DELETE_ATTACHMENT, request);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
370
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
371 listener_.SignalAttachmentDeleted(Convert(response.delete_attachment().deleted_attachment()));
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375 virtual void DeleteMetadata(int64_t id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376 MetadataType type) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
378 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
379 request.mutable_delete_metadata()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
380 request.mutable_delete_metadata()->set_type(type);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
381
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
382 ExecuteTransaction(DatabasePluginMessages::OPERATION_DELETE_METADATA, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
383 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
384
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
385
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
386 virtual void DeleteResource(int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
387 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
388 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
389 request.mutable_delete_resource()->set_id(id);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
390
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
391 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
392 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_DELETE_RESOURCE, request);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
393
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
394 for (int i = 0; i < response.delete_resource().deleted_attachments().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
395 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
396 listener_.SignalAttachmentDeleted(Convert(response.delete_resource().deleted_attachments(i)));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
397 }
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
398
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
399 for (int i = 0; i < response.delete_resource().deleted_resources().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
400 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
401 listener_.SignalResourceDeleted(Convert(response.delete_resource().deleted_resources(i).level()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
402 response.delete_resource().deleted_resources(i).public_id());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
403 }
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
404
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
405 if (response.delete_resource().is_remaining_ancestor())
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
406 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
407 listener_.SignalRemainingAncestor(Convert(response.delete_resource().remaining_ancestor().level()),
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
408 response.delete_resource().remaining_ancestor().public_id());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
409 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
410 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
411
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
412
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
414 int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
416 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
417 request.mutable_get_all_metadata()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
418
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
419 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
420 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_ALL_METADATA, request);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
421
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
422 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
423 for (int i = 0; i < response.get_all_metadata().metadata().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
424 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
425 MetadataType key = static_cast<MetadataType>(response.get_all_metadata().metadata(i).type());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
426
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
427 if (target.find(key) == target.end())
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
428 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
429 target[key] = response.get_all_metadata().metadata(i).value();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
430 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
431 else
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
432 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
433 throw OrthancException(ErrorCode_DatabasePlugin);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
434 }
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
435 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439 virtual void GetAllPublicIds(std::list<std::string>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
440 ResourceType resourceType) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
442 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
443 request.mutable_get_all_public_ids()->set_resource_type(Convert(resourceType));
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
444
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
445 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
446 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_ALL_PUBLIC_IDS, request);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
447
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
448 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
449 for (int i = 0; i < response.get_all_public_ids().ids().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
450 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
451 target.push_back(response.get_all_public_ids().ids(i));
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
452 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
453 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
454
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
455
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
456 virtual void GetAllPublicIds(std::list<std::string>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
457 ResourceType resourceType,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
458 int64_t since,
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
459 uint32_t limit) ORTHANC_OVERRIDE
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
461 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
462 request.mutable_get_all_public_ids_with_limits()->set_resource_type(Convert(resourceType));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
463 request.mutable_get_all_public_ids_with_limits()->set_since(since);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
464 request.mutable_get_all_public_ids_with_limits()->set_limit(limit);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
465
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
466 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
467 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_ALL_PUBLIC_IDS_WITH_LIMITS, request);
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
468
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
469 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
470 for (int i = 0; i < response.get_all_public_ids_with_limits().ids().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
471 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
472 target.push_back(response.get_all_public_ids_with_limits().ids(i));
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
473 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
474 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
475
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
476
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
477 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
478 bool& done /*out*/,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
479 int64_t since,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
480 uint32_t limit) ORTHANC_OVERRIDE
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
481 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
482 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
483 request.mutable_get_changes()->set_since(since);
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
484 request.mutable_get_changes()->set_limit(limit);
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
485
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
486 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
487 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHANGES, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
488
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
489 done = response.get_changes().done();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
490
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
491 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
492 for (int i = 0; i < response.get_changes().changes().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
493 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
494 target.push_back(Convert(response.get_changes().changes(i)));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
495 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
499 virtual void GetChildrenInternalId(std::list<int64_t>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
500 int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
501 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
502 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
503 request.mutable_get_children_internal_id()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
504
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
505 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
506 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_INTERNAL_ID, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
507
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
508 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
509 for (int i = 0; i < response.get_children_internal_id().ids().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
510 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
511 target.push_back(response.get_children_internal_id().ids(i));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
512 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
513 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
514
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516 virtual void GetChildrenPublicId(std::list<std::string>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
519 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
520 request.mutable_get_children_public_id()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
521
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
522 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
523 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_PUBLIC_ID, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
524
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
525 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
526 for (int i = 0; i < response.get_children_public_id().ids().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
527 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
528 target.push_back(response.get_children_public_id().ids(i));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
529 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
530 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
531
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
532
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
533 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
534 bool& done /*out*/,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
535 int64_t since,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
536 uint32_t limit) ORTHANC_OVERRIDE
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
538 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
539 request.mutable_get_exported_resources()->set_since(since);
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
540 request.mutable_get_exported_resources()->set_limit(limit);
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
541
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
542 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
543 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_EXPORTED_RESOURCES, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
544
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
545 done = response.get_exported_resources().done();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
546
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
547 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
548 for (int i = 0; i < response.get_exported_resources().resources().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
549 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
550 target.push_back(Convert(response.get_exported_resources().resources(i)));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
551 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
552 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
553
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
554
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
555 virtual void GetLastChange(std::list<ServerIndexChange>& target /*out*/) ORTHANC_OVERRIDE
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
556 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
557 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
558 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_CHANGE);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
559
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
560 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
561 if (response.get_last_change().found())
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
562 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
563 target.push_back(Convert(response.get_last_change().change()));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
564 }
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
565 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
567
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
570 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
571 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_EXPORTED_RESOURCE);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
572
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
573 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
574 if (response.get_last_exported_resource().found())
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
575 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
576 target.push_back(Convert(response.get_last_exported_resource().resource()));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
577 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
580
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
581 virtual void GetMainDicomTags(DicomMap& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
582 int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
583 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
584 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
585 request.mutable_get_main_dicom_tags()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
586
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
587 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
588 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_MAIN_DICOM_TAGS, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
589
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
590 target.Clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
591
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
592 for (int i = 0; i < response.get_main_dicom_tags().tags().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
593 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
594 const DatabasePluginMessages::GetMainDicomTags_Response_Tag& tag = response.get_main_dicom_tags().tags(i);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
595 if (tag.group() > 0xffffu ||
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
596 tag.element() > 0xffffu)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
597 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
598 throw OrthancException(ErrorCode_ParameterOutOfRange);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
599 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
600 else
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
601 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
602 target.SetValue(tag.group(), tag.element(), tag.value(), false);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
603 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
604 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
606
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
607
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
608 virtual std::string GetPublicId(int64_t resourceId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
609 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
610 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
611 request.mutable_get_public_id()->set_id(resourceId);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
612
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
613 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
614 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_PUBLIC_ID, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
615 return response.get_public_id().id();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
616 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
617
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
618
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
619 virtual uint64_t GetResourcesCount(ResourceType resourceType) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
621 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
622 request.mutable_get_resources_count()->set_type(Convert(resourceType));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
623
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
624 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
625 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_RESOURCES_COUNT, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
626 return response.get_resources_count().count();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
627 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
628
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
629
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
630 virtual ResourceType GetResourceType(int64_t resourceId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
631 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
632 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
633 request.mutable_get_resource_type()->set_id(resourceId);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
634
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
635 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
636 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_RESOURCE_TYPE, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
637 return Convert(response.get_resource_type().type());
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
638 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
639
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
640
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
641 virtual uint64_t GetTotalCompressedSize() ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
642 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
643 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
644 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_TOTAL_COMPRESSED_SIZE);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
645 return response.get_total_compressed_size().size();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
646 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
647
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
648
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
649 virtual uint64_t GetTotalUncompressedSize() ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
650 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
651 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
652 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_TOTAL_UNCOMPRESSED_SIZE);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
653 return response.get_total_uncompressed_size().size();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
654 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
655
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
656
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
657 virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
658 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
659 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
660 request.mutable_is_protected_patient()->set_patient_id(internalId);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
661
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
662 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
663 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_IS_PROTECTED_PATIENT, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
664 return response.is_protected_patient().protected_patient();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
665 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
666
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
667
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
668 virtual void ListAvailableAttachments(std::set<FileContentType>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
669 int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
670 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
671 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
672 request.mutable_list_available_attachments()->set_id(id);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
673
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
674 DatabasePluginMessages::TransactionResponse response;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
675 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LIST_AVAILABLE_ATTACHMENTS, request);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
676
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
677 target.clear();
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
678 for (int i = 0; i < response.list_available_attachments().attachments().size(); i++)
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
679 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
680 FileContentType attachment = static_cast<FileContentType>(response.list_available_attachments().attachments(i));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
681
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
682 if (target.find(attachment) == target.end())
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
683 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
684 target.insert(attachment);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
685 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
686 else
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
687 {
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
688 throw OrthancException(ErrorCode_DatabasePlugin);
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
689 }
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
690 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
691 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
692
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
693
5216
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
694 virtual void LogChange(ChangeType changeType,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
695 ResourceType resourceType,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
696 int64_t internalId,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
697 const std::string& /* publicId - unused */,
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
698 const std::string& date) ORTHANC_OVERRIDE
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
699 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
700 DatabasePluginMessages::TransactionRequest request;
5216
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
701 request.mutable_log_change()->set_change_type(changeType);
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
702 request.mutable_log_change()->set_resource_type(Convert(resourceType));
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
703 request.mutable_log_change()->set_resource_id(internalId);
5216
450ac804d3af simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5215
diff changeset
704 request.mutable_log_change()->set_date(date);
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
705
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
706 ExecuteTransaction(DatabasePluginMessages::OPERATION_LOG_CHANGE, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
707 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
708
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
709
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
710 virtual void LogExportedResource(const ExportedResource& resource) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
711 {
5210
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
712 // TODO: "seq" is ignored, could be simplified in "ExportedResource"
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
713
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
714 DatabasePluginMessages::TransactionRequest request;
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
715 request.mutable_log_exported_resource()->set_resource_type(Convert(resource.GetResourceType()));
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
716 request.mutable_log_exported_resource()->set_public_id(resource.GetPublicId());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
717 request.mutable_log_exported_resource()->set_modality(resource.GetModality());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
718 request.mutable_log_exported_resource()->set_date(resource.GetDate());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
719 request.mutable_log_exported_resource()->set_patient_id(resource.GetPatientId());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
720 request.mutable_log_exported_resource()->set_study_instance_uid(resource.GetStudyInstanceUid());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
721 request.mutable_log_exported_resource()->set_series_instance_uid(resource.GetSeriesInstanceUid());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
722 request.mutable_log_exported_resource()->set_sop_instance_uid(resource.GetSopInstanceUid());
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
723
6a7a244c777d cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5209
diff changeset
724 ExecuteTransaction(DatabasePluginMessages::OPERATION_LOG_EXPORTED_RESOURCE, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
725 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
726
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
727
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
728 virtual bool LookupAttachment(FileInfo& attachment,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
729 int64_t& revision,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
730 int64_t id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
731 FileContentType contentType) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
732 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
733 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
734 request.mutable_lookup_attachment()->set_id(id);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
735 request.mutable_lookup_attachment()->set_content_type(contentType);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
736
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
737 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
738 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_ATTACHMENT, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
739
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
740 if (response.lookup_attachment().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
741 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
742 attachment = Convert(response.lookup_attachment().attachment());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
743 revision = response.lookup_attachment().revision();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
744 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
745 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
746 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
747 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
748 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
749 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
750 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
751
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
752
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
753 virtual bool LookupGlobalProperty(std::string& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
754 GlobalProperty property,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
755 bool shared) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
756 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
757 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
758 request.mutable_lookup_global_property()->set_server_id(shared ? "" : database_.GetServerIdentifier());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
759 request.mutable_lookup_global_property()->set_property(property);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
760
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
761 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
762 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_GLOBAL_PROPERTY, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
763
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
764 if (response.lookup_global_property().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
765 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
766 target = response.lookup_global_property().value();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
767 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
768 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
769 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
770 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
771 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
772 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
773 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
774
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
775
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
776 virtual int64_t IncrementGlobalProperty(GlobalProperty property,
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
777 int64_t increment,
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
778 bool shared) ORTHANC_OVERRIDE
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
779 {
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
780 DatabasePluginMessages::TransactionRequest request;
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
781 request.mutable_increment_global_property()->set_server_id(shared ? "" : database_.GetServerIdentifier());
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
782 request.mutable_increment_global_property()->set_property(property);
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
783 request.mutable_increment_global_property()->set_increment(increment);
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
784
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
785 DatabasePluginMessages::TransactionResponse response;
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
786 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_INCREMENT_GLOBAL_PROPERTY, request);
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
787
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
788 return response.increment_global_property().new_value();
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
789 }
5466
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
790
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
791 virtual void UpdateAndGetStatistics(int64_t& patientsCount,
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
792 int64_t& studiesCount,
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
793 int64_t& seriesCount,
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
794 int64_t& instancesCount,
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
795 int64_t& compressedSize,
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
796 int64_t& uncompressedSize) ORTHANC_OVERRIDE
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
797 {
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
798 DatabasePluginMessages::TransactionResponse response;
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
799 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_UPDATE_AND_GET_STATISTICS);
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
800
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
801 patientsCount = response.update_and_get_statistics().patients_count();
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
802 studiesCount = response.update_and_get_statistics().studies_count();
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
803 seriesCount = response.update_and_get_statistics().series_count();
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
804 instancesCount = response.update_and_get_statistics().instances_count();
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
805 compressedSize = response.update_and_get_statistics().total_compressed_size();
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
806 uncompressedSize = response.update_and_get_statistics().total_uncompressed_size();
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
807 }
dceed5e3d6a9 new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents: 5455
diff changeset
808
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
809 virtual bool LookupMetadata(std::string& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
810 int64_t& revision,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
811 int64_t id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
812 MetadataType type) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
813 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
814 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
815 request.mutable_lookup_metadata()->set_id(id);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
816 request.mutable_lookup_metadata()->set_metadata_type(type);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
817
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
818 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
819 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_METADATA, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
820
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
821 if (response.lookup_metadata().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
822 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
823 target = response.lookup_metadata().value();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
824 revision = response.lookup_metadata().revision();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
825 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
826 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
827 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
828 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
829 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
830 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
831 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
832
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834 virtual bool LookupParent(int64_t& parentId,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 int64_t resourceId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
837 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
838 request.mutable_lookup_parent()->set_id(resourceId);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
839
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
840 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
841 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_PARENT, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
842
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
843 if (response.lookup_parent().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
844 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
845 parentId = response.lookup_parent().parent();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
846 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
847 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
848 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
849 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
850 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
851 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
852 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
853
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
854
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
855 virtual bool LookupResource(int64_t& id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 ResourceType& type,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
857 const std::string& publicId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
858 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
859 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
860 request.mutable_lookup_resource()->set_public_id(publicId);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
861
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
862 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
863 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCE, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
864
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
865 if (response.lookup_resource().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
866 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
867 id = response.lookup_resource().internal_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
868 type = Convert(response.lookup_resource().type());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
869 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
870 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
871 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
872 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
873 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
874 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
875 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
876
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
877
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
878 virtual bool SelectPatientToRecycle(int64_t& internalId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
879 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
880 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
881 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_SELECT_PATIENT_TO_RECYCLE);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
882
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
883 if (response.select_patient_to_recycle().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
884 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
885 internalId = response.select_patient_to_recycle().patient_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
886 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
887 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
888 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
889 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
890 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
891 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
892 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
893
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
894
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
895 virtual bool SelectPatientToRecycle(int64_t& internalId,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
896 int64_t patientIdToAvoid) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
897 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
898 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
899 request.mutable_select_patient_to_recycle_with_avoid()->set_patient_id_to_avoid(patientIdToAvoid);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
900
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
901 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
902 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_SELECT_PATIENT_TO_RECYCLE_WITH_AVOID, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
903
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
904 if (response.select_patient_to_recycle_with_avoid().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
905 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
906 internalId = response.select_patient_to_recycle_with_avoid().patient_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
907 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
908 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
909 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
910 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
911 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
912 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
913 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
915
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
916 virtual void SetGlobalProperty(GlobalProperty property,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
917 bool shared,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
918 const std::string& value) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
919 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
920 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
921 request.mutable_set_global_property()->set_server_id(shared ? "" : database_.GetServerIdentifier());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
922 request.mutable_set_global_property()->set_property(property);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
923 request.mutable_set_global_property()->set_value(value);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
924
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
925 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_GLOBAL_PROPERTY, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
928
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
929 virtual void ClearMainDicomTags(int64_t id) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
930 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
931 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
932 request.mutable_clear_main_dicom_tags()->set_id(id);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
933
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
934 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_MAIN_DICOM_TAGS, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
936
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
937
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
938 virtual void SetMetadata(int64_t id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
939 MetadataType type,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
940 const std::string& value,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
941 int64_t revision) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
942 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
943 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
944 request.mutable_set_metadata()->set_id(id);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
945 request.mutable_set_metadata()->set_metadata_type(type);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
946 request.mutable_set_metadata()->set_value(value);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
947 request.mutable_set_metadata()->set_revision(revision);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
948
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
949 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_METADATA, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
950 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
951
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
952
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
953 virtual void SetProtectedPatient(int64_t internalId,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
954 bool isProtected) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
955 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
956 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
957 request.mutable_set_protected_patient()->set_patient_id(internalId);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
958 request.mutable_set_protected_patient()->set_protected_patient(isProtected);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
959
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
960 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_PROTECTED_PATIENT, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
961 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
962
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
963
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
964 virtual bool IsDiskSizeAbove(uint64_t threshold) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
965 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
966 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
967 request.mutable_is_disk_size_above()->set_threshold(threshold);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
968
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
969 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
970 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_IS_DISK_SIZE_ABOVE, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
971
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
972 return response.is_disk_size_above().result();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
973 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
974
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
975
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
976 virtual void ApplyLookupResources(std::list<std::string>& resourcesId,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
977 std::list<std::string>* instancesId, // Can be NULL if not needed
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
978 const DatabaseConstraints& lookup,
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
979 ResourceType queryLevel,
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
980 const std::set<std::string>& labels,
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
981 LabelsConstraint labelsConstraint,
5213
055428d92772 clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5211
diff changeset
982 uint32_t limit) ORTHANC_OVERRIDE
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
983 {
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
984 if (!database_.GetDatabaseCapabilities().HasLabelsSupport() &&
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
985 !labels.empty())
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
986 {
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
987 throw OrthancException(ErrorCode_InternalError);
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
988 }
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
989
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
990 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
991 request.mutable_lookup_resources()->set_query_level(Convert(queryLevel));
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
992 request.mutable_lookup_resources()->set_limit(limit);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
993 request.mutable_lookup_resources()->set_retrieve_instances_ids(instancesId != NULL);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
994
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
995 request.mutable_lookup_resources()->mutable_lookup()->Reserve(lookup.GetSize());
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
996
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
997 for (size_t i = 0; i < lookup.GetSize(); i++)
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
998 {
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
999 const DatabaseConstraint& source = lookup.GetConstraint(i);
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1000
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1001 DatabasePluginMessages::DatabaseConstraint* target = request.mutable_lookup_resources()->add_lookup();
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1002 target->set_level(Convert(source.GetLevel()));
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1003 target->set_tag_group(source.GetTag().GetGroup());
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1004 target->set_tag_element(source.GetTag().GetElement());
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1005 target->set_is_identifier_tag(source.IsIdentifier());
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1006 target->set_is_case_sensitive(source.IsCaseSensitive());
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1007 target->set_is_mandatory(source.IsMandatory());
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1008
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1009 target->mutable_values()->Reserve(source.GetValuesCount());
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1010 for (size_t j = 0; j < source.GetValuesCount(); j++)
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1011 {
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1012 target->add_values(source.GetValue(j));
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1013 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1014
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1015 switch (source.GetConstraintType())
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1016 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1017 case ConstraintType_Equal:
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1018 target->set_type(DatabasePluginMessages::CONSTRAINT_EQUAL);
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1019 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1020
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1021 case ConstraintType_SmallerOrEqual:
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1022 target->set_type(DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL);
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1023 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1024
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1025 case ConstraintType_GreaterOrEqual:
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1026 target->set_type(DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL);
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1027 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1028
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1029 case ConstraintType_Wildcard:
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1030 target->set_type(DatabasePluginMessages::CONSTRAINT_WILDCARD);
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1031 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1032
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1033 case ConstraintType_List:
5680
68fc5af30c03 added container class DatabaseConstraints
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5640
diff changeset
1034 target->set_type(DatabasePluginMessages::CONSTRAINT_LIST);
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1035 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1036
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1037 default:
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1038 throw OrthancException(ErrorCode_ParameterOutOfRange);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1039 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1040 }
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1041
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1042 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it)
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1043 {
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1044 request.mutable_lookup_resources()->add_labels(*it);
5239
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1045 }
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1046
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1047 switch (labelsConstraint)
5239
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1048 {
5248
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1049 case LabelsConstraint_All:
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1050 request.mutable_lookup_resources()->set_labels_constraint(DatabasePluginMessages::LABELS_CONSTRAINT_ALL);
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1051 break;
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1052
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1053 case LabelsConstraint_Any:
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1054 request.mutable_lookup_resources()->set_labels_constraint(DatabasePluginMessages::LABELS_CONSTRAINT_ANY);
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1055 break;
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1056
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1057 case LabelsConstraint_None:
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1058 request.mutable_lookup_resources()->set_labels_constraint(DatabasePluginMessages::LABELS_CONSTRAINT_NONE);
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1059 break;
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1060
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1061 default:
a7d95f951f8a replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5239
diff changeset
1062 throw OrthancException(ErrorCode_ParameterOutOfRange);
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1063 }
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1064
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1065 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1066 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1067
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1068 for (int i = 0; i < response.lookup_resources().resources_ids().size(); i++)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1069 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1070 resourcesId.push_back(response.lookup_resources().resources_ids(i));
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1071 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1072
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1073 if (instancesId != NULL)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1074 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1075 if (response.lookup_resources().resources_ids().size() != response.lookup_resources().instances_ids().size())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1076 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1077 throw OrthancException(ErrorCode_DatabasePlugin);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1078 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1079 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1080 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1081 for (int i = 0; i < response.lookup_resources().instances_ids().size(); i++)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1082 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1083 instancesId->push_back(response.lookup_resources().instances_ids(i));
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1084 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1085 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1086 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1087 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1088
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1089
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1090 virtual bool CreateInstance(CreateInstanceResult& result, /* out */
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1091 int64_t& instanceId, /* out */
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1092 const std::string& patient,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1093 const std::string& study,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1094 const std::string& series,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1095 const std::string& instance) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1096 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1097 // TODO: "CreateInstanceResult" => constructor and getters
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1098
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1099 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1100 request.mutable_create_instance()->set_patient(patient);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1101 request.mutable_create_instance()->set_study(study);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1102 request.mutable_create_instance()->set_series(series);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1103 request.mutable_create_instance()->set_instance(instance);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1104
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1105 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1106 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_CREATE_INSTANCE, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1107
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1108 instanceId = response.create_instance().instance_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1109
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1110 if (response.create_instance().is_new_instance())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1111 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1112 result.isNewPatient_ = response.create_instance().is_new_patient();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1113 result.isNewStudy_ = response.create_instance().is_new_study();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1114 result.isNewSeries_ = response.create_instance().is_new_series();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1115 result.patientId_ = response.create_instance().patient_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1116 result.studyId_ = response.create_instance().study_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1117 result.seriesId_ = response.create_instance().series_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1118 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1119 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1120 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1121 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1122 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1123 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1124 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1125
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1126
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1127 virtual void SetResourcesContent(const ResourcesContent& content) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1128 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1129 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1130
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1131 request.mutable_set_resources_content()->mutable_tags()->Reserve(content.GetListTags().size());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1132 for (ResourcesContent::ListTags::const_iterator it = content.GetListTags().begin(); it != content.GetListTags().end(); ++it)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1133 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1134 DatabasePluginMessages::SetResourcesContent_Request_Tag* tag = request.mutable_set_resources_content()->add_tags();
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1135 tag->set_resource_id(it->GetResourceId());
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1136 tag->set_is_identifier(it->IsIdentifier());
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1137 tag->set_group(it->GetTag().GetGroup());
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1138 tag->set_element(it->GetTag().GetElement());
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1139 tag->set_value(it->GetValue());
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1140 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1141
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1142 request.mutable_set_resources_content()->mutable_metadata()->Reserve(content.GetListMetadata().size());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1143 for (ResourcesContent::ListMetadata::const_iterator it = content.GetListMetadata().begin(); it != content.GetListMetadata().end(); ++it)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1144 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1145 DatabasePluginMessages::SetResourcesContent_Request_Metadata* metadata = request.mutable_set_resources_content()->add_metadata();
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1146 metadata->set_resource_id(it->GetResourceId());
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1147 metadata->set_metadata(it->GetType());
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1148 metadata->set_value(it->GetValue());
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1149 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1150
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1151 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_RESOURCES_CONTENT, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1152 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1153
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1154
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1155 virtual void GetChildrenMetadata(std::list<std::string>& target,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1156 int64_t resourceId,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1157 MetadataType metadata) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1158 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1159 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1160 request.mutable_get_children_metadata()->set_id(resourceId);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1161 request.mutable_get_children_metadata()->set_metadata(metadata);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1162
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1163 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1164 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_METADATA, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1165
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1166 for (int i = 0; i < response.get_children_metadata().values().size(); i++)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1167 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1168 target.push_back(response.get_children_metadata().values(i));
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1169 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1170 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1171
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1172
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1173 virtual int64_t GetLastChangeIndex() ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1174 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1175 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1176 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_CHANGE_INDEX);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1177 return response.get_last_change_index().result();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1178 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1179
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1180
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1181 virtual bool LookupResourceAndParent(int64_t& id,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1182 ResourceType& type,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1183 std::string& parentPublicId,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1184 const std::string& publicId) ORTHANC_OVERRIDE
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1185 {
5211
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1186 DatabasePluginMessages::TransactionRequest request;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1187 request.mutable_lookup_resource_and_parent()->set_public_id(publicId);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1188
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1189 DatabasePluginMessages::TransactionResponse response;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1190 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCE_AND_PARENT, request);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1191
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1192 if (response.lookup_resource_and_parent().found())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1193 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1194 id = response.lookup_resource_and_parent().id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1195 type = Convert(response.lookup_resource_and_parent().type());
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1196
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1197 switch (type)
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1198 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1199 case ResourceType_Patient:
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1200 if (!response.lookup_resource_and_parent().parent_public_id().empty())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1201 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1202 throw OrthancException(ErrorCode_DatabasePlugin);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1203 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1204 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1205
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1206 case ResourceType_Study:
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1207 case ResourceType_Series:
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1208 case ResourceType_Instance:
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1209 if (response.lookup_resource_and_parent().parent_public_id().empty())
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1210 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1211 throw OrthancException(ErrorCode_DatabasePlugin);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1212 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1213 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1214 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1215 parentPublicId = response.lookup_resource_and_parent().parent_public_id();
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1216 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1217 break;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1218
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1219 default:
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1220 throw OrthancException(ErrorCode_ParameterOutOfRange);
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1221 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1222
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1223 return true;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1224 }
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1225 else
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1226 {
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1227 return false;
27e6ec2811e3 completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5210
diff changeset
1228 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1229 }
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1230
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1231
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1232 virtual void AddLabel(int64_t resource,
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1233 const std::string& label) ORTHANC_OVERRIDE
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1234 {
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1235 if (database_.GetDatabaseCapabilities().HasLabelsSupport())
5239
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1236 {
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1237 DatabasePluginMessages::TransactionRequest request;
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1238 request.mutable_add_label()->set_id(resource);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1239 request.mutable_add_label()->set_label(label);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1240
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1241 ExecuteTransaction(DatabasePluginMessages::OPERATION_ADD_LABEL, request);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1242 }
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1243 else
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1244 {
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1245 // This method shouldn't have been called
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1246 throw OrthancException(ErrorCode_InternalError);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1247 }
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1248 }
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1249
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1250
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1251 virtual void RemoveLabel(int64_t resource,
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1252 const std::string& label) ORTHANC_OVERRIDE
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1253 {
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1254 if (database_.GetDatabaseCapabilities().HasLabelsSupport())
5239
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1255 {
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1256 DatabasePluginMessages::TransactionRequest request;
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1257 request.mutable_remove_label()->set_id(resource);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1258 request.mutable_remove_label()->set_label(label);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1259
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1260 ExecuteTransaction(DatabasePluginMessages::OPERATION_REMOVE_LABEL, request);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1261 }
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1262 else
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1263 {
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1264 // This method shouldn't have been called
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1265 throw OrthancException(ErrorCode_InternalError);
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1266 }
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1267 }
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1268
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1269
5221
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
1270 virtual void ListLabels(std::set<std::string>& target,
d0f7c742d397 started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5220
diff changeset
1271 int64_t resource) ORTHANC_OVERRIDE
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1272 {
5249
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
1273 ListLabelsInternal(target, true, resource);
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
1274 }
5239
178b0434256a added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5221
diff changeset
1275
5249
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
1276
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
1277 virtual void ListAllLabels(std::set<std::string>& target) ORTHANC_OVERRIDE
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
1278 {
f22c8fac764b added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5248
diff changeset
1279 ListLabelsInternal(target, false, -1);
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1280 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1281 };
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1282
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1283
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1284 OrthancPluginDatabaseV4::OrthancPluginDatabaseV4(SharedLibrary& library,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1285 PluginsErrorDictionary& errorDictionary,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1286 const _OrthancPluginRegisterDatabaseBackendV4& database,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1287 const std::string& serverIdentifier) :
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1288 library_(library),
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1289 errorDictionary_(errorDictionary),
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1290 definition_(database),
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1291 serverIdentifier_(serverIdentifier),
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1292 open_(false),
5517
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1293 databaseVersion_(0)
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1294 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1295 CLOG(INFO, PLUGINS) << "Identifier of this Orthanc server for the global properties "
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1296 << "of the custom database: \"" << serverIdentifier << "\"";
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1297
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1298 if (definition_.backend == NULL ||
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1299 definition_.operations == NULL ||
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1300 definition_.finalize == NULL)
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1301 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1302 throw OrthancException(ErrorCode_NullPointer);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1303 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1304 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1305
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1306
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1307 OrthancPluginDatabaseV4::~OrthancPluginDatabaseV4()
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1308 {
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1309 definition_.finalize(definition_.backend);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1310 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1311
5254
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1312
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1313 static void AddIdentifierTags(DatabasePluginMessages::Open::Request& request,
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1314 ResourceType level)
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1315 {
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1316 const DicomTag* tags = NULL;
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1317 size_t size;
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1318
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1319 ServerToolbox::LoadIdentifiers(tags, size, level);
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1320
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1321 if (tags == NULL ||
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1322 size == 0)
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1323 {
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1324 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1325 }
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1326
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1327 for (size_t i = 0; i < size; i++)
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1328 {
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1329 DatabasePluginMessages::Open_Request_IdentifierTag* tag = request.add_identifier_tags();
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1330 tag->set_level(Convert(level));
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1331 tag->set_group(tags[i].GetGroup());
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1332 tag->set_element(tags[i].GetElement());
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1333 tag->set_name(FromDcmtkBridge::GetTagName(tags[i], ""));
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1334 }
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1335 }
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1336
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1337
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1338 void OrthancPluginDatabaseV4::Open()
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1339 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1340 if (open_)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1341 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1342 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1343 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1344
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1345 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1346 DatabasePluginMessages::DatabaseRequest request;
5254
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1347 AddIdentifierTags(*request.mutable_open(), ResourceType_Patient);
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1348 AddIdentifierTags(*request.mutable_open(), ResourceType_Study);
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1349 AddIdentifierTags(*request.mutable_open(), ResourceType_Series);
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1350 AddIdentifierTags(*request.mutable_open(), ResourceType_Instance);
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1351
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1352 DatabasePluginMessages::DatabaseResponse response;
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1353 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_OPEN, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1354 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1355
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1356 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1357 DatabasePluginMessages::DatabaseRequest request;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1358 DatabasePluginMessages::DatabaseResponse response;
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1359 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_GET_SYSTEM_INFORMATION, request);
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1360
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1361 const ::Orthanc::DatabasePluginMessages::GetSystemInformation_Response& systemInfo = response.get_system_information();
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1362 databaseVersion_ = systemInfo.database_version();
5517
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1363 dbCapabilities_.SetFlushToDisk(systemInfo.supports_flush_to_disk());
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1364 dbCapabilities_.SetRevisionsSupport(systemInfo.supports_revisions());
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1365 dbCapabilities_.SetLabelsSupport(systemInfo.supports_labels());
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1366 dbCapabilities_.SetAtomicIncrementGlobalProperty(systemInfo.supports_increment_global_property());
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1367 dbCapabilities_.SetUpdateAndGetStatistics(systemInfo.has_update_and_get_statistics());
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1368 dbCapabilities_.SetMeasureLatency(systemInfo.has_measure_latency());
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1369 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1370
5254
fafdb6179829 inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5249
diff changeset
1371 open_ = true;
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1372 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1373
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1374
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1375 void OrthancPluginDatabaseV4::Close()
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1376 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1377 if (!open_)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1378 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1379 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1380 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1381 else
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1382 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1383 DatabasePluginMessages::DatabaseRequest request;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1384 DatabasePluginMessages::DatabaseResponse response;
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1385 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_CLOSE, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1386 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1387 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1388
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1389
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1390
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1391 void OrthancPluginDatabaseV4::FlushToDisk()
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1392 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1393 if (!open_ ||
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1394 !GetDatabaseCapabilities().HasFlushToDisk())
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1395 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1396 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1397 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1398 else
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1399 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1400 DatabasePluginMessages::DatabaseRequest request;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1401 DatabasePluginMessages::DatabaseResponse response;
5209
154d37a56500 started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
1402 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_FLUSH_TO_DISK, request);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1403 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1404 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1405
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1406
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1407 IDatabaseWrapper::ITransaction* OrthancPluginDatabaseV4::StartTransaction(TransactionType type,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1408 IDatabaseListener& listener)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1409 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1410 if (!open_)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1411 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1412 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1413 }
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1414 else
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1415 {
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1416 return new Transaction(*this, listener, type);
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1417 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1418 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1419
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1420
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1421 unsigned int OrthancPluginDatabaseV4::GetDatabaseVersion()
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1422 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1423 if (!open_)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1424 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1425 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1426 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1427 else
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1428 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1429 return databaseVersion_;
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1430 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1431 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1432
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1433
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1434 void OrthancPluginDatabaseV4::Upgrade(unsigned int targetVersion,
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1435 IStorageArea& storageArea)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1436 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1437 if (!open_)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1438 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1439 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1440 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1441 else
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1442 {
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1443 VoidDatabaseListener listener;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1444 Transaction transaction(*this, listener, TransactionType_ReadWrite);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1445
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1446 try
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1447 {
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1448 DatabasePluginMessages::DatabaseRequest request;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1449 request.mutable_upgrade()->set_target_version(targetVersion);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1450 request.mutable_upgrade()->set_storage_area(reinterpret_cast<intptr_t>(&storageArea));
5215
8b6da4fdf9fe cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5214
diff changeset
1451 request.mutable_upgrade()->set_transaction(reinterpret_cast<intptr_t>(transaction.GetTransactionObject()));
5214
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1452
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1453 DatabasePluginMessages::DatabaseResponse response;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1454
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1455 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_UPGRADE, request);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1456 transaction.Commit(0);
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1457 }
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1458 catch (OrthancException& e)
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1459 {
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1460 transaction.Rollback();
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1461 throw;
a9d00b17a48e implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5213
diff changeset
1462 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1463 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1464 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1465
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1466
5493
b3ebe249ed5b At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents: 5466
diff changeset
1467 uint64_t OrthancPluginDatabaseV4::MeasureLatency()
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1468 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1469 if (!open_)
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1470 {
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1471 throw OrthancException(ErrorCode_BadSequenceOfCalls);
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1472 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1473 else
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1474 {
5520
d7c24c9c9448 removed useless try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5519
diff changeset
1475 DatabasePluginMessages::DatabaseRequest request;
d7c24c9c9448 removed useless try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5519
diff changeset
1476 DatabasePluginMessages::DatabaseResponse response;
5493
b3ebe249ed5b At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents: 5466
diff changeset
1477
5520
d7c24c9c9448 removed useless try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5519
diff changeset
1478 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_MEASURE_LATENCY, request);
d7c24c9c9448 removed useless try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5519
diff changeset
1479 return response.measure_latency().latency_us();
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1480 }
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1481 }
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1482
5517
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1483
0d433132b249 refactoring IDatabaseWrapper::Capabilities
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5497
diff changeset
1484 const IDatabaseWrapper::Capabilities OrthancPluginDatabaseV4::GetDatabaseCapabilities() const
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1485 {
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1486 if (!open_)
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1487 {
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1488 throw OrthancException(ErrorCode_BadSequenceOfCalls);
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1489 }
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1490 else
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1491 {
5455
176bc05f85f4 DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents: 5254
diff changeset
1492 return dbCapabilities_;
5220
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1493 }
df39c7583a49 preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5216
diff changeset
1494 }
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1495 }