comparison Framework/Plugins/DatabaseBackendAdapterV4.cpp @ 403:91124cc8a8c7 db-protobuf

database plugins are informed about the identifier tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Apr 2023 11:10:19 +0200
parents 82921a29349a
children 7c1fe5d6c12c ecd0b719cff5
comparison
equal deleted inserted replaced
402:82921a29349a 403:91124cc8a8c7
88 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 88 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
89 } 89 }
90 } 90 }
91 91
92 92
93 static Orthanc::ResourceType Convert2(Orthanc::DatabasePluginMessages::ResourceType resourceType)
94 {
95 switch (resourceType)
96 {
97 case Orthanc::DatabasePluginMessages::RESOURCE_PATIENT:
98 return Orthanc::ResourceType_Patient;
99
100 case Orthanc::DatabasePluginMessages::RESOURCE_STUDY:
101 return Orthanc::ResourceType_Study;
102
103 case Orthanc::DatabasePluginMessages::RESOURCE_SERIES:
104 return Orthanc::ResourceType_Series;
105
106 case Orthanc::DatabasePluginMessages::RESOURCE_INSTANCE:
107 return Orthanc::ResourceType_Instance;
108
109 default:
110 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
111 }
112 }
113
114
93 class Output : public IDatabaseBackendOutput 115 class Output : public IDatabaseBackendOutput
94 { 116 {
95 private: 117 private:
96 Orthanc::DatabasePluginMessages::DeleteAttachment::Response* deleteAttachment_; 118 Orthanc::DatabasePluginMessages::DeleteAttachment::Response* deleteAttachment_;
97 Orthanc::DatabasePluginMessages::DeleteResource::Response* deleteResource_; 119 Orthanc::DatabasePluginMessages::DeleteResource::Response* deleteResource_;
412 break; 434 break;
413 } 435 }
414 436
415 case Orthanc::DatabasePluginMessages::OPERATION_OPEN: 437 case Orthanc::DatabasePluginMessages::OPERATION_OPEN:
416 { 438 {
417 pool.OpenConnections(); 439 std::list<IdentifierTag> identifierTags;
440
441 if (request.open().identifier_tags().empty())
442 {
443 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
444 "No identifier tag was provided by the Orthanc core");
445 }
446
447 for (int i = 0; i < request.open().identifier_tags().size(); i++)
448 {
449 const Orthanc::DatabasePluginMessages::Open_Request_IdentifierTag& tag = request.open().identifier_tags(i);
450 identifierTags.push_back(IdentifierTag(Convert2(tag.level()),
451 Orthanc::DicomTag(tag.group(), tag.element()),
452 tag.name()));
453 }
454
455 pool.OpenConnections(true, identifierTags);
456
418 break; 457 break;
419 } 458 }
420 459
421 case Orthanc::DatabasePluginMessages::OPERATION_CLOSE: 460 case Orthanc::DatabasePluginMessages::OPERATION_CLOSE:
422 { 461 {