X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ri%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Fspi%2Frepository%2FFragmentRepository.java;h=b896fe86d01b58db3088c565995d9006593526e9;hb=efe679def187d07560601a3ff3beb719755b3d7a;hp=eb2e82b6c9b955d5bce14e8e69d0d20473c42a7d;hpb=98c078768b2ee6c8ce1a910f42ce46845eacc2c1;p=cps.git 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 eb2e82b6c..b896fe86d 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 @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2020-201 Nordix Foundation. All rights reserved. - * Modifications Copyright (C) 2020 Bell Canada. All rights reserved. + * Modifications Copyright (C) 2020-2021 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,4 +66,11 @@ public interface FragmentRepository extends JpaRepository // Above query will match the anchor id and last descendant name 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) + // 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, + @Param("descendantName") String descendantName, @Param("leafDataAsJson") String leafDataAsJson); }