From eb830bfda2a18618032434aa7ebe3501bca2cca7 Mon Sep 17 00:00:00 2001 From: ktimoney Date: Tue, 27 Apr 2021 11:26:09 +0100 Subject: Add correct filter type prefix to query Added unit tests Issue-ID: POLICY-3247 Change-Id: I27474948619b7256a1e504611531eecac15c27c1 Signed-off-by: ktimoney --- models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java | 3 ++- .../java/org/onap/policy/models/dao/impl/PfNonTimestampKeyFilter.java | 2 ++ .../org/onap/policy/models/dao/impl/PfReferenceTimestampKeyFilter.java | 2 ++ .../java/org/onap/policy/models/dao/impl/PfTimestampKeyFilter.java | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) (limited to 'models-dao/src/main/java') diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java b/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java index ef9d4f939..fbe81b3ff 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java @@ -38,6 +38,7 @@ public abstract class PfFilter { private String timeStampEndFilter; private String timeStampFilter; private String nameParameter; + private String keyPrefix; /** * Generates filter string. @@ -59,7 +60,7 @@ public abstract class PfFilter { StringBuilder filterQueryString = new StringBuilder(inputFilterString); if (filterMap != null) { for (String key : filterMap.keySet()) { - filterQueryString.append("c." + key + "= :" + key + AND); + filterQueryString.append(getKeyPrefix() + key + "= :" + key + AND); } } diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfNonTimestampKeyFilter.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfNonTimestampKeyFilter.java index 9c9a3e844..ac3224022 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfNonTimestampKeyFilter.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfNonTimestampKeyFilter.java @@ -32,6 +32,7 @@ public class PfNonTimestampKeyFilter extends PfFilter { private static final String TIMESTAMP_END_FILTER = "c.timeStamp <= :endTime"; private static final String TIMESTAMP_FILTER = " c.timeStamp "; private static final String NAME_PARAMETER = "name"; + private static final String KEY_PREFIX = "c."; /** * The default constructor injects query strings. @@ -42,5 +43,6 @@ public class PfNonTimestampKeyFilter extends PfFilter { setTimeStampEndFilter(TIMESTAMP_END_FILTER); setTimeStampFilter(TIMESTAMP_FILTER); setNameParameter(NAME_PARAMETER); + setKeyPrefix(KEY_PREFIX); } } diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfReferenceTimestampKeyFilter.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfReferenceTimestampKeyFilter.java index 53802f306..42b05c19b 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfReferenceTimestampKeyFilter.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfReferenceTimestampKeyFilter.java @@ -32,6 +32,7 @@ public class PfReferenceTimestampKeyFilter extends PfFilter { private static final String TIMESTAMP_END_FILTER = "c.key.timeStamp <= :endTime"; private static final String TIMESTAMP_FILTER = " c.key.timeStamp "; private static final String NAME_PARAMETER = "parentKeyName"; + private static final String KEY_PREFIX = "c.key.referenceKey."; /** * The default constructor injects query strings. @@ -42,5 +43,6 @@ public class PfReferenceTimestampKeyFilter extends PfFilter { setTimeStampEndFilter(TIMESTAMP_END_FILTER); setTimeStampFilter(TIMESTAMP_FILTER); setNameParameter(NAME_PARAMETER); + setKeyPrefix(KEY_PREFIX); } } diff --git a/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfTimestampKeyFilter.java b/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfTimestampKeyFilter.java index f01f80498..f8d4fa833 100644 --- a/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfTimestampKeyFilter.java +++ b/models-dao/src/main/java/org/onap/policy/models/dao/impl/PfTimestampKeyFilter.java @@ -32,6 +32,7 @@ public class PfTimestampKeyFilter extends PfFilter { private static final String TIMESTAMP_END_FILTER = "c.key.timeStamp <= :endTime"; private static final String TIMESTAMP_FILTER = " c.key.timeStamp "; private static final String NAME_PARAMETER = "name"; + private static final String KEY_PREFIX = "c."; /** * The default constructor injects query strings. @@ -42,5 +43,6 @@ public class PfTimestampKeyFilter extends PfFilter { setTimeStampEndFilter(TIMESTAMP_END_FILTER); setTimeStampFilter(TIMESTAMP_FILTER); setNameParameter(NAME_PARAMETER); + setKeyPrefix(KEY_PREFIX); } } -- cgit 1.2.3-korg