comparison OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp @ 5681:77875b51cf95 find-refactoring

integration mainline->find-refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 09 Jul 2024 10:15:15 +0200
parents dc96401dbe88 68fc5af30c03
children 89d559e67b03
comparison
equal deleted inserted replaced
5679:527918e9c5d9 5681:77875b51cf95
974 } 974 }
975 975
976 976
977 virtual void ApplyLookupResources(std::list<std::string>& resourcesId, 977 virtual void ApplyLookupResources(std::list<std::string>& resourcesId,
978 std::list<std::string>* instancesId, // Can be NULL if not needed 978 std::list<std::string>* instancesId, // Can be NULL if not needed
979 const std::vector<DatabaseConstraint>& lookup, 979 const DatabaseConstraints& lookup,
980 ResourceType queryLevel, 980 ResourceType queryLevel,
981 const std::set<std::string>& labels, 981 const std::set<std::string>& labels,
982 LabelsConstraint labelsConstraint, 982 LabelsConstraint labelsConstraint,
983 uint32_t limit) ORTHANC_OVERRIDE 983 uint32_t limit) ORTHANC_OVERRIDE
984 { 984 {
991 DatabasePluginMessages::TransactionRequest request; 991 DatabasePluginMessages::TransactionRequest request;
992 request.mutable_lookup_resources()->set_query_level(Convert(queryLevel)); 992 request.mutable_lookup_resources()->set_query_level(Convert(queryLevel));
993 request.mutable_lookup_resources()->set_limit(limit); 993 request.mutable_lookup_resources()->set_limit(limit);
994 request.mutable_lookup_resources()->set_retrieve_instances_ids(instancesId != NULL); 994 request.mutable_lookup_resources()->set_retrieve_instances_ids(instancesId != NULL);
995 995
996 request.mutable_lookup_resources()->mutable_lookup()->Reserve(lookup.size()); 996 request.mutable_lookup_resources()->mutable_lookup()->Reserve(lookup.GetSize());
997 997
998 for (size_t i = 0; i < lookup.size(); i++) 998 for (size_t i = 0; i < lookup.GetSize(); i++)
999 { 999 {
1000 DatabasePluginMessages::DatabaseConstraint* constraint = request.mutable_lookup_resources()->add_lookup(); 1000 const DatabaseConstraint& source = lookup.GetConstraint(i);
1001 constraint->set_level(Convert(lookup[i].GetLevel())); 1001
1002 constraint->set_tag_group(lookup[i].GetTag().GetGroup()); 1002 DatabasePluginMessages::DatabaseConstraint* target = request.mutable_lookup_resources()->add_lookup();
1003 constraint->set_tag_element(lookup[i].GetTag().GetElement()); 1003 target->set_level(Convert(source.GetLevel()));
1004 constraint->set_is_identifier_tag(lookup[i].IsIdentifier()); 1004 target->set_tag_group(source.GetTag().GetGroup());
1005 constraint->set_is_case_sensitive(lookup[i].IsCaseSensitive()); 1005 target->set_tag_element(source.GetTag().GetElement());
1006 constraint->set_is_mandatory(lookup[i].IsMandatory()); 1006 target->set_is_identifier_tag(source.IsIdentifier());
1007 1007 target->set_is_case_sensitive(source.IsCaseSensitive());
1008 constraint->mutable_values()->Reserve(lookup[i].GetValuesCount()); 1008 target->set_is_mandatory(source.IsMandatory());
1009 for (size_t j = 0; j < lookup[i].GetValuesCount(); j++) 1009
1010 target->mutable_values()->Reserve(source.GetValuesCount());
1011 for (size_t j = 0; j < source.GetValuesCount(); j++)
1010 { 1012 {
1011 constraint->add_values(lookup[i].GetValue(j)); 1013 target->add_values(source.GetValue(j));
1012 } 1014 }
1013 1015
1014 switch (lookup[i].GetConstraintType()) 1016 switch (source.GetConstraintType())
1015 { 1017 {
1016 case ConstraintType_Equal: 1018 case ConstraintType_Equal:
1017 constraint->set_type(DatabasePluginMessages::CONSTRAINT_EQUAL); 1019 target->set_type(DatabasePluginMessages::CONSTRAINT_EQUAL);
1018 break; 1020 break;
1019 1021
1020 case ConstraintType_SmallerOrEqual: 1022 case ConstraintType_SmallerOrEqual:
1021 constraint->set_type(DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL); 1023 target->set_type(DatabasePluginMessages::CONSTRAINT_SMALLER_OR_EQUAL);
1022 break; 1024 break;
1023 1025
1024 case ConstraintType_GreaterOrEqual: 1026 case ConstraintType_GreaterOrEqual:
1025 constraint->set_type(DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL); 1027 target->set_type(DatabasePluginMessages::CONSTRAINT_GREATER_OR_EQUAL);
1026 break; 1028 break;
1027 1029
1028 case ConstraintType_Wildcard: 1030 case ConstraintType_Wildcard:
1029 constraint->set_type(DatabasePluginMessages::CONSTRAINT_WILDCARD); 1031 target->set_type(DatabasePluginMessages::CONSTRAINT_WILDCARD);
1030 break; 1032 break;
1031 1033
1032 case ConstraintType_List: 1034 case ConstraintType_List:
1033 constraint->set_type(DatabasePluginMessages::CONSTRAINT_LIST); 1035 target->set_type(DatabasePluginMessages::CONSTRAINT_LIST);
1034 break; 1036 break;
1035 1037
1036 default: 1038 default:
1037 throw OrthancException(ErrorCode_ParameterOutOfRange); 1039 throw OrthancException(ErrorCode_ParameterOutOfRange);
1038 } 1040 }