diff --git a/Framework/Core/src/DataDescriptorQueryBuilder.cxx b/Framework/Core/src/DataDescriptorQueryBuilder.cxx index 2edbb4f84be5d..d498353b784ec 100644 --- a/Framework/Core/src/DataDescriptorQueryBuilder.cxx +++ b/Framework/Core/src/DataDescriptorQueryBuilder.cxx @@ -115,6 +115,14 @@ std::vector DataDescriptorQueryBuilder::parse(char const* config) auto lastMatcher = std::make_unique(DataDescriptorMatcher::Op::Just, StartTimeValueMatcher(ContextRef{0})); + size_t extraNodes = 0; + if (nodes.size() <= 1) { + nodes.push_back(DescriptionValueMatcher{ContextRef{++extraNodes}}); + } + if (nodes.size() <= 2) { + nodes.push_back(SubSpecificationTypeValueMatcher{ContextRef{++extraNodes}}); + } + for (size_t ni = 0, ne = nodes.size(); ni < ne; ++ni) { auto& node = nodes[nodes.size() - 1 - ni]; auto tmp = std::make_unique(DataDescriptorMatcher::Op::And, @@ -187,6 +195,8 @@ std::vector DataDescriptorQueryBuilder::parse(char const* config) case IN_END_DESCRIPTION: { if (assignLastStringMatch("description", 16, currentDescription, IN_BEGIN_SUBSPEC)) { nodes.push_back(DescriptionValueMatcher{*currentDescription}); + } else { + nodes.push_back(DescriptionValueMatcher{ContextRef{1}}); } } break; case IN_BEGIN_SUBSPEC: { @@ -196,6 +206,8 @@ std::vector DataDescriptorQueryBuilder::parse(char const* config) case IN_END_SUBSPEC: { if (assignLastNumericMatch("subspec", currentSubSpec, IN_BEGIN_TIMEMODULO)) { nodes.push_back(SubSpecificationTypeValueMatcher{*currentSubSpec}); + } else { + nodes.push_back(SubSpecificationTypeValueMatcher{ContextRef{2}}); } } break; case IN_BEGIN_TIMEMODULO: { diff --git a/Framework/Core/test/test_DataDescriptorMatcher.cxx b/Framework/Core/test/test_DataDescriptorMatcher.cxx index 6501a31a7e705..66b310ebd7eae 100644 --- a/Framework/Core/test/test_DataDescriptorMatcher.cxx +++ b/Framework/Core/test/test_DataDescriptorMatcher.cxx @@ -605,3 +605,43 @@ BOOST_AUTO_TEST_CASE(DataQuery) << DataDescriptorMatcher::Op::Just; BOOST_CHECK_EQUAL(ops.str(), "andorxorjust"); } + +BOOST_AUTO_TEST_CASE(CheckOriginWildcard) +{ + auto result0 = DataDescriptorQueryBuilder::parse("x:TST"); + BOOST_CHECK_EQUAL(result0.size(), 1); + DataDescriptorMatcher expectedMatcher00{ + DataDescriptorMatcher::Op::And, + OriginValueMatcher{"TST"}, + std::make_unique( + DataDescriptorMatcher::Op::And, + DescriptionValueMatcher{ContextRef{1}}, + std::make_unique( + DataDescriptorMatcher::Op::And, + SubSpecificationTypeValueMatcher{ContextRef{2}}, + std::make_unique(DataDescriptorMatcher::Op::Just, + StartTimeValueMatcher{ContextRef{0}})))}; + auto matcher = std::get_if(&result0[0].matcher); + BOOST_REQUIRE(matcher != nullptr); + BOOST_CHECK_EQUAL(expectedMatcher00, *matcher); +} + +BOOST_AUTO_TEST_CASE(CheckOriginDescriptionWildcard) +{ + auto result0 = DataDescriptorQueryBuilder::parse("x:TST/A"); + BOOST_CHECK_EQUAL(result0.size(), 1); + DataDescriptorMatcher expectedMatcher00{ + DataDescriptorMatcher::Op::And, + OriginValueMatcher{"TST"}, + std::make_unique( + DataDescriptorMatcher::Op::And, + DescriptionValueMatcher{"A"}, + std::make_unique( + DataDescriptorMatcher::Op::And, + SubSpecificationTypeValueMatcher{ContextRef{1}}, + std::make_unique(DataDescriptorMatcher::Op::Just, + StartTimeValueMatcher{ContextRef{0}})))}; + auto matcher = std::get_if(&result0[0].matcher); + BOOST_REQUIRE(matcher != nullptr); + BOOST_CHECK_EQUAL(expectedMatcher00, *matcher); +}