Mercurial > hg > orthanc
annotate OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5497:4dd50c4b985a pg-transactions
merge default -> pg-transactions
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 23 Jan 2024 17:05:28 +0100 |
parents | b3ebe249ed5b 48b8dae6dc77 |
children | 0d433132b249 |
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 |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5254
diff
changeset
|
5 * Copyright (C) 2017-2024 Osimis S.A., Belgium |
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5254
diff
changeset
|
6 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
5207
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 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
232 if (database_.GetDatabaseCapabilities().HasLabelsSupport()) |
5249
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
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 |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
308 virtual const IDatabaseWrapper::Capabilities& GetDatabaseCapabilities() const ORTHANC_OVERRIDE |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
309 { |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
310 return database_.GetDatabaseCapabilities(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
311 } |
5215
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
312 |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
313 void* GetTransactionObject() |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
314 { |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
315 return transaction_; |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
316 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 |
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 virtual void Rollback() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
320 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
321 ExecuteTransaction(DatabasePluginMessages::OPERATION_ROLLBACK); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
322 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 virtual void Commit(int64_t fileSizeDelta) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
327 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
328 request.mutable_commit()->set_file_size_delta(fileSizeDelta); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
329 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
330 ExecuteTransaction(DatabasePluginMessages::OPERATION_COMMIT, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
332 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 virtual void AddAttachment(int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
335 const FileInfo& attachment, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 int64_t revision) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
338 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
339 request.mutable_add_attachment()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
340 request.mutable_add_attachment()->mutable_attachment()->set_uuid(attachment.GetUuid()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 request.mutable_add_attachment()->set_revision(revision); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
348 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
349 ExecuteTransaction(DatabasePluginMessages::OPERATION_ADD_ATTACHMENT, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 |
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 virtual void ClearChanges() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
355 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_CHANGES); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 |
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 virtual void ClearExportedResources() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
361 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_EXPORTED_RESOURCES); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
364 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 virtual void DeleteAttachment(int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 FileContentType attachment) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
368 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
369 request.mutable_delete_attachment()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
370 request.mutable_delete_attachment()->set_type(attachment); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
371 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
372 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
373 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_DELETE_ATTACHMENT, request); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
374 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
375 listener_.SignalAttachmentDeleted(Convert(response.delete_attachment().deleted_attachment())); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 virtual void DeleteMetadata(int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 MetadataType type) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
382 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
383 request.mutable_delete_metadata()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
384 request.mutable_delete_metadata()->set_type(type); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
385 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
386 ExecuteTransaction(DatabasePluginMessages::OPERATION_DELETE_METADATA, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
388 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 virtual void DeleteResource(int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
392 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
393 request.mutable_delete_resource()->set_id(id); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
394 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
395 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
396 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_DELETE_RESOURCE, request); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
397 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
398 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
|
399 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
400 listener_.SignalAttachmentDeleted(Convert(response.delete_resource().deleted_attachments(i))); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
401 } |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
402 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
403 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
|
404 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
405 listener_.SignalResourceDeleted(Convert(response.delete_resource().deleted_resources(i).level()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
406 response.delete_resource().deleted_resources(i).public_id()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
407 } |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
408 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
409 if (response.delete_resource().is_remaining_ancestor()) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
410 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
411 listener_.SignalRemainingAncestor(Convert(response.delete_resource().remaining_ancestor().level()), |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
412 response.delete_resource().remaining_ancestor().public_id()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
413 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 virtual void GetAllMetadata(std::map<MetadataType, std::string>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
420 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
421 request.mutable_get_all_metadata()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
422 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
423 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
424 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_ALL_METADATA, request); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
425 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
426 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
427 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
|
428 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
429 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
|
430 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
431 if (target.find(key) == target.end()) |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
432 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
433 target[key] = response.get_all_metadata().metadata(i).value(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
434 } |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
435 else |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
436 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
437 throw OrthancException(ErrorCode_DatabasePlugin); |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
438 } |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
439 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
443 virtual void GetAllPublicIds(std::list<std::string>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 ResourceType resourceType) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
446 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
447 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
|
448 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
449 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
450 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
|
451 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
452 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
453 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
|
454 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
455 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
|
456 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 virtual void GetAllPublicIds(std::list<std::string>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 ResourceType resourceType, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5211
diff
changeset
|
462 int64_t since, |
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5211
diff
changeset
|
463 uint32_t limit) ORTHANC_OVERRIDE |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
465 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
466 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
|
467 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
|
468 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
|
469 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
470 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
471 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
|
472 |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
473 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
474 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
|
475 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
476 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
|
477 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
478 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 virtual void GetChanges(std::list<ServerIndexChange>& target /*out*/, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 bool& done /*out*/, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 int64_t since, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5211
diff
changeset
|
484 uint32_t limit) ORTHANC_OVERRIDE |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
486 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
487 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
|
488 request.mutable_get_changes()->set_limit(limit); |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
489 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
490 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
491 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHANGES, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
492 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
493 done = response.get_changes().done(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
494 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
495 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
496 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
|
497 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
498 target.push_back(Convert(response.get_changes().changes(i))); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
499 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
501 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
503 virtual void GetChildrenInternalId(std::list<int64_t>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
506 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
507 request.mutable_get_children_internal_id()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
508 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
509 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
510 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_INTERNAL_ID, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
511 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
512 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
513 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
|
514 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
515 target.push_back(response.get_children_internal_id().ids(i)); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
516 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 virtual void GetChildrenPublicId(std::list<std::string>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
523 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
524 request.mutable_get_children_public_id()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
525 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
526 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
527 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_PUBLIC_ID, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
528 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
529 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
530 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
|
531 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
532 target.push_back(response.get_children_public_id().ids(i)); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
533 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 virtual void GetExportedResources(std::list<ExportedResource>& target /*out*/, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 bool& done /*out*/, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 int64_t since, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5211
diff
changeset
|
540 uint32_t limit) ORTHANC_OVERRIDE |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
542 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
543 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
|
544 request.mutable_get_exported_resources()->set_limit(limit); |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
545 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
546 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
547 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_EXPORTED_RESOURCES, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
548 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
549 done = response.get_exported_resources().done(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
550 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
551 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
552 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
|
553 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
554 target.push_back(Convert(response.get_exported_resources().resources(i))); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
555 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
558 |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
559 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
|
560 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
561 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
562 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_CHANGE); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
563 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
564 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
565 if (response.get_last_change().found()) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
566 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
567 target.push_back(Convert(response.get_last_change().change())); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
568 } |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
569 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
571 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 virtual void GetLastExportedResource(std::list<ExportedResource>& target /*out*/) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
574 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
575 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_EXPORTED_RESOURCE); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
576 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
577 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
578 if (response.get_last_exported_resource().found()) |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
579 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
580 target.push_back(Convert(response.get_last_exported_resource().resource())); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
581 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 virtual void GetMainDicomTags(DicomMap& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
588 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
589 request.mutable_get_main_dicom_tags()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
590 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
591 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
592 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_MAIN_DICOM_TAGS, request); |
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 target.Clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
595 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
596 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
|
597 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
598 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
|
599 if (tag.group() > 0xffffu || |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
600 tag.element() > 0xffffu) |
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 throw OrthancException(ErrorCode_ParameterOutOfRange); |
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 else |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
605 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
606 target.SetValue(tag.group(), tag.element(), tag.value(), false); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
607 } |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
608 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 virtual std::string GetPublicId(int64_t resourceId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
614 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
615 request.mutable_get_public_id()->set_id(resourceId); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
616 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
617 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
618 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_PUBLIC_ID, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
619 return response.get_public_id().id(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 virtual uint64_t GetResourcesCount(ResourceType resourceType) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
625 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
626 request.mutable_get_resources_count()->set_type(Convert(resourceType)); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
627 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
628 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
629 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_RESOURCES_COUNT, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
630 return response.get_resources_count().count(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 virtual ResourceType GetResourceType(int64_t resourceId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
636 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
637 request.mutable_get_resource_type()->set_id(resourceId); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
638 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
639 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
640 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_RESOURCE_TYPE, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
641 return Convert(response.get_resource_type().type()); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 virtual uint64_t GetTotalCompressedSize() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
647 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
648 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_TOTAL_COMPRESSED_SIZE); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
649 return response.get_total_compressed_size().size(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 virtual uint64_t GetTotalUncompressedSize() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
655 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
656 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_TOTAL_UNCOMPRESSED_SIZE); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
657 return response.get_total_uncompressed_size().size(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 virtual bool IsProtectedPatient(int64_t internalId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
663 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
664 request.mutable_is_protected_patient()->set_patient_id(internalId); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
665 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
666 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
667 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_IS_PROTECTED_PATIENT, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
668 return response.is_protected_patient().protected_patient(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
672 virtual void ListAvailableAttachments(std::set<FileContentType>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
673 int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
675 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
676 request.mutable_list_available_attachments()->set_id(id); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
677 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
678 DatabasePluginMessages::TransactionResponse response; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
679 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LIST_AVAILABLE_ATTACHMENTS, request); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
680 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
681 target.clear(); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
682 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
|
683 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
684 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
|
685 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
686 if (target.find(attachment) == target.end()) |
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 target.insert(attachment); |
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 else |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
691 { |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
692 throw OrthancException(ErrorCode_DatabasePlugin); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
693 } |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
694 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
698 virtual void LogChange(ChangeType changeType, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
699 ResourceType resourceType, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
700 int64_t internalId, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
701 const std::string& /* publicId - unused */, |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
702 const std::string& date) ORTHANC_OVERRIDE |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
704 DatabasePluginMessages::TransactionRequest request; |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
705 request.mutable_log_change()->set_change_type(changeType); |
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
706 request.mutable_log_change()->set_resource_type(Convert(resourceType)); |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
707 request.mutable_log_change()->set_resource_id(internalId); |
5216
450ac804d3af
simplifying IDatabaseWrapper::LogChange()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5215
diff
changeset
|
708 request.mutable_log_change()->set_date(date); |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
709 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
710 ExecuteTransaction(DatabasePluginMessages::OPERATION_LOG_CHANGE, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
711 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 virtual void LogExportedResource(const ExportedResource& resource) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 { |
5210
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
716 // TODO: "seq" is ignored, could be simplified in "ExportedResource" |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
717 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
718 DatabasePluginMessages::TransactionRequest request; |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
719 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
|
720 request.mutable_log_exported_resource()->set_public_id(resource.GetPublicId()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
721 request.mutable_log_exported_resource()->set_modality(resource.GetModality()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
722 request.mutable_log_exported_resource()->set_date(resource.GetDate()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
723 request.mutable_log_exported_resource()->set_patient_id(resource.GetPatientId()); |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
724 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
|
725 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
|
726 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
|
727 |
6a7a244c777d
cont OrthancPluginDatabaseV4::Transaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5209
diff
changeset
|
728 ExecuteTransaction(DatabasePluginMessages::OPERATION_LOG_EXPORTED_RESOURCE, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
730 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 virtual bool LookupAttachment(FileInfo& attachment, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 int64_t& revision, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 FileContentType contentType) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
737 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
738 request.mutable_lookup_attachment()->set_id(id); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
739 request.mutable_lookup_attachment()->set_content_type(contentType); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
740 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
741 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
742 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_ATTACHMENT, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
743 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
744 if (response.lookup_attachment().found()) |
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 attachment = Convert(response.lookup_attachment().attachment()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
747 revision = response.lookup_attachment().revision(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
748 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
749 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
750 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
751 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
752 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
753 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
755 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
756 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
757 virtual bool LookupGlobalProperty(std::string& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 GlobalProperty property, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
759 bool shared) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
760 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
761 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
762 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
|
763 request.mutable_lookup_global_property()->set_property(property); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
764 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
765 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
766 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_GLOBAL_PROPERTY, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
767 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
768 if (response.lookup_global_property().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
769 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
770 target = response.lookup_global_property().value(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
771 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
772 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
773 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
774 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
775 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
776 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
779 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
780 virtual int64_t IncrementGlobalProperty(GlobalProperty property, |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
781 int64_t increment, |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
782 bool shared) ORTHANC_OVERRIDE |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
783 { |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
784 DatabasePluginMessages::TransactionRequest request; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
785 request.mutable_increment_global_property()->set_server_id(shared ? "" : database_.GetServerIdentifier()); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
786 request.mutable_increment_global_property()->set_property(property); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
787 request.mutable_increment_global_property()->set_increment(increment); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
788 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
789 DatabasePluginMessages::TransactionResponse response; |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
790 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_INCREMENT_GLOBAL_PROPERTY, request); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
791 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
792 return response.increment_global_property().new_value(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
793 } |
5466
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
794 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
795 virtual void UpdateAndGetStatistics(int64_t& patientsCount, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
796 int64_t& studiesCount, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
797 int64_t& seriesCount, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
798 int64_t& instancesCount, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
799 int64_t& compressedSize, |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
800 int64_t& uncompressedSize) ORTHANC_OVERRIDE |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
801 { |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
802 DatabasePluginMessages::TransactionResponse response; |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
803 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_UPDATE_AND_GET_STATISTICS); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
804 |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
805 patientsCount = response.update_and_get_statistics().patients_count(); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
806 studiesCount = response.update_and_get_statistics().studies_count(); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
807 seriesCount = response.update_and_get_statistics().series_count(); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
808 instancesCount = response.update_and_get_statistics().instances_count(); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
809 compressedSize = response.update_and_get_statistics().total_compressed_size(); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
810 uncompressedSize = response.update_and_get_statistics().total_uncompressed_size(); |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
811 } |
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
812 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 virtual bool LookupMetadata(std::string& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 int64_t& revision, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 MetadataType type) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
818 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
819 request.mutable_lookup_metadata()->set_id(id); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
820 request.mutable_lookup_metadata()->set_metadata_type(type); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
821 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
822 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
823 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_METADATA, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
824 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
825 if (response.lookup_metadata().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
826 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
827 target = response.lookup_metadata().value(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
828 revision = response.lookup_metadata().revision(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
829 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
830 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
831 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
832 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
833 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
834 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 virtual bool LookupParent(int64_t& parentId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
839 int64_t resourceId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
841 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
842 request.mutable_lookup_parent()->set_id(resourceId); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
843 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
844 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
845 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_PARENT, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
846 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
847 if (response.lookup_parent().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
848 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
849 parentId = response.lookup_parent().parent(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
850 return true; |
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 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
853 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
854 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
855 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 virtual bool LookupResource(int64_t& id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 ResourceType& type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 const std::string& publicId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
863 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
864 request.mutable_lookup_resource()->set_public_id(publicId); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
865 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
866 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
867 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCE, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
868 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
869 if (response.lookup_resource().found()) |
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 id = response.lookup_resource().internal_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
872 type = Convert(response.lookup_resource().type()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
873 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
874 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
875 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
876 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
877 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
878 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 } |
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 virtual bool SelectPatientToRecycle(int64_t& internalId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
883 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
884 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
885 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_SELECT_PATIENT_TO_RECYCLE); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
886 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
887 if (response.select_patient_to_recycle().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
888 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
889 internalId = response.select_patient_to_recycle().patient_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
890 return true; |
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 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
893 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
894 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
895 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 virtual bool SelectPatientToRecycle(int64_t& internalId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 int64_t patientIdToAvoid) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
902 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
903 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
|
904 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
905 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
906 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
|
907 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
908 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
|
909 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
910 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
|
911 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
912 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
913 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
914 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
915 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
916 } |
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 SetGlobalProperty(GlobalProperty property, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 bool shared, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 const std::string& value) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
924 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
925 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
|
926 request.mutable_set_global_property()->set_property(property); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
927 request.mutable_set_global_property()->set_value(value); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
928 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
929 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_GLOBAL_PROPERTY, request); |
5207
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
932 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 virtual void ClearMainDicomTags(int64_t id) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
934 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
935 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
936 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
|
937 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
938 ExecuteTransaction(DatabasePluginMessages::OPERATION_CLEAR_MAIN_DICOM_TAGS, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 } |
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 virtual void SetMetadata(int64_t id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
943 MetadataType type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
944 const std::string& value, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
945 int64_t revision) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
947 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
948 request.mutable_set_metadata()->set_id(id); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
949 request.mutable_set_metadata()->set_metadata_type(type); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
950 request.mutable_set_metadata()->set_value(value); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
951 request.mutable_set_metadata()->set_revision(revision); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
952 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
953 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_METADATA, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
956 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
957 virtual void SetProtectedPatient(int64_t internalId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
958 bool isProtected) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
960 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
961 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
|
962 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
|
963 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
964 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_PROTECTED_PATIENT, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
965 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
966 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
967 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
968 virtual bool IsDiskSizeAbove(uint64_t threshold) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
969 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
970 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
971 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
|
972 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
973 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
974 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
|
975 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
976 return response.is_disk_size_above().result(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
977 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
978 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
979 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
980 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
981 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
|
982 const std::vector<DatabaseConstraint>& lookup, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
983 ResourceType queryLevel, |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
984 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
|
985 LabelsConstraint labelsConstraint, |
5213
055428d92772
clarifying types of since/limit in IDatabaseWrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5211
diff
changeset
|
986 uint32_t limit) ORTHANC_OVERRIDE |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
987 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
988 if (!database_.GetDatabaseCapabilities().HasLabelsSupport() && |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
989 !labels.empty()) |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
990 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
991 throw OrthancException(ErrorCode_InternalError); |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
992 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
993 |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
994 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
995 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
|
996 request.mutable_lookup_resources()->set_limit(limit); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
997 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
|
998 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
999 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
|
1000 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1001 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
|
1002 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1003 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
|
1004 constraint->set_level(Convert(lookup[i].GetLevel())); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1005 constraint->set_tag_group(lookup[i].GetTag().GetGroup()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1006 constraint->set_tag_element(lookup[i].GetTag().GetElement()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1007 constraint->set_is_identifier_tag(lookup[i].IsIdentifier()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1008 constraint->set_is_case_sensitive(lookup[i].IsCaseSensitive()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1009 constraint->set_is_mandatory(lookup[i].IsMandatory()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1010 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1011 constraint->mutable_values()->Reserve(lookup[i].GetValuesCount()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1012 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
|
1013 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1014 constraint->add_values(lookup[i].GetValue(j)); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1015 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1016 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1017 switch (lookup[i].GetConstraintType()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1018 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1019 case ConstraintType_Equal: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1020 constraint->set_type(DatabasePluginMessages::CONSTRAINT_EQUAL); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1021 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1022 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1023 case ConstraintType_SmallerOrEqual: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1024 constraint->set_type(DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1025 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1026 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1027 case ConstraintType_GreaterOrEqual: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1028 constraint->set_type(DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1029 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1030 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1031 case ConstraintType_Wildcard: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1032 constraint->set_type(DatabasePluginMessages::CONSTRAINT_WILDCARD); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1033 break; |
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 case ConstraintType_List: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1036 constraint->set_type(DatabasePluginMessages::CONSTRAINT_LIST); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1037 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1038 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1039 default: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1040 throw OrthancException(ErrorCode_ParameterOutOfRange); |
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 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1043 |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1044 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
|
1045 { |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1046 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
|
1047 } |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1048 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1049 switch (labelsConstraint) |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1050 { |
5248
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1051 case LabelsConstraint_All: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1052 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
|
1053 break; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1054 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1055 case LabelsConstraint_Any: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1056 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
|
1057 break; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1058 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1059 case LabelsConstraint_None: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1060 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
|
1061 break; |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1062 |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1063 default: |
a7d95f951f8a
replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5239
diff
changeset
|
1064 throw OrthancException(ErrorCode_ParameterOutOfRange); |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1065 } |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1066 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1067 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1068 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request); |
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 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
|
1071 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1072 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
|
1073 } |
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 (instancesId != NULL) |
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 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
|
1078 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1079 throw OrthancException(ErrorCode_DatabasePlugin); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1080 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1081 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1082 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1083 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
|
1084 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1085 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
|
1086 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1087 } |
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 bool CreateInstance(CreateInstanceResult& result, /* out */ |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1093 int64_t& instanceId, /* out */ |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1094 const std::string& patient, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1095 const std::string& study, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1096 const std::string& series, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1097 const std::string& instance) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1098 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1099 // TODO: "CreateInstanceResult" => constructor and getters |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1100 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1101 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1102 request.mutable_create_instance()->set_patient(patient); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1103 request.mutable_create_instance()->set_study(study); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1104 request.mutable_create_instance()->set_series(series); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1105 request.mutable_create_instance()->set_instance(instance); |
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 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1108 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_CREATE_INSTANCE, request); |
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 instanceId = response.create_instance().instance_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1111 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1112 if (response.create_instance().is_new_instance()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1113 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1114 result.isNewPatient_ = response.create_instance().is_new_patient(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1115 result.isNewStudy_ = response.create_instance().is_new_study(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1116 result.isNewSeries_ = response.create_instance().is_new_series(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1117 result.patientId_ = response.create_instance().patient_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1118 result.studyId_ = response.create_instance().study_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1119 result.seriesId_ = response.create_instance().series_id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1120 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1121 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1122 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1123 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1124 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1125 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1126 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1127 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1128 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1129 virtual void SetResourcesContent(const ResourcesContent& content) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1130 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1131 DatabasePluginMessages::TransactionRequest request; |
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 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
|
1134 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
|
1135 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1136 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
|
1137 tag->set_resource_id(it->GetResourceId()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1138 tag->set_is_identifier(it->IsIdentifier()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1139 tag->set_group(it->GetTag().GetGroup()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1140 tag->set_element(it->GetTag().GetElement()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1141 tag->set_value(it->GetValue()); |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1142 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1143 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1144 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
|
1145 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
|
1146 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1147 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
|
1148 metadata->set_resource_id(it->GetResourceId()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1149 metadata->set_metadata(it->GetType()); |
8b6da4fdf9fe
cleaning ResourcesContent::TagValue and ResourcesContent::Metadata
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5214
diff
changeset
|
1150 metadata->set_value(it->GetValue()); |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1151 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1152 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1153 ExecuteTransaction(DatabasePluginMessages::OPERATION_SET_RESOURCES_CONTENT, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1154 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1155 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1156 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1157 virtual void GetChildrenMetadata(std::list<std::string>& target, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1158 int64_t resourceId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1159 MetadataType metadata) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1160 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1161 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1162 request.mutable_get_children_metadata()->set_id(resourceId); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1163 request.mutable_get_children_metadata()->set_metadata(metadata); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1164 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1165 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1166 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_CHILDREN_METADATA, request); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1167 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1168 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
|
1169 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1170 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
|
1171 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1172 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1173 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1174 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1175 virtual int64_t GetLastChangeIndex() ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1176 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1177 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1178 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_GET_LAST_CHANGE_INDEX); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1179 return response.get_last_change_index().result(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1180 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1181 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1182 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1183 virtual bool LookupResourceAndParent(int64_t& id, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1184 ResourceType& type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1185 std::string& parentPublicId, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1186 const std::string& publicId) ORTHANC_OVERRIDE |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1187 { |
5211
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1188 DatabasePluginMessages::TransactionRequest request; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1189 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
|
1190 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1191 DatabasePluginMessages::TransactionResponse response; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1192 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
|
1193 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1194 if (response.lookup_resource_and_parent().found()) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1195 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1196 id = response.lookup_resource_and_parent().id(); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1197 type = Convert(response.lookup_resource_and_parent().type()); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1198 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1199 switch (type) |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1200 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1201 case ResourceType_Patient: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1202 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
|
1203 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1204 throw OrthancException(ErrorCode_DatabasePlugin); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1205 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1206 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1207 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1208 case ResourceType_Study: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1209 case ResourceType_Series: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1210 case ResourceType_Instance: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1211 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
|
1212 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1213 throw OrthancException(ErrorCode_DatabasePlugin); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1214 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1215 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1216 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1217 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
|
1218 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1219 break; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1220 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1221 default: |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1222 throw OrthancException(ErrorCode_ParameterOutOfRange); |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1223 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1224 |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1225 return true; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1226 } |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1227 else |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1228 { |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1229 return false; |
27e6ec2811e3
completed first implementation of OrthancPluginDatabaseV4
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5210
diff
changeset
|
1230 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
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 virtual void AddLabel(int64_t resource, |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1235 const std::string& label) ORTHANC_OVERRIDE |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1236 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1237 if (database_.GetDatabaseCapabilities().HasLabelsSupport()) |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1238 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1239 DatabasePluginMessages::TransactionRequest request; |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1240 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
|
1241 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
|
1242 |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1243 ExecuteTransaction(DatabasePluginMessages::OPERATION_ADD_LABEL, request); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1244 } |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1245 else |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1246 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1247 // 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
|
1248 throw OrthancException(ErrorCode_InternalError); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1249 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1250 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1251 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1252 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1253 virtual void RemoveLabel(int64_t resource, |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1254 const std::string& label) ORTHANC_OVERRIDE |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1255 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1256 if (database_.GetDatabaseCapabilities().HasLabelsSupport()) |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1257 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1258 DatabasePluginMessages::TransactionRequest request; |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1259 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
|
1260 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
|
1261 |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1262 ExecuteTransaction(DatabasePluginMessages::OPERATION_REMOVE_LABEL, request); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1263 } |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1264 else |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1265 { |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1266 // 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
|
1267 throw OrthancException(ErrorCode_InternalError); |
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1268 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1269 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1270 |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1271 |
5221
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1272 virtual void ListLabels(std::set<std::string>& target, |
d0f7c742d397
started implementation of labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5220
diff
changeset
|
1273 int64_t resource) ORTHANC_OVERRIDE |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1274 { |
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
|
1275 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
|
1276 } |
5239
178b0434256a
added primitives to exchange labels with plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5221
diff
changeset
|
1277 |
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
|
1278 |
f22c8fac764b
added "/tools/labels" to list all the labels that are associated with any resource
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5248
diff
changeset
|
1279 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
|
1280 { |
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
|
1281 ListLabelsInternal(target, false, -1); |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1282 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1283 }; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1284 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1285 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1286 OrthancPluginDatabaseV4::OrthancPluginDatabaseV4(SharedLibrary& library, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1287 PluginsErrorDictionary& errorDictionary, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1288 const _OrthancPluginRegisterDatabaseBackendV4& database, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1289 const std::string& serverIdentifier) : |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1290 library_(library), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1291 errorDictionary_(errorDictionary), |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1292 definition_(database), |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1293 serverIdentifier_(serverIdentifier), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1294 open_(false), |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1295 databaseVersion_(0), |
5493
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1296 dbCapabilities_(false, false, false, false, false, false) // updated in Open() |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1297 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1298 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
|
1299 << "of the custom database: \"" << serverIdentifier << "\""; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1300 |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1301 if (definition_.backend == NULL || |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1302 definition_.operations == NULL || |
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1303 definition_.finalize == NULL) |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1304 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1305 throw OrthancException(ErrorCode_NullPointer); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1306 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1307 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1308 |
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 OrthancPluginDatabaseV4::~OrthancPluginDatabaseV4() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 { |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1312 definition_.finalize(definition_.backend); |
5207
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 |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1315 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1316 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
|
1317 ResourceType level) |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1318 { |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1319 const DicomTag* tags = NULL; |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1320 size_t size; |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1321 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1322 ServerToolbox::LoadIdentifiers(tags, size, level); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1323 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1324 if (tags == NULL || |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1325 size == 0) |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1326 { |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1327 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1328 } |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1329 |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1330 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
|
1331 { |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1332 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
|
1333 tag->set_level(Convert(level)); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1334 tag->set_group(tags[i].GetGroup()); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1335 tag->set_element(tags[i].GetElement()); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1336 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
|
1337 } |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1338 } |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1339 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1340 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1341 void OrthancPluginDatabaseV4::Open() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1342 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1343 if (open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1344 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1345 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1346 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1347 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1348 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1349 DatabasePluginMessages::DatabaseRequest request; |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1350 AddIdentifierTags(*request.mutable_open(), ResourceType_Patient); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1351 AddIdentifierTags(*request.mutable_open(), ResourceType_Study); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1352 AddIdentifierTags(*request.mutable_open(), ResourceType_Series); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1353 AddIdentifierTags(*request.mutable_open(), ResourceType_Instance); |
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1354 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1355 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1356 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_OPEN, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1357 } |
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 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1360 DatabasePluginMessages::DatabaseRequest request; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1361 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1362 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_GET_SYSTEM_INFORMATION, request); |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1363 |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1364 const ::Orthanc::DatabasePluginMessages::GetSystemInformation_Response& systemInfo = response.get_system_information(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1365 databaseVersion_ = systemInfo.database_version(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1366 dbCapabilities_.hasFlushToDisk_ = systemInfo.supports_flush_to_disk(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1367 dbCapabilities_.hasRevisionsSupport_ = systemInfo.supports_revisions(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1368 dbCapabilities_.hasLabelsSupport_ = systemInfo.supports_labels(); |
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1369 dbCapabilities_.hasAtomicIncrementGlobalProperty_ = systemInfo.supports_increment_global_property(); |
5466
dceed5e3d6a9
new DB plugin primitive: UpdateAndGetStatistics
Alain Mazy <am@osimis.io>
parents:
5455
diff
changeset
|
1370 dbCapabilities_.hasUpdateAndGetStatistics_ = systemInfo.has_update_and_get_statistics(); |
5493
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1371 dbCapabilities_.hasMeasureLatency_ = systemInfo.has_measure_latency(); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1372 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1373 |
5254
fafdb6179829
inform database plugins about the identifier tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5249
diff
changeset
|
1374 open_ = true; |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1375 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1376 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1377 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1378 void OrthancPluginDatabaseV4::Close() |
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 if (!open_) |
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1383 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1384 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1385 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1386 DatabasePluginMessages::DatabaseRequest request; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1387 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1388 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_CLOSE, request); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1389 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1390 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1391 |
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 void OrthancPluginDatabaseV4::FlushToDisk() |
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 if (!open_ || |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1397 !GetDatabaseCapabilities().HasFlushToDisk()) |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1398 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1399 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1400 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1401 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1402 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1403 DatabasePluginMessages::DatabaseRequest request; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1404 DatabasePluginMessages::DatabaseResponse response; |
5209
154d37a56500
started implementation of transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5207
diff
changeset
|
1405 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_FLUSH_TO_DISK, request); |
5207
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 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1410 IDatabaseWrapper::ITransaction* OrthancPluginDatabaseV4::StartTransaction(TransactionType type, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1411 IDatabaseListener& listener) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1412 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1413 if (!open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1414 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1415 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1416 } |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1417 else |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1418 { |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1419 return new Transaction(*this, listener, type); |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1420 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1421 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1422 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1423 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1424 unsigned int OrthancPluginDatabaseV4::GetDatabaseVersion() |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1425 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1426 if (!open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1427 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1428 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1429 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1430 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1431 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1432 return databaseVersion_; |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1433 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1434 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1435 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1436 |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1437 void OrthancPluginDatabaseV4::Upgrade(unsigned int targetVersion, |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1438 IStorageArea& storageArea) |
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 if (!open_) |
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 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
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 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1445 { |
5214
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1446 VoidDatabaseListener listener; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1447 Transaction transaction(*this, listener, TransactionType_ReadWrite); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1448 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1449 try |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1450 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1451 DatabasePluginMessages::DatabaseRequest request; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1452 request.mutable_upgrade()->set_target_version(targetVersion); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1453 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
|
1454 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
|
1455 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1456 DatabasePluginMessages::DatabaseResponse response; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1457 |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1458 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_UPGRADE, request); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1459 transaction.Commit(0); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1460 } |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1461 catch (OrthancException& e) |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1462 { |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1463 transaction.Rollback(); |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1464 throw; |
a9d00b17a48e
implemented OrthancPluginDatabaseV4::Upgrade()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5213
diff
changeset
|
1465 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1466 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1467 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1468 |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1469 |
5493
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1470 uint64_t OrthancPluginDatabaseV4::MeasureLatency() |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1471 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1472 if (!open_) |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1473 { |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1474 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1475 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1476 else |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1477 { |
5493
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1478 try |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1479 { |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1480 DatabasePluginMessages::DatabaseRequest request; |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1481 DatabasePluginMessages::DatabaseResponse response; |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1482 |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1483 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_MEASURE_LATENCY, request); |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1484 return response.measure_latency().latency_us(); |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1485 |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1486 } |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1487 catch (OrthancException& e) |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1488 { |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1489 throw; |
b3ebe249ed5b
At startup, when using a database plugin, display the latency to access the DB
Alain Mazy <am@osimis.io>
parents:
5466
diff
changeset
|
1490 } |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1491 } |
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1492 } |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1493 |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1494 const IDatabaseWrapper::Capabilities& OrthancPluginDatabaseV4::GetDatabaseCapabilities() const |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1495 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1496 if (!open_) |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1497 { |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1498 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1499 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1500 else |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1501 { |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1502 return dbCapabilities_; |
5220
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1503 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1504 } |
df39c7583a49
preparing virtual methods for labels
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5216
diff
changeset
|
1505 |
5455
176bc05f85f4
DB: new Capabilities class to manage future new methods from DB plugins + Added IncrementGlobalProperty
Alain Mazy <am@osimis.io>
parents:
5254
diff
changeset
|
1506 |
5207
e7529e6241d2
first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1507 } |