summaryrefslogtreecommitdiffstats
path: root/models-pap/src/main/java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-07-12 18:34:41 +0000
committerGerrit Code Review <gerrit@onap.org>2021-07-12 18:34:41 +0000
commit886406e003934b83da7a2b538a0574a76fd5dd4d (patch)
tree737ab84301fa22e5c446b0f0d0e484e385294864 /models-pap/src/main/java
parent24b9a9a0f5a3c95c1ebb0c5d5316fdf05ef7f8dd (diff)
parentc9067692f47fc532a6306e3dd8f5df75d8828a7b (diff)
Merge "Handle numRecords default setting when built as 0."
Diffstat (limited to 'models-pap/src/main/java')
-rw-r--r--models-pap/src/main/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProvider.java49
1 files changed, 5 insertions, 44 deletions
diff --git a/models-pap/src/main/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProvider.java b/models-pap/src/main/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProvider.java
index 432e4c85e..7368d29c7 100644
--- a/models-pap/src/main/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProvider.java
+++ b/models-pap/src/main/java/org/onap/policy/models/pap/persistence/provider/PolicyAuditProvider.java
@@ -73,47 +73,18 @@ public class PolicyAuditProvider {
}
/**
- * Collect all audit records.
- *
- * @param numRecords number of records to be collected
- * @return list of {@link PolicyAudit} records
- */
- public List<PolicyAudit> getAuditRecords(@NonNull PfDao dao, @NonNull Integer numRecords) {
- numRecords = numRecords > DEFAULT_MAX_RECORDS ? DEFAULT_MAX_RECORDS : numRecords;
-
- // @formatter:off
- return dao.getAll(JpaPolicyAudit.class, "timeStamp DESC", numRecords)
- .stream()
- .map(JpaPolicyAudit::toAuthorative)
- .collect(Collectors.toList());
- // @formatter:on
- }
-
- /**
- * Collect audit records based on filters at {@link AuditFilter}.
- *
- * @param auditFilter {@link AuditFilter} object with filters for search
- * @param numRecords number of records to be collected
- * @return list of {@link PolicyAudit} records
- */
- public List<PolicyAudit> getAuditRecords(@NonNull PfDao dao, @NonNull AuditFilter auditFilter,
- @NonNull Integer numRecords) {
-
- auditFilter.setRecordNum(Math.min(numRecords, DEFAULT_MAX_RECORDS));
-
- return getAuditRecords(dao, auditFilter);
- }
-
- /**
* Collect audit records based on filters at {@link AuditFilter}.
*
* @param auditFilter {@link AuditFilter} object with filters for search
* @return list of {@link PolicyAudit} records
*/
public List<PolicyAudit> getAuditRecords(@NonNull PfDao dao, @NonNull AuditFilter auditFilter) {
+ if (auditFilter.getRecordNum() < 1 || auditFilter.getRecordNum() > DEFAULT_MAX_RECORDS) {
+ auditFilter.setRecordNum(DEFAULT_MAX_RECORDS);
+ }
- return dao.getFiltered(JpaPolicyAudit.class, auditFilter)
- .stream().map(JpaPolicyAudit::toAuthorative).collect(Collectors.toList());
+ return dao.getFiltered(JpaPolicyAudit.class, auditFilter).stream().map(JpaPolicyAudit::toAuthorative)
+ .collect(Collectors.toList());
}
/**
@@ -140,16 +111,6 @@ public class PolicyAuditProvider {
// initialized lazily, if not set via the builder
private Map<String, Object> filterMap;
- /**
- * Check if even still using build(), none of the params were provided.
- *
- * @return {@code true} if all empty/null; {@code false} otherwise.
- */
- public boolean isEmpty() {
- return StringUtils.isAllEmpty(name, version, pdpGroup) && action == null && fromDate == null
- && toDate == null;
- }
-
@Override
public Instant getStartTime() {
return fromDate;