Mercurial > hg > orthanc
comparison OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5254:fafdb6179829 db-protobuf
inform database plugins about the identifier tags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Apr 2023 11:09:52 +0200 |
parents | f22c8fac764b |
children | 176bc05f85f4 48b8dae6dc77 |
comparison
equal
deleted
inserted
replaced
5253:1700fe5c9737 | 5254:fafdb6179829 |
---|---|
25 | 25 |
26 #if ORTHANC_ENABLE_PLUGINS != 1 | 26 #if ORTHANC_ENABLE_PLUGINS != 1 |
27 # error The plugin support is disabled | 27 # error The plugin support is disabled |
28 #endif | 28 #endif |
29 | 29 |
30 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
30 #include "../../../OrthancFramework/Sources/Logging.h" | 31 #include "../../../OrthancFramework/Sources/Logging.h" |
31 #include "../../../OrthancFramework/Sources/OrthancException.h" | 32 #include "../../../OrthancFramework/Sources/OrthancException.h" |
32 #include "../../Sources/Database/ResourcesContent.h" | 33 #include "../../Sources/Database/ResourcesContent.h" |
33 #include "../../Sources/Database/VoidDatabaseListener.h" | 34 #include "../../Sources/Database/VoidDatabaseListener.h" |
35 #include "../../Sources/ServerToolbox.h" | |
34 #include "PluginsEnumerations.h" | 36 #include "PluginsEnumerations.h" |
35 | 37 |
36 #include "OrthancDatabasePlugin.pb.h" // Auto-generated file | 38 #include "OrthancDatabasePlugin.pb.h" // Auto-generated file |
37 | 39 |
38 #include <cassert> | 40 #include <cassert> |
1273 OrthancPluginDatabaseV4::~OrthancPluginDatabaseV4() | 1275 OrthancPluginDatabaseV4::~OrthancPluginDatabaseV4() |
1274 { | 1276 { |
1275 definition_.finalize(definition_.backend); | 1277 definition_.finalize(definition_.backend); |
1276 } | 1278 } |
1277 | 1279 |
1280 | |
1281 static void AddIdentifierTags(DatabasePluginMessages::Open::Request& request, | |
1282 ResourceType level) | |
1283 { | |
1284 const DicomTag* tags = NULL; | |
1285 size_t size; | |
1286 | |
1287 ServerToolbox::LoadIdentifiers(tags, size, level); | |
1288 | |
1289 if (tags == NULL || | |
1290 size == 0) | |
1291 { | |
1292 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
1293 } | |
1294 | |
1295 for (size_t i = 0; i < size; i++) | |
1296 { | |
1297 DatabasePluginMessages::Open_Request_IdentifierTag* tag = request.add_identifier_tags(); | |
1298 tag->set_level(Convert(level)); | |
1299 tag->set_group(tags[i].GetGroup()); | |
1300 tag->set_element(tags[i].GetElement()); | |
1301 tag->set_name(FromDcmtkBridge::GetTagName(tags[i], "")); | |
1302 } | |
1303 } | |
1304 | |
1278 | 1305 |
1279 void OrthancPluginDatabaseV4::Open() | 1306 void OrthancPluginDatabaseV4::Open() |
1280 { | 1307 { |
1281 if (open_) | 1308 if (open_) |
1282 { | 1309 { |
1283 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 1310 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
1284 } | 1311 } |
1285 | 1312 |
1286 { | 1313 { |
1287 DatabasePluginMessages::DatabaseRequest request; | 1314 DatabasePluginMessages::DatabaseRequest request; |
1315 AddIdentifierTags(*request.mutable_open(), ResourceType_Patient); | |
1316 AddIdentifierTags(*request.mutable_open(), ResourceType_Study); | |
1317 AddIdentifierTags(*request.mutable_open(), ResourceType_Series); | |
1318 AddIdentifierTags(*request.mutable_open(), ResourceType_Instance); | |
1319 | |
1288 DatabasePluginMessages::DatabaseResponse response; | 1320 DatabasePluginMessages::DatabaseResponse response; |
1289 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_OPEN, request); | 1321 ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_OPEN, request); |
1290 } | 1322 } |
1291 | 1323 |
1292 { | 1324 { |
1297 hasFlushToDisk_ = response.get_system_information().supports_flush_to_disk(); | 1329 hasFlushToDisk_ = response.get_system_information().supports_flush_to_disk(); |
1298 hasRevisionsSupport_ = response.get_system_information().supports_revisions(); | 1330 hasRevisionsSupport_ = response.get_system_information().supports_revisions(); |
1299 hasLabelsSupport_ = response.get_system_information().supports_labels(); | 1331 hasLabelsSupport_ = response.get_system_information().supports_labels(); |
1300 } | 1332 } |
1301 | 1333 |
1302 open_ = true; | 1334 open_ = true; |
1303 } | 1335 } |
1304 | 1336 |
1305 | 1337 |
1306 void OrthancPluginDatabaseV4::Close() | 1338 void OrthancPluginDatabaseV4::Close() |
1307 { | 1339 { |