aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src
diff options
context:
space:
mode:
authorning.xi <ning.xi@est.tech>2019-12-26 21:37:52 +0800
committerning.xi <ning.xi@est.tech>2020-01-08 11:15:36 +0800
commit86374588a6103114b1f0f335a1b65da1ad0817a5 (patch)
tree5256c00f48e6c145bbf670db64e7dbc9e2dbe14d /models-pdp/src
parentf69b6681486e4d1c5859f649a3293488c1859712 (diff)
update Db provider to support query number
Issue-ID: POLICY-1629 Signed-off-by: ning.xi <ning.xi@est.tech> Change-Id: I42c9542adc44d52b760a70e710ab4cc6fa8a1b3b
Diffstat (limited to 'models-pdp/src')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java
index f149a3602..3b1718090 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@ public class PdpStatisticsProvider {
// Recurring string constants
private static final String NOT_VALID = "\" is not valid \n";
+ private static final String DESC_ORDER = "DESC";
/**
* Get PDP statistics.
@@ -84,12 +85,14 @@ public class PdpStatisticsProvider {
* @param pdpSubGroup pdpSubGroupType name to filter statistics
* @param startTimeStamp startTimeStamp to filter statistics
* @param endTimeStamp endTimeStamp to filter statistics
+ * @param sortOrder sortOrder to query database
+ * @param getRecordNum Total query count from database
* @return the PDP statistics found
* @throws PfModelException on errors getting policies
*/
public List<PdpStatistics> getFilteredPdpStatistics(@NonNull final PfDao dao, final String name,
@NonNull final String pdpGroupName, final String pdpSubGroup, final Date startTimeStamp,
- final Date endTimeStamp) {
+ final Date endTimeStamp, final String sortOrder, final int getRecordNum) {
Map<String, Object> filterMap = new HashMap<>();
filterMap.put("pdpGroupName", pdpGroupName);
if (pdpSubGroup != null) {
@@ -97,7 +100,7 @@ public class PdpStatisticsProvider {
}
return asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class, name, PfKey.NULL_KEY_VERSION, startTimeStamp,
- endTimeStamp, filterMap));
+ endTimeStamp, filterMap, sortOrder, getRecordNum));
}
/**
@@ -187,8 +190,8 @@ public class PdpStatisticsProvider {
*/
public List<PdpStatistics> deletePdpStatistics(@NonNull final PfDao dao, @NonNull final String name,
final Date timestamp) {
- List<PdpStatistics> pdpStatisticsListToDel = asPdpStatisticsList(
- dao.getFiltered(JpaPdpStatistics.class, name, PfKey.NULL_KEY_VERSION, timestamp, timestamp, null));
+ List<PdpStatistics> pdpStatisticsListToDel = asPdpStatisticsList(dao.getFiltered(JpaPdpStatistics.class, name,
+ PfKey.NULL_KEY_VERSION, timestamp, timestamp, null, DESC_ORDER, 0));
pdpStatisticsListToDel.stream().forEach(s -> dao.delete(JpaPdpStatistics.class,
new PfTimestampKey(s.getPdpInstanceId(), PfKey.NULL_KEY_VERSION, s.getTimeStamp())));