summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2021-04-28 16:39:32 +0100
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2021-04-30 10:45:53 +0100
commita4cc3554804540b49d9b778f75b158d6c1ec5899 (patch)
treee352e909ac9f098e6c6bdc98c668f750e6d2d235 /cps-ri/src/main
parent6da081cc0667795cd7872582a8795cf0bbd56c17 (diff)
Fix Get descendent to support xpaths that end in list values
Issue-ID: CPS-367 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: I3234afd8b8b69c5a3c87db1669d9b304f9fcaa49
Diffstat (limited to 'cps-ri/src/main')
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java5
1 files changed, 3 insertions, 2 deletions
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 74d04613d9..b9874484c0 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<FragmentEntity, Long>
List<FragmentEntity> 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<FragmentEntity> getByAnchorAndDescendentNameAndLeafValues(@Param("anchor") int anchorId,