summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java
diff options
context:
space:
mode:
Diffstat (limited to 'cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java')
-rwxr-xr-xcps-ri/src/main/java/org/onap/cps/spi/repository/FragmentRepository.java10
1 files changed, 7 insertions, 3 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 a40168a9d..5ff7cfc97 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
@@ -55,9 +55,13 @@ public interface FragmentRepository extends JpaRepository<FragmentEntity, Long>
@Query(value =
"SELECT * FROM FRAGMENT WHERE (anchor_id = :anchor) AND (xpath = (:xpath) OR xpath LIKE "
+ "CONCAT(:xpath,'\\[@%]')) AND attributes @> jsonb_build_object(:leafName , :leafValue)",
- nativeQuery = true)
- // Above query will match an xpath with or without the index for a list [@key=value]
- // and match anchor id, leaf name and leaf value
+ nativeQuery = true)
+ // Above query will match an xpath with or without the index for a list [@key=value] and match anchor id,
+ // leaf name and leaf value
List<FragmentEntity> getByAnchorAndXpathAndLeafAttributes(@Param("anchor") int anchorId, @Param("xpath")
String xpathPrefix, @Param("leafName") String leafName, @Param("leafValue") Object leafValue);
+
+ @Query(value = "SELECT * FROM FRAGMENT WHERE anchor_id = :anchor AND xpath LIKE %:xpath", nativeQuery = true)
+ // Above query will match the end of an xpath and anchor id
+ List<FragmentEntity> getByAnchorAndEndsWithXpath(@Param("anchor") int anchorId, @Param("xpath") String xpath);
} \ No newline at end of file