summaryrefslogtreecommitdiffstats
path: root/models-pdp
diff options
context:
space:
mode:
Diffstat (limited to 'models-pdp')
-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())));