aboutsummaryrefslogtreecommitdiffstats
path: root/models-dao/src/main/java
diff options
context:
space:
mode:
authorktimoney <kevin.timoney@est.tech>2021-04-27 11:26:09 +0100
committerktimoney <kevin.timoney@est.tech>2021-04-27 16:17:43 +0100
commiteb830bfda2a18618032434aa7ebe3501bca2cca7 (patch)
treea1222d4b4d2f66e436ee6499b1f842d68982f516 /models-dao/src/main/java
parent6e589fc31f69482d2cf5bf57c733094394439b0f (diff)
Add correct filter type prefix to query
Added unit tests Issue-ID: POLICY-3247 Change-Id: I27474948619b7256a1e504611531eecac15c27c1 Signed-off-by: ktimoney <kevin.timoney@est.tech>
Diffstat (limited to 'models-dao/src/main/java')
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/PfFilter.java3
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/PfNonTimestampKeyFilter.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/PfReferenceTimestampKeyFilter.java2
-rw-r--r--models-dao/src/main/java/org/onap/policy/models/dao/impl/PfTimestampKeyFilter.java2
4 files changed, 8 insertions, 1 deletions
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);
}
}