comparison Framework/Plugins/DatabaseBackendAdapterV4.cpp @ 461:c2d6ce6818fe pg-transactions

fix compatibility with older versions of Orthanc SDK
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 24 Jan 2024 15:58:27 +0100
parents f0976163dbe1
children 594859656a06 54d518dcd74a
comparison
equal deleted inserted replaced
460:f0976163dbe1 461:c2d6ce6818fe
429 IndexConnectionsPool::Accessor accessor(pool); 429 IndexConnectionsPool::Accessor accessor(pool);
430 response.mutable_get_system_information()->set_database_version(accessor.GetBackend().GetDatabaseVersion(accessor.GetManager())); 430 response.mutable_get_system_information()->set_database_version(accessor.GetBackend().GetDatabaseVersion(accessor.GetManager()));
431 response.mutable_get_system_information()->set_supports_flush_to_disk(false); 431 response.mutable_get_system_information()->set_supports_flush_to_disk(false);
432 response.mutable_get_system_information()->set_supports_revisions(accessor.GetBackend().HasRevisionsSupport()); 432 response.mutable_get_system_information()->set_supports_revisions(accessor.GetBackend().HasRevisionsSupport());
433 response.mutable_get_system_information()->set_supports_labels(accessor.GetBackend().HasLabelsSupport()); 433 response.mutable_get_system_information()->set_supports_labels(accessor.GetBackend().HasLabelsSupport());
434
435 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 3)
434 response.mutable_get_system_information()->set_supports_increment_global_property(accessor.GetBackend().HasAtomicIncrementGlobalProperty()); 436 response.mutable_get_system_information()->set_supports_increment_global_property(accessor.GetBackend().HasAtomicIncrementGlobalProperty());
435 response.mutable_get_system_information()->set_has_update_and_get_statistics(accessor.GetBackend().HasUpdateAndGetStatistics()); 437 response.mutable_get_system_information()->set_has_update_and_get_statistics(accessor.GetBackend().HasUpdateAndGetStatistics());
436 response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency()); 438 response.mutable_get_system_information()->set_has_measure_latency(accessor.GetBackend().HasMeasureLatency());
439 #endif
440
437 break; 441 break;
438 } 442 }
439 443
440 case Orthanc::DatabasePluginMessages::OPERATION_OPEN: 444 case Orthanc::DatabasePluginMessages::OPERATION_OPEN:
441 { 445 {
516 } 520 }
517 521
518 break; 522 break;
519 } 523 }
520 524
525 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 3)
521 case Orthanc::DatabasePluginMessages::OPERATION_MEASURE_LATENCY: 526 case Orthanc::DatabasePluginMessages::OPERATION_MEASURE_LATENCY:
522 { 527 {
523 IndexConnectionsPool::Accessor accessor(pool); 528 IndexConnectionsPool::Accessor accessor(pool);
524 response.mutable_measure_latency()->set_latency_us(accessor.GetBackend().MeasureLatency(accessor.GetManager())); 529 response.mutable_measure_latency()->set_latency_us(accessor.GetBackend().MeasureLatency(accessor.GetManager()));
525 break; 530 break;
526 } 531 }
532 #endif
527 533
528 default: 534 default:
529 LOG(ERROR) << "Not implemented database operation from protobuf: " << request.operation(); 535 LOG(ERROR) << "Not implemented database operation from protobuf: " << request.operation();
530 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); 536 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
531 } 537 }
950 } 956 }
951 957
952 break; 958 break;
953 } 959 }
954 960
961 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 3)
955 case Orthanc::DatabasePluginMessages::OPERATION_UPDATE_AND_GET_STATISTICS: 962 case Orthanc::DatabasePluginMessages::OPERATION_UPDATE_AND_GET_STATISTICS:
956 { 963 {
957 int64_t patientsCount, studiesCount, seriesCount, instancesCount, compressedSize, uncompressedSize; 964 int64_t patientsCount, studiesCount, seriesCount, instancesCount, compressedSize, uncompressedSize;
958 backend.UpdateAndGetStatistics(manager, patientsCount, studiesCount, seriesCount, instancesCount, compressedSize, uncompressedSize); 965 backend.UpdateAndGetStatistics(manager, patientsCount, studiesCount, seriesCount, instancesCount, compressedSize, uncompressedSize);
959 966
963 response.mutable_update_and_get_statistics()->set_instances_count(instancesCount); 970 response.mutable_update_and_get_statistics()->set_instances_count(instancesCount);
964 response.mutable_update_and_get_statistics()->set_total_compressed_size(compressedSize); 971 response.mutable_update_and_get_statistics()->set_total_compressed_size(compressedSize);
965 response.mutable_update_and_get_statistics()->set_total_uncompressed_size(uncompressedSize); 972 response.mutable_update_and_get_statistics()->set_total_uncompressed_size(uncompressedSize);
966 break; 973 break;
967 } 974 }
968 975 #endif
976
977 #if ORTHANC_PLUGINS_VERSION_IS_ABOVE(1, 12, 3)
969 case Orthanc::DatabasePluginMessages::OPERATION_INCREMENT_GLOBAL_PROPERTY: 978 case Orthanc::DatabasePluginMessages::OPERATION_INCREMENT_GLOBAL_PROPERTY:
970 { 979 {
971 int64_t value = backend.IncrementGlobalProperty(manager, request.increment_global_property().server_id().c_str(), 980 int64_t value = backend.IncrementGlobalProperty(manager, request.increment_global_property().server_id().c_str(),
972 request.increment_global_property().property(), 981 request.increment_global_property().property(),
973 request.increment_global_property().increment()); 982 request.increment_global_property().increment());
974 response.mutable_increment_global_property()->set_new_value(value); 983 response.mutable_increment_global_property()->set_new_value(value);
975 break; 984 break;
976 } 985 }
986 #endif
977 987
978 case Orthanc::DatabasePluginMessages::OPERATION_LOOKUP_METADATA: 988 case Orthanc::DatabasePluginMessages::OPERATION_LOOKUP_METADATA:
979 { 989 {
980 std::string value; 990 std::string value;
981 int64_t revision = -1; 991 int64_t revision = -1;