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