Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5332:f5cb6310e0dc
fix handling of DICOM files without pixel data
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 27 Jun 2023 09:35:31 +0200 |
parents | fafdb6179829 |
children | 176bc05f85f4 48b8dae6dc77 |
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * 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
|
9 * 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
|
10 * 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
|
11 * License, or (at your option) any later version. |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * 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
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * General Public License for more details. |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * 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
|
19 * 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
|
20 **/ |
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 #include "../../Sources/PrecompiledHeadersServer.h" |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 #include "OrthancPluginDatabaseV4.h" |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 #if ORTHANC_ENABLE_PLUGINS != 1 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 # error The plugin support is disabled |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 #endif |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
30 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 #include "../../../OrthancFramework/Sources/Logging.h" |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #include "../../../OrthancFramework/Sources/OrthancException.h" |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
33 #include "../../Sources/Database/ResourcesContent.h" |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
34 #include "../../Sources/Database/VoidDatabaseListener.h" |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
35 #include "../../Sources/ServerToolbox.h" |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 #include "PluginsEnumerations.h" |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
38 #include "OrthancDatabasePlugin.pb.h" // Auto-generated file |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 #include <cassert> |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
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 namespace Orthanc |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
45 static void CheckSuccess(PluginsErrorDictionary& errorDictionary, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
46 OrthancPluginErrorCode code) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
47 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
48 if (code != OrthancPluginErrorCode_Success) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
49 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
50 errorDictionary.LogError(code, true); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
51 throw OrthancException(static_cast<ErrorCode>(code)); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
52 } |
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 static ResourceType Convert(DatabasePluginMessages::ResourceType type) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
57 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
58 switch (type) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
59 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
60 case DatabasePluginMessages::RESOURCE_PATIENT: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
61 return ResourceType_Patient; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
62 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
63 case DatabasePluginMessages::RESOURCE_STUDY: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
64 return ResourceType_Study; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
65 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
66 case DatabasePluginMessages::RESOURCE_SERIES: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
67 return ResourceType_Series; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
68 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
69 case DatabasePluginMessages::RESOURCE_INSTANCE: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
70 return ResourceType_Instance; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
71 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
72 default: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
73 throw OrthancException(ErrorCode_ParameterOutOfRange); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
74 } |
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 static DatabasePluginMessages::ResourceType Convert(ResourceType type) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
79 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
80 switch (type) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
81 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
82 case ResourceType_Patient: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
83 return DatabasePluginMessages::RESOURCE_PATIENT; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
84 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
85 case ResourceType_Study: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
86 return DatabasePluginMessages::RESOURCE_STUDY; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
87 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
88 case ResourceType_Series: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
89 return DatabasePluginMessages::RESOURCE_SERIES; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
90 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
91 case ResourceType_Instance: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
92 return DatabasePluginMessages::RESOURCE_INSTANCE; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
93 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
94 default: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
95 throw OrthancException(ErrorCode_ParameterOutOfRange); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
96 } |
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 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
100 static FileInfo Convert(const DatabasePluginMessages::FileInfo& source) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
101 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
102 return FileInfo(source.uuid(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
103 static_cast<FileContentType>(source.content_type()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
104 source.uncompressed_size(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
105 source.uncompressed_hash(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
106 static_cast<CompressionType>(source.compression_type()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
107 source.compressed_size(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
108 source.compressed_hash()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
109 } |
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 static ServerIndexChange Convert(const DatabasePluginMessages::ServerIndexChange& source) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
113 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
114 return ServerIndexChange(source.seq(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
115 static_cast<ChangeType>(source.change_type()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
116 Convert(source.resource_type()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
117 source.public_id(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
118 source.date()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
119 } |
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 static ExportedResource Convert(const DatabasePluginMessages::ExportedResource& source) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
123 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
124 return ExportedResource(source.seq(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
125 Convert(source.resource_type()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
126 source.public_id(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
127 source.modality(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
128 source.date(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
129 source.patient_id(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
130 source.study_instance_uid(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
131 source.series_instance_uid(), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
132 source.sop_instance_uid()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
133 } |
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 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
136 static void Execute(DatabasePluginMessages::Response& response, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
137 const OrthancPluginDatabaseV4& database, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
138 const DatabasePluginMessages::Request& request) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
139 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
140 std::string requestSerialized; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
141 request.SerializeToString(&requestSerialized); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
142 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
143 OrthancPluginMemoryBuffer64 responseSerialized; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
144 CheckSuccess(database.GetErrorDictionary(), database.GetDefinition().operations( |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
145 &responseSerialized, database.GetDefinition().backend, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
146 requestSerialized.empty() ? NULL : requestSerialized.c_str(), |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
147 requestSerialized.size())); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
148 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
149 bool success = response.ParseFromArray(responseSerialized.data, responseSerialized.size); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
150 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
151 if (responseSerialized.size > 0) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
152 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
153 free(responseSerialized.data); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
154 } |
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 if (!success) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
157 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
158 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
|
159 } |
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 static void ExecuteDatabase(DatabasePluginMessages::DatabaseResponse& response, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
164 const OrthancPluginDatabaseV4& database, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
165 DatabasePluginMessages::DatabaseOperation operation, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
166 const DatabasePluginMessages::DatabaseRequest& request) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
167 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
168 DatabasePluginMessages::Request fullRequest; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
169 fullRequest.set_type(DatabasePluginMessages::REQUEST_DATABASE); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
170 fullRequest.mutable_database_request()->CopyFrom(request); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
171 fullRequest.mutable_database_request()->set_operation(operation); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
172 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
173 DatabasePluginMessages::Response fullResponse; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
174 Execute(fullResponse, database, fullRequest); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
175 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
176 response.CopyFrom(fullResponse.database_response()); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
177 } |
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 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 class OrthancPluginDatabaseV4::Transaction : public IDatabaseWrapper::ITransaction |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 private: |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
183 OrthancPluginDatabaseV4& database_; |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 IDatabaseListener& listener_; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 void* transaction_; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
186 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
187 void ExecuteTransaction(DatabasePluginMessages::TransactionResponse& response, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
188 DatabasePluginMessages::TransactionOperation operation, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
189 const DatabasePluginMessages::TransactionRequest& request) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
190 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
191 DatabasePluginMessages::Request fullRequest; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
192 fullRequest.set_type(DatabasePluginMessages::REQUEST_TRANSACTION); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
193 fullRequest.mutable_transaction_request()->CopyFrom(request); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
194 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
|
195 fullRequest.mutable_transaction_request()->set_operation(operation); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
197 DatabasePluginMessages::Response fullResponse; |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
198 Execute(fullResponse, database_, fullRequest); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
199 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
200 response.CopyFrom(fullResponse.transaction_response()); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
201 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
202 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
203 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
204 void ExecuteTransaction(DatabasePluginMessages::TransactionResponse& response, |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
205 DatabasePluginMessages::TransactionOperation operation) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
206 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
207 DatabasePluginMessages::TransactionRequest request; // Ignored |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
208 ExecuteTransaction(response, operation, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
209 } |
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 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
212 void ExecuteTransaction(DatabasePluginMessages::TransactionOperation operation, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
213 const DatabasePluginMessages::TransactionRequest& request) |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
214 { |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
215 DatabasePluginMessages::TransactionResponse response; // Ignored |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
216 ExecuteTransaction(response, operation, request); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
217 } |
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 void ExecuteTransaction(DatabasePluginMessages::TransactionOperation operation) |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
221 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
222 DatabasePluginMessages::TransactionResponse response; // Ignored |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
223 DatabasePluginMessages::TransactionRequest request; // Ignored |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
224 ExecuteTransaction(response, operation, request); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
225 } |
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 |
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
|
228 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
|
229 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
|
230 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
|
231 { |
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 if (database_.HasLabelsSupport()) |
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
|
233 { |
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 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
|
235 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
|
236 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
|
237 |
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 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
|
239 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
|
240 |
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 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
|
242 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
|
243 { |
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 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
|
245 } |
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 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
|
248 { |
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 // 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
|
250 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
|
251 } |
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 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
255 public: |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
256 Transaction(OrthancPluginDatabaseV4& database, |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
257 IDatabaseListener& listener, |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
258 TransactionType type) : |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
259 database_(database), |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
260 listener_(listener), |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
261 transaction_(NULL) |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
262 { |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
263 DatabasePluginMessages::DatabaseRequest request; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
264 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
265 switch (type) |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
266 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
267 case TransactionType_ReadOnly: |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
268 request.mutable_start_transaction()->set_type(DatabasePluginMessages::TRANSACTION_READ_ONLY); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
269 break; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
270 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
271 case TransactionType_ReadWrite: |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
272 request.mutable_start_transaction()->set_type(DatabasePluginMessages::TRANSACTION_READ_WRITE); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
273 break; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
274 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
275 default: |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
276 throw OrthancException(ErrorCode_ParameterOutOfRange); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
277 } |
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 DatabasePluginMessages::DatabaseResponse response; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
280 ExecuteDatabase(response, database, DatabasePluginMessages::OPERATION_START_TRANSACTION, request); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
281 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
282 transaction_ = reinterpret_cast<void*>(response.start_transaction().transaction()); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
283 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
284 if (transaction_ == NULL) |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
285 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
286 throw OrthancException(ErrorCode_NullPointer); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
287 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 } |
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 virtual ~Transaction() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 { |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
293 try |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
294 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
295 DatabasePluginMessages::DatabaseRequest request; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
296 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
|
297 |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
298 DatabasePluginMessages::DatabaseResponse response; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
299 ExecuteDatabase(response, database_, DatabasePluginMessages::OPERATION_FINALIZE_TRANSACTION, request); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
300 } |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
301 catch (OrthancException& e) |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
302 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
303 // Destructors must not throw exceptions |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
304 LOG(ERROR) << "Cannot finalize the database engine: " << e.What(); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
305 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 } |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
307 |
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
775 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
776 virtual bool LookupMetadata(std::string& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 int64_t& revision, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 MetadataType type) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
781 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
782 request.mutable_lookup_metadata()->set_id(id); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
783 request.mutable_lookup_metadata()->set_metadata_type(type); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
784 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
785 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
786 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_METADATA, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
787 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
788 if (response.lookup_metadata().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
789 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
790 target = response.lookup_metadata().value(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
791 revision = response.lookup_metadata().revision(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
792 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
793 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
794 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
795 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
796 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
797 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 virtual bool LookupParent(int64_t& parentId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 int64_t resourceId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
804 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
805 request.mutable_lookup_parent()->set_id(resourceId); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
806 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
807 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
808 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_PARENT, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
809 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
810 if (response.lookup_parent().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
811 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
812 parentId = response.lookup_parent().parent(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
813 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
814 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
815 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
816 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
817 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
818 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 virtual bool LookupResource(int64_t& id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 ResourceType& type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 const std::string& publicId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
826 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
827 request.mutable_lookup_resource()->set_public_id(publicId); |
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 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
830 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCE, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
831 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
832 if (response.lookup_resource().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
833 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
834 id = response.lookup_resource().internal_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
835 type = Convert(response.lookup_resource().type()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
836 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
837 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
838 else |
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 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
841 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 virtual bool SelectPatientToRecycle(int64_t& internalId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
846 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
847 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
848 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_SELECT_PATIENT_TO_RECYCLE); |
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 if (response.select_patient_to_recycle().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
851 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
852 internalId = response.select_patient_to_recycle().patient_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
853 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
854 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
855 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
856 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
857 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
858 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 virtual bool SelectPatientToRecycle(int64_t& internalId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 int64_t patientIdToAvoid) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
865 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
866 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
|
867 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
868 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
869 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
|
870 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
871 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
|
872 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
873 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
|
874 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
875 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
876 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
877 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
878 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
879 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
880 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
881 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 virtual void SetGlobalProperty(GlobalProperty property, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 bool shared, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 const std::string& value) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
887 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
888 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
|
889 request.mutable_set_global_property()->set_property(property); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
890 request.mutable_set_global_property()->set_value(value); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
891 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
892 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_GLOBAL_PROPERTY, request); |
5207
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 virtual void ClearMainDicomTags(int64_t id) 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_clear_main_dicom_tags()->set_id(id); |
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 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_MAIN_DICOM_TAGS, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 virtual void SetMetadata(int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 MetadataType type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 const std::string& value, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
908 int64_t revision) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
910 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
911 request.mutable_set_metadata()->set_id(id); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
912 request.mutable_set_metadata()->set_metadata_type(type); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
913 request.mutable_set_metadata()->set_value(value); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
914 request.mutable_set_metadata()->set_revision(revision); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
915 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
916 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_METADATA, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 virtual void SetProtectedPatient(int64_t internalId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 bool isProtected) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
923 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
924 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
|
925 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
|
926 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
927 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_PROTECTED_PATIENT, request); |
5207
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
930 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
931 virtual bool IsDiskSizeAbove(uint64_t threshold) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
933 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
934 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
|
935 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
936 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
937 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
|
938 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
939 return response.is_disk_size_above().result(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
940 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
941 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
942 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
943 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
944 std::list<std::string>* instancesId, // Can be NULL if not needed |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 const std::vector<DatabaseConstraint>& lookup, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 ResourceType queryLevel, |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
947 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
|
948 LabelsConstraint labelsConstraint, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5211
diff
changeset
|
949 uint32_t limit) ORTHANC_OVERRIDE |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
950 { |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
951 if (!database_.HasLabelsSupport() && |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
952 !labels.empty()) |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
953 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
954 throw OrthancException(ErrorCode_InternalError); |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
955 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
956 |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
957 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
958 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
|
959 request.mutable_lookup_resources()->set_limit(limit); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
960 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
|
961 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
962 request.mutable_lookup_resources()->mutable_lookup()->Reserve(lookup.size()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
963 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
964 for (size_t i = 0; i < lookup.size(); i++) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
965 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
966 DatabasePluginMessages::DatabaseConstraint* constraint = request.mutable_lookup_resources()->add_lookup(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
967 constraint->set_level(Convert(lookup[i].GetLevel())); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
968 constraint->set_tag_group(lookup[i].GetTag().GetGroup()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
969 constraint->set_tag_element(lookup[i].GetTag().GetElement()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
970 constraint->set_is_identifier_tag(lookup[i].IsIdentifier()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
971 constraint->set_is_case_sensitive(lookup[i].IsCaseSensitive()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
972 constraint->set_is_mandatory(lookup[i].IsMandatory()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
973 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
974 constraint->mutable_values()->Reserve(lookup[i].GetValuesCount()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
975 for (size_t j = 0; j < lookup[i].GetValuesCount(); j++) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
976 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
977 constraint->add_values(lookup[i].GetValue(j)); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
978 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
979 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
980 switch (lookup[i].GetConstraintType()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
981 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
982 case ConstraintType_Equal: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
983 constraint->set_type(DatabasePluginMessages::CONSTRAINT_EQUAL); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
984 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
985 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
986 case ConstraintType_SmallerOrEqual: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
987 constraint->set_type(DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
988 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
989 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
990 case ConstraintType_GreaterOrEqual: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
991 constraint->set_type(DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
992 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
993 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
994 case ConstraintType_Wildcard: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
995 constraint->set_type(DatabasePluginMessages::CONSTRAINT_WILDCARD); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
996 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
997 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
998 case ConstraintType_List: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
999 constraint->set_type(DatabasePluginMessages::CONSTRAINT_LIST); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1000 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1001 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1002 default: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1003 throw OrthancException(ErrorCode_ParameterOutOfRange); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1004 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1005 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1006 |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1007 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
|
1008 { |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1009 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
|
1010 } |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1011 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1012 switch (labelsConstraint) |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1013 { |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1014 case LabelsConstraint_All: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1015 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
|
1016 break; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1017 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1018 case LabelsConstraint_Any: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1019 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
|
1020 break; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1021 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1022 case LabelsConstraint_None: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1023 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
|
1024 break; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1025 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1026 default: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1027 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1028 } |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1029 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1030 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1031 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request); |
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 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
|
1034 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1035 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
|
1036 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1037 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1038 if (instancesId != NULL) |
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 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
|
1041 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1042 throw OrthancException(ErrorCode_DatabasePlugin); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1043 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1044 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1045 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1046 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
|
1047 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1048 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
|
1049 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1050 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1051 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1052 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1053 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1054 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1055 virtual bool CreateInstance(CreateInstanceResult& result, /* out */ |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1056 int64_t& instanceId, /* out */ |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1057 const std::string& patient, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1058 const std::string& study, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1059 const std::string& series, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1060 const std::string& instance) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1061 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1062 // TODO: "CreateInstanceResult" => constructor and getters |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1063 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1064 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1065 request.mutable_create_instance()->set_patient(patient); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1066 request.mutable_create_instance()->set_study(study); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1067 request.mutable_create_instance()->set_series(series); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1068 request.mutable_create_instance()->set_instance(instance); |
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 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1071 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_CREATE_INSTANCE, request); |
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 instanceId = response.create_instance().instance_id(); |
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.create_instance().is_new_instance()) |
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 result.isNewPatient_ = response.create_instance().is_new_patient(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1078 result.isNewStudy_ = response.create_instance().is_new_study(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1079 result.isNewSeries_ = response.create_instance().is_new_series(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1080 result.patientId_ = response.create_instance().patient_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1081 result.studyId_ = response.create_instance().study_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1082 result.seriesId_ = response.create_instance().series_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1083 return true; |
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 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1086 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1087 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1088 } |
5207
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1091 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1092 virtual void SetResourcesContent(const ResourcesContent& content) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1093 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1094 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1095 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1096 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
|
1097 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
|
1098 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1099 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
|
1100 tag->set_resource_id(it->GetResourceId()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1101 tag->set_is_identifier(it->IsIdentifier()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1102 tag->set_group(it->GetTag().GetGroup()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1103 tag->set_element(it->GetTag().GetElement()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1104 tag->set_value(it->GetValue()); |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1105 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1106 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1107 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
|
1108 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
|
1109 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1110 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
|
1111 metadata->set_resource_id(it->GetResourceId()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1112 metadata->set_metadata(it->GetType()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1113 metadata->set_value(it->GetValue()); |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1114 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1115 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1116 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_RESOURCES_CONTENT, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1117 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1118 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1119 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1120 virtual void GetChildrenMetadata(std::list<std::string>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1121 int64_t resourceId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1122 MetadataType metadata) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1123 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1124 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1125 request.mutable_get_children_metadata()->set_id(resourceId); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1126 request.mutable_get_children_metadata()->set_metadata(metadata); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1127 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1128 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1129 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_METADATA, 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 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
|
1132 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1133 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
|
1134 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1135 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1136 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1137 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1138 virtual int64_t GetLastChangeIndex() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1139 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1140 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1141 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_CHANGE_INDEX); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1142 return response.get_last_change_index().result(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1143 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1144 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1145 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1146 virtual bool LookupResourceAndParent(int64_t& id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1147 ResourceType& type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1148 std::string& parentPublicId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1149 const std::string& publicId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1150 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1151 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1152 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
|
1153 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1154 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1155 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
|
1156 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1157 if (response.lookup_resource_and_parent().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1158 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1159 id = response.lookup_resource_and_parent().id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1160 type = Convert(response.lookup_resource_and_parent().type()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1161 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1162 switch (type) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1163 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1164 case ResourceType_Patient: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1165 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
|
1166 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1167 throw OrthancException(ErrorCode_DatabasePlugin); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1168 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1169 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1170 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1171 case ResourceType_Study: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1172 case ResourceType_Series: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1173 case ResourceType_Instance: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1174 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
|
1175 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1176 throw OrthancException(ErrorCode_DatabasePlugin); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1177 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1178 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1179 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1180 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
|
1181 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1182 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1183 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1184 default: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1185 throw OrthancException(ErrorCode_ParameterOutOfRange); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1186 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1187 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1188 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1189 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1190 else |
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 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1193 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1194 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1195 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1196 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1197 virtual void AddLabel(int64_t resource, |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1198 const std::string& label) ORTHANC_OVERRIDE |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1199 { |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1200 if (database_.HasLabelsSupport()) |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1201 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1202 DatabasePluginMessages::TransactionRequest request; |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1203 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
|
1204 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
|
1205 |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1206 ExecuteTransaction(DatabasePluginMessages::OPERATION_ADD_LABEL, request); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1207 } |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1208 else |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1209 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1210 // 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
|
1211 throw OrthancException(ErrorCode_InternalError); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1212 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1213 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1214 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1215 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1216 virtual void RemoveLabel(int64_t resource, |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1217 const std::string& label) ORTHANC_OVERRIDE |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1218 { |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1219 if (database_.HasLabelsSupport()) |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1220 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1221 DatabasePluginMessages::TransactionRequest request; |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1222 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
|
1223 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
|
1224 |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1225 ExecuteTransaction(DatabasePluginMessages::OPERATION_REMOVE_LABEL, request); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1226 } |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1227 else |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1228 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1229 // 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
|
1230 throw OrthancException(ErrorCode_InternalError); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1231 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1232 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1233 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1234 |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1235 virtual void ListLabels(std::set<std::string>& target, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1236 int64_t resource) ORTHANC_OVERRIDE |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1237 { |
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
|
1238 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
|
1239 } |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1240 |
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
|
1241 |
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
|
1242 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
|
1243 { |
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
|
1244 ListLabelsInternal(target, false, -1); |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1245 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1246 }; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1247 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1248 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1249 OrthancPluginDatabaseV4::OrthancPluginDatabaseV4(SharedLibrary& library, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1250 PluginsErrorDictionary& errorDictionary, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1251 const _OrthancPluginRegisterDatabaseBackendV4& database, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1252 const std::string& serverIdentifier) : |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1253 library_(library), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1254 errorDictionary_(errorDictionary), |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1255 definition_(database), |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1256 serverIdentifier_(serverIdentifier), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1257 open_(false), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1258 databaseVersion_(0), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1259 hasFlushToDisk_(false), |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1260 hasRevisionsSupport_(false), |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1261 hasLabelsSupport_(false) |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1262 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1263 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
|
1264 << "of the custom database: \"" << serverIdentifier << "\""; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1265 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1266 if (definition_.backend == NULL || |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1267 definition_.operations == NULL || |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1268 definition_.finalize == NULL) |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1269 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1270 throw OrthancException(ErrorCode_NullPointer); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1271 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1272 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1273 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1274 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1275 OrthancPluginDatabaseV4::~OrthancPluginDatabaseV4() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1276 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1277 definition_.finalize(definition_.backend); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1278 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1279 |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1280 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1281 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
|
1282 ResourceType level) |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1283 { |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1284 const DicomTag* tags = NULL; |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1285 size_t size; |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1286 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1287 ServerToolbox::LoadIdentifiers(tags, size, level); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1288 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1289 if (tags == NULL || |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1290 size == 0) |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1291 { |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1292 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1293 } |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1294 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1295 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
|
1296 { |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1297 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
|
1298 tag->set_level(Convert(level)); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1299 tag->set_group(tags[i].GetGroup()); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1300 tag->set_element(tags[i].GetElement()); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1301 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
|
1302 } |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1303 } |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1304 |
5207
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 void OrthancPluginDatabaseV4::Open() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1307 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1308 if (open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1309 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1310 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1312 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1313 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1314 DatabasePluginMessages::DatabaseRequest request; |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1315 AddIdentifierTags(*request.mutable_open(), ResourceType_Patient); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1316 AddIdentifierTags(*request.mutable_open(), ResourceType_Study); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1317 AddIdentifierTags(*request.mutable_open(), ResourceType_Series); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1318 AddIdentifierTags(*request.mutable_open(), ResourceType_Instance); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1319 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1320 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1321 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_OPEN, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1322 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1323 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1324 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1325 DatabasePluginMessages::DatabaseRequest request; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1326 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1327 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_GET_SYSTEM_INFORMATION, request); |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1328 databaseVersion_ = response.get_system_information().database_version(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1329 hasFlushToDisk_ = response.get_system_information().supports_flush_to_disk(); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1330 hasRevisionsSupport_ = response.get_system_information().supports_revisions(); |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1331 hasLabelsSupport_ = response.get_system_information().supports_labels(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1332 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1333 |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1334 open_ = true; |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1335 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1336 |
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::Close() |
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 else |
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; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1347 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1348 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_CLOSE, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1349 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1350 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1351 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1352 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1353 bool OrthancPluginDatabaseV4::HasFlushToDisk() const |
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 if (!open_) |
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1358 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1359 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1360 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1361 return hasFlushToDisk_; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1362 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1363 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1364 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1365 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1366 void OrthancPluginDatabaseV4::FlushToDisk() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1367 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1368 if (!open_ || |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1369 !hasFlushToDisk_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1370 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1371 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 else |
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 DatabasePluginMessages::DatabaseRequest request; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1376 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1377 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_FLUSH_TO_DISK, request); |
5207
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 } |
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1382 IDatabaseWrapper::ITransaction* OrthancPluginDatabaseV4::StartTransaction(TransactionType type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1383 IDatabaseListener& listener) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1384 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1385 if (!open_) |
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1388 } |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1389 else |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1390 { |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1391 return new Transaction(*this, listener, type); |
5207
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 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1394 |
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 unsigned int OrthancPluginDatabaseV4::GetDatabaseVersion() |
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 if (!open_) |
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1401 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1402 else |
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 return databaseVersion_; |
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1408 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1409 void OrthancPluginDatabaseV4::Upgrade(unsigned int targetVersion, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1410 IStorageArea& storageArea) |
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 if (!open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1413 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1414 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1415 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1416 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1417 { |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1418 VoidDatabaseListener listener; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1419 Transaction transaction(*this, listener, TransactionType_ReadWrite); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1420 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1421 try |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1422 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1423 DatabasePluginMessages::DatabaseRequest request; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1424 request.mutable_upgrade()->set_target_version(targetVersion); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1425 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
|
1426 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
|
1427 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1428 DatabasePluginMessages::DatabaseResponse response; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1429 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1430 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_UPGRADE, request); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1431 transaction.Commit(0); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1432 } |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1433 catch (OrthancException& e) |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1434 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1435 transaction.Rollback(); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1436 throw; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1437 } |
5207
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 } |
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1442 bool OrthancPluginDatabaseV4::HasRevisionsSupport() const |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1443 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1444 if (!open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1445 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1446 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1447 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1448 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1449 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1450 return hasRevisionsSupport_; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1451 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1452 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1453 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1454 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1455 bool OrthancPluginDatabaseV4::HasLabelsSupport() const |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1456 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1457 if (!open_) |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1458 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1459 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1460 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1461 else |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1462 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1463 return hasLabelsSupport_; |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1464 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1465 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1466 } |