From a4cc3554804540b49d9b778f75b158d6c1ec5899 Mon Sep 17 00:00:00 2001 From: "puthuparambil.aditya" Date: Wed, 28 Apr 2021 16:39:32 +0100 Subject: Fix Get descendent to support xpaths that end in list values Issue-ID: CPS-367 Signed-off-by: puthuparambil.aditya Change-Id: I3234afd8b8b69c5a3c87db1669d9b304f9fcaa49 --- .../main/java/org/onap/cps/spi/repository/FragmentRepository.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cps-ri/src/main/java/org') diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java index 74d04613d..b9874484c 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java @@ -76,8 +76,9 @@ public interface FragmentRepository extends JpaRepository List getByAnchorAndXpathEndsInDescendantName(@Param("anchor") int anchorId, @Param("descendantName") String descendantName); - @Query(value = "SELECT * FROM FRAGMENT WHERE anchor_id = :anchor AND xpath LIKE CONCAT('%/',:descendantName) " - + "AND attributes @> :leafDataAsJson\\:\\:jsonb", nativeQuery = true) + @Query(value = "SELECT * FROM FRAGMENT WHERE anchor_id = :anchor AND (xpath LIKE CONCAT('%/',:descendantName) OR " + + "xpath LIKE CONCAT('%/', :descendantName,'\\[@%]')) AND attributes @> :leafDataAsJson\\:\\:jsonb", + nativeQuery = true) // Above query will match the anchor id, last descendant name and all parameters passed into leafDataASJson with the // attribute values of the requested data node eg: {"leaf_name":"value", "another_leaf_name":"another value"}​​​​​​ List getByAnchorAndDescendentNameAndLeafValues(@Param("anchor") int anchorId, -- cgit 1.2.3-korg