diff options
author | 2023-04-17 14:19:46 +0530 | |
---|---|---|
committer | 2023-04-21 13:44:18 +0530 | |
commit | d7bc158cd274b3d6cd01bcad86aef258e6880c1c (patch) | |
tree | c94fa03528b6ed4fbb2672267482542dd59f7b73 /cps-ri/src/main/java/org | |
parent | c4621cbcb1f9aad97ba3389468546444d1e9f3dc (diff) |
Add contains condition support to cps-path
Issue-ID: CPS-1272
Change-Id: Ic81d1322cacc64a8752916324b801d02be47d34f
Signed-off-by: Rudrangi Anupriya <ra00745022@techmahindra.com>
Diffstat (limited to 'cps-ri/src/main/java/org')
-rw-r--r-- | cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentQueryBuilder.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentQueryBuilder.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentQueryBuilder.java index ca6e18bad..ab9c02e88 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentQueryBuilder.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentQueryBuilder.java @@ -98,6 +98,7 @@ public class FragmentQueryBuilder { sqlStringBuilder.append(")"); } addTextFunctionCondition(cpsPathQuery, sqlStringBuilder, queryParameters); + addContainsFunctionCondition(cpsPathQuery, sqlStringBuilder, queryParameters); final Query query = entityManager.createNativeQuery(sqlStringBuilder.toString(), FragmentEntity.class); setQueryParameters(query, queryParameters); return query; @@ -160,6 +161,16 @@ public class FragmentQueryBuilder { } } + private static void addContainsFunctionCondition(final CpsPathQuery cpsPathQuery, + final StringBuilder sqlStringBuilder, + final Map<String, Object> queryParameters) { + if (cpsPathQuery.hasContainsFunctionCondition()) { + sqlStringBuilder.append(" AND attributes ->> :containsLeafName LIKE CONCAT('%',:containsValue,'%') "); + queryParameters.put("containsLeafName", cpsPathQuery.getContainsFunctionConditionLeafName()); + queryParameters.put("containsValue", cpsPathQuery.getContainsFunctionConditionValue()); + } + } + private static void setQueryParameters(final Query query, final Map<String, Object> queryParameters) { for (final Map.Entry<String, Object> queryParameter : queryParameters.entrySet()) { query.setParameter(queryParameter.getKey(), queryParameter.getValue()); |