comparison OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5248:a7d95f951f8a db-protobuf

replaced "WithLabels" and "WithoutLabels", by "Labels" and "LabelsConstraint"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Apr 2023 22:18:37 +0200
parents 178b0434256a
children f22c8fac764b
comparison
equal deleted inserted replaced
5247:eb2684260c19 5248:a7d95f951f8a
913 913
914 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, 914 virtual void ApplyLookupResources(std::list<std::string>& resourcesId,
915 std::list<std::string>* instancesId, // Can be NULL if not needed 915 std::list<std::string>* instancesId, // Can be NULL if not needed
916 const std::vector<DatabaseConstraint>& lookup, 916 const std::vector<DatabaseConstraint>& lookup,
917 ResourceType queryLevel, 917 ResourceType queryLevel,
918 const std::set<std::string>& withLabels, 918 const std::set<std::string>& labels,
919 const std::set<std::string>& withoutLabels, 919 LabelsConstraint labelsConstraint,
920 uint32_t limit) ORTHANC_OVERRIDE 920 uint32_t limit) ORTHANC_OVERRIDE
921 { 921 {
922 if (!database_.HasLabelsSupport() && 922 if (!database_.HasLabelsSupport() &&
923 (!withLabels.empty() || 923 !labels.empty())
924 !withoutLabels.empty()))
925 { 924 {
926 throw OrthancException(ErrorCode_InternalError); 925 throw OrthancException(ErrorCode_InternalError);
927 } 926 }
928 927
929 DatabasePluginMessages::TransactionRequest request; 928 DatabasePluginMessages::TransactionRequest request;
974 default: 973 default:
975 throw OrthancException(ErrorCode_ParameterOutOfRange); 974 throw OrthancException(ErrorCode_ParameterOutOfRange);
976 } 975 }
977 } 976 }
978 977
979 for (std::set<std::string>::const_iterator it = withLabels.begin(); it != withLabels.end(); ++it) 978 for (std::set<std::string>::const_iterator it = labels.begin(); it != labels.end(); ++it)
980 { 979 {
981 request.mutable_lookup_resources()->add_with_labels(*it); 980 request.mutable_lookup_resources()->add_labels(*it);
982 } 981 }
983 982
984 for (std::set<std::string>::const_iterator it = withoutLabels.begin(); it != withoutLabels.end(); ++it) 983 switch (labelsConstraint)
985 { 984 {
986 request.mutable_lookup_resources()->add_without_labels(*it); 985 case LabelsConstraint_All:
986 request.mutable_lookup_resources()->set_labels_constraint(DatabasePluginMessages::LABELS_CONSTRAINT_ALL);
987 break;
988
989 case LabelsConstraint_Any:
990 request.mutable_lookup_resources()->set_labels_constraint(DatabasePluginMessages::LABELS_CONSTRAINT_ANY);
991 break;
992
993 case LabelsConstraint_None:
994 request.mutable_lookup_resources()->set_labels_constraint(DatabasePluginMessages::LABELS_CONSTRAINT_NONE);
995 break;
996
997 default:
998 throw OrthancException(ErrorCode_ParameterOutOfRange);
987 } 999 }
988 1000
989 DatabasePluginMessages::TransactionResponse response; 1001 DatabasePluginMessages::TransactionResponse response;
990 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request); 1002 ExecuteTransaction(response, DatabasePluginMessages::OPERATION_LOOKUP_RESOURCES, request);
991 1003