Mercurial > hg > orthanc-databases
comparison Framework/Plugins/DatabaseBackendAdapterV4.cpp @ 568:77c8544bbd7d find-refactoring
merge
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 23 Sep 2024 16:06:53 +0200 |
parents | 22bbce1f88ff 373cf7d747cc |
children | f18e46d7dbf8 35d2df9572b1 |
comparison
equal
deleted
inserted
replaced
567:22bbce1f88ff | 568:77c8544bbd7d |
---|---|
25 | 25 |
26 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 | 26 #if defined(ORTHANC_PLUGINS_VERSION_IS_ABOVE) // Macro introduced in Orthanc 1.3.1 |
27 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) | 27 # if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 0) |
28 | 28 |
29 #include "IndexConnectionsPool.h" | 29 #include "IndexConnectionsPool.h" |
30 #include "MessagesToolbox.h" | |
30 | 31 |
31 #include <OrthancDatabasePlugin.pb.h> // Include protobuf messages | 32 #include <OrthancDatabasePlugin.pb.h> // Include protobuf messages |
32 | 33 |
33 #include <Logging.h> | 34 #include <Logging.h> |
34 #include <OrthancException.h> | 35 #include <OrthancException.h> |
95 { | 96 { |
96 private: | 97 private: |
97 Orthanc::DatabasePluginMessages::DeleteAttachment::Response* deleteAttachment_; | 98 Orthanc::DatabasePluginMessages::DeleteAttachment::Response* deleteAttachment_; |
98 Orthanc::DatabasePluginMessages::DeleteResource::Response* deleteResource_; | 99 Orthanc::DatabasePluginMessages::DeleteResource::Response* deleteResource_; |
99 Orthanc::DatabasePluginMessages::GetChanges::Response* getChanges_; | 100 Orthanc::DatabasePluginMessages::GetChanges::Response* getChanges_; |
100 Orthanc::DatabasePluginMessages::GetChangesExtended::Response* getChangesExtended_; | |
101 Orthanc::DatabasePluginMessages::GetExportedResources::Response* getExportedResources_; | 101 Orthanc::DatabasePluginMessages::GetExportedResources::Response* getExportedResources_; |
102 Orthanc::DatabasePluginMessages::GetLastChange::Response* getLastChange_; | 102 Orthanc::DatabasePluginMessages::GetLastChange::Response* getLastChange_; |
103 Orthanc::DatabasePluginMessages::GetLastExportedResource::Response* getLastExportedResource_; | 103 Orthanc::DatabasePluginMessages::GetLastExportedResource::Response* getLastExportedResource_; |
104 Orthanc::DatabasePluginMessages::GetMainDicomTags::Response* getMainDicomTags_; | 104 Orthanc::DatabasePluginMessages::GetMainDicomTags::Response* getMainDicomTags_; |
105 Orthanc::DatabasePluginMessages::LookupAttachment::Response* lookupAttachment_; | 105 Orthanc::DatabasePluginMessages::LookupAttachment::Response* lookupAttachment_; |
106 Orthanc::DatabasePluginMessages::LookupResources::Response* lookupResources_; | 106 Orthanc::DatabasePluginMessages::LookupResources::Response* lookupResources_; |
107 | 107 |
108 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1 | |
109 Orthanc::DatabasePluginMessages::GetChangesExtended::Response* getChangesExtended_; | |
110 #endif | |
111 | |
108 void Clear() | 112 void Clear() |
109 { | 113 { |
110 deleteAttachment_ = NULL; | 114 deleteAttachment_ = NULL; |
111 deleteResource_ = NULL; | 115 deleteResource_ = NULL; |
112 getChanges_ = NULL; | 116 getChanges_ = NULL; |
113 getChangesExtended_ = NULL; | |
114 getExportedResources_ = NULL; | 117 getExportedResources_ = NULL; |
115 getLastChange_ = NULL; | 118 getLastChange_ = NULL; |
116 getLastExportedResource_ = NULL; | 119 getLastExportedResource_ = NULL; |
117 getMainDicomTags_ = NULL; | 120 getMainDicomTags_ = NULL; |
118 lookupAttachment_ = NULL; | 121 lookupAttachment_ = NULL; |
119 lookupResources_ = NULL; | 122 lookupResources_ = NULL; |
123 | |
124 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1 | |
125 getChangesExtended_ = NULL; | |
126 #endif | |
120 } | 127 } |
121 | 128 |
122 public: | 129 public: |
123 Output(Orthanc::DatabasePluginMessages::DeleteAttachment::Response& deleteAttachment) | 130 Output(Orthanc::DatabasePluginMessages::DeleteAttachment::Response& deleteAttachment) |
124 { | 131 { |
136 { | 143 { |
137 Clear(); | 144 Clear(); |
138 getChanges_ = &getChanges; | 145 getChanges_ = &getChanges; |
139 } | 146 } |
140 | 147 |
148 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1 | |
141 Output(Orthanc::DatabasePluginMessages::GetChangesExtended::Response& getChangesExtended) | 149 Output(Orthanc::DatabasePluginMessages::GetChangesExtended::Response& getChangesExtended) |
142 { | 150 { |
143 Clear(); | 151 Clear(); |
144 getChangesExtended_ = &getChangesExtended; | 152 getChangesExtended_ = &getChangesExtended; |
145 } | 153 } |
154 #endif | |
146 | 155 |
147 Output(Orthanc::DatabasePluginMessages::GetExportedResources::Response& getExportedResources) | 156 Output(Orthanc::DatabasePluginMessages::GetExportedResources::Response& getExportedResources) |
148 { | 157 { |
149 Clear(); | 158 Clear(); |
150 getExportedResources_ = &getExportedResources; | 159 getExportedResources_ = &getExportedResources; |
294 | 303 |
295 if (getChanges_ != NULL) | 304 if (getChanges_ != NULL) |
296 { | 305 { |
297 change = getChanges_->add_changes(); | 306 change = getChanges_->add_changes(); |
298 } | 307 } |
308 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1 | |
299 else if (getChangesExtended_ != NULL) | 309 else if (getChangesExtended_ != NULL) |
300 { | 310 { |
301 change = getChangesExtended_->add_changes(); | 311 change = getChangesExtended_->add_changes(); |
302 } | 312 } |
313 #endif | |
303 else if (getLastChange_ != NULL) | 314 else if (getLastChange_ != NULL) |
304 { | 315 { |
305 if (getLastChange_->found()) | 316 if (getLastChange_->found()) |
306 { | 317 { |
307 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 318 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
427 response.mutable_get_system_information()->set_supports_increment_global_property(accessor.GetBackend().HasAtomicIncrementGlobalProperty()); | 438 response.mutable_get_system_information()->set_supports_increment_global_property(accessor.GetBackend().HasAtomicIncrementGlobalProperty()); |
428 response.mutable_get_system_information()->set_has_update_and_get_statistics(accessor.GetBackend().HasUpdateAndGetStatistics()); | 439 response.mutable_get_system_information()->set_has_update_and_get_statistics(accessor.GetBackend().HasUpdateAndGetStatistics()); |
429 response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency()); | 440 response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency()); |
430 #endif | 441 #endif |
431 | 442 |
432 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) | 443 #if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1 |
433 response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport()); | 444 response.mutable_get_system_information()->set_supports_find(accessor.GetBackend().HasFindSupport()); |
434 response.mutable_get_system_information()->set_has_extended_changes(accessor.GetBackend().HasExtendedChanges()); | 445 response.mutable_get_system_information()->set_has_extended_changes(accessor.GetBackend().HasExtendedChanges()); |
435 #endif | 446 #endif |
436 | 447 |
437 break; | 448 break; |
775 backend.GetChanges(output, done, manager, request.get_changes().since(), request.get_changes().limit()); | 786 backend.GetChanges(output, done, manager, request.get_changes().since(), request.get_changes().limit()); |
776 | 787 |
777 response.mutable_get_changes()->set_done(done); | 788 response.mutable_get_changes()->set_done(done); |
778 break; | 789 break; |
779 } | 790 } |
780 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 5) | 791 #if ORTHANC_PLUGINS_HAS_CHANGES_EXTENDED == 1 |
781 case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_EXTENDED: | 792 case Orthanc::DatabasePluginMessages::OPERATION_GET_CHANGES_EXTENDED: |
782 { | 793 { |
783 Output output(*response.mutable_get_changes_extended()); | 794 Output output(*response.mutable_get_changes_extended()); |
784 | 795 |
785 bool done; | 796 bool done; |
1308 } | 1319 } |
1309 | 1320 |
1310 break; | 1321 break; |
1311 } | 1322 } |
1312 | 1323 |
1324 #if ORTHANC_PLUGINS_HAS_INTEGRATED_FIND == 1 | |
1313 case Orthanc::DatabasePluginMessages::OPERATION_FIND: | 1325 case Orthanc::DatabasePluginMessages::OPERATION_FIND: |
1314 { | 1326 { |
1315 backend.ExecuteFind(response, manager, request.find()); | 1327 backend.ExecuteFind(response, manager, request.find()); |
1316 break; | 1328 break; |
1317 } | 1329 } |
1330 #endif | |
1318 | 1331 |
1319 default: | 1332 default: |
1320 LOG(ERROR) << "Not implemented transaction operation from protobuf: " << request.operation(); | 1333 LOG(ERROR) << "Not implemented transaction operation from protobuf: " << request.operation(); |
1321 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | 1334 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); |
1322 } | 1335 } |