diff options
author | Jim Hahn <jrh3@att.com> | 2020-01-09 13:58:02 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-09 13:58:02 +0000 |
commit | ca0e6bd8fcc79dd3a681fbb158017e6a5f5397f5 (patch) | |
tree | 377e7605e46183ae245d39ffb868274f4bf2ede8 /models-pdp/src/main | |
parent | 2ed313e69cfd0a587f072079e23ab8f6499518db (diff) | |
parent | 86374588a6103114b1f0f335a1b65da1ad0817a5 (diff) |
Merge "update Db provider to support query number"
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r-- | models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpStatisticsProvider.java | 13 |
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()))); |