From ed19ece1be53159e265a0e400e2618ef0bd8721a Mon Sep 17 00:00:00 2001 From: rameshiyer27 Date: Tue, 9 Mar 2021 12:49:39 +0000 Subject: Add support for localName based filtering in PfReferenceTimestamp key. Issue : Currently we have a requirement to filter control loop statistics based on the UUID of the element which is "localName" of the PfREferenceTimestamp key. Adding UUID as part of filterMap in getFiltered() method which also requires this minor change in buildFilter. Issue-ID: POLICY-3051 Signed-off-by: zrrmmua Change-Id: Idb9f4fc47c439f84bf8fc784bd9e228a2e05d8e9 --- .../java/org/onap/policy/models/dao/impl/DefaultPfDao.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'models-dao/src/main/java') diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java index ef86c177b..bdbc04e22 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/DefaultPfDao.java @@ -367,7 +367,7 @@ public class DefaultPfDao implements PfDao { try { if (filterMap != null) { - filterQueryString = buildFilter(filterMap, filterQueryString); + filterQueryString = buildFilter(filterMap, filterQueryString, isRefTimestampKey(someClass)); } filterQueryString = addKeyFilterString(filterQueryString, name, startTime, endTime, isRefTimestampKey(someClass)); @@ -425,10 +425,15 @@ public class DefaultPfDao implements PfDao { } } - private String buildFilter(final Map filterMap, String filterQueryString) { + private String buildFilter(final Map filterMap, String filterQueryString, + boolean isRefTimestampKey) { StringBuilder bld = new StringBuilder(filterQueryString); for (String key : filterMap.keySet()) { - bld.append("c." + key + "= :" + key + AND); + if (isRefTimestampKey) { + bld.append("c.key.referenceKey." + key + "= :" + key + AND); + } else { + bld.append("c." + key + "= :" + key + AND); + } } return bld.toString(); } -- cgit 1.2.3-korg