summaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main/java
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-07 00:20:08 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-07 00:20:08 +0000
commit82699a970d5f06c6dc1391d8beb0efe76bf84089 (patch)
tree7b044561032482b0fbb7c47e92139a3f4fb84314 /models-pdp/src/main/java
parentc7ebd4c91bdbf00faed2b9935b818c781803edd1 (diff)
parent422412ec8f21017aff1641f133c2258f52f7d706 (diff)
Merge "Fix bugs on filters"
Diffstat (limited to 'models-pdp/src/main/java')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java26
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java2
2 files changed, 26 insertions, 2 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
index c5c0bc541..5965b728d 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
@@ -68,11 +68,12 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
// @formatter:off
List<PdpGroup> returnList = originalList.stream()
.filter(p -> filterOnRegexp(p.getName(), name))
- .filter(p -> filterOnRegexp(p.getVersion(), version))
+ .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version))
.filter(p -> ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0)
.filter(p -> filterOnPdpType(p, pdpType))
.filter(p -> filterOnPolicyType(p, policyType))
.filter(p -> filterOnPolicy(p, policy))
+ .filter(p -> filterOnPdpState(p, pdpState))
.collect(Collectors.toList());
// @formatter:off
@@ -151,4 +152,27 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
return false;
}
+
+ /**
+ * Filter PDP groups on PDP state.
+ *
+ * @param pdpGroup the PDP group to check
+ * @param policyFilter the policy regular expressions to check for
+ * @return true if the filter should let this PDP group through
+ */
+ private boolean filterOnPdpState(final PdpGroup pdpGroup, final PdpState pdpState) {
+ if (pdpState == null) {
+ return true;
+ }
+
+ for (PdpSubGroup pdpSubGroup: pdpGroup.getPdpSubgroups()) {
+ for (Pdp pdp : pdpSubGroup.getPdpInstances()) {
+ if (pdpState.equals(pdp.getPdpState())) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
}
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
index a1eb97dd0..bef3f1547 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/provider/PdpProvider.java
@@ -111,7 +111,7 @@ public class PdpProvider {
List<JpaPdpGroup> jpaPdpGroupList = dao.getAll(JpaPdpGroup.class);
- return asPdpGroupList(jpaPdpGroupList);
+ return filter.filter(asPdpGroupList(jpaPdpGroupList));
}
/**