diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java | 9 | ||||
-rw-r--r-- | src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java | 12 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java b/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java index 83ece5795..1d6d21977 100644 --- a/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java +++ b/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java @@ -36,10 +36,13 @@ import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier; /** - * This is an utility class to do searching in pdp groups. + * This is an utility class to do searching in pdp groups and create json object describing the result. */ public class PdpGroupsAnalyzer { + public static final String ASSIGNED_PDP_GROUPS_INFO = "pdpGroupInfo"; + public static final String SUPPORTED_PDP_GROUPS_INFO = "supportedPdpGroups"; + /** * Get supported subGroups based on the defined policy type and version for s specific PDPgroup. * It returns null if the Group is not ACTIVE or if the policytype/version has not been found in the PDPSubgroups. @@ -80,7 +83,7 @@ public class PdpGroupsAnalyzer { public static JsonObject getSupportedPdpGroupsForModelType(PdpGroups pdpGroups, String policyType, String version) { JsonObject supportedPdpGroups = new JsonObject(); JsonArray pdpGroupsArray = new JsonArray(); - supportedPdpGroups.add("supportedPdpGroups", pdpGroupsArray); + supportedPdpGroups.add(SUPPORTED_PDP_GROUPS_INFO, pdpGroupsArray); pdpGroups.getGroups().stream().map(pdpGroup -> PdpGroupsAnalyzer.getSupportedPdpSubgroupsForModelType(pdpGroup, policyType, version)).filter(Objects::nonNull) @@ -113,7 +116,7 @@ public class PdpGroupsAnalyzer { public static JsonObject getPdpGroupDeploymentOfOnePolicy(PdpGroups pdpGroups, String policyName, String version) { JsonObject pdpGroupInfo = new JsonObject(); JsonObject assignedPdpGroups = new JsonObject(); - pdpGroupInfo.add("pdpGroupInfo", assignedPdpGroups); + pdpGroupInfo.add(ASSIGNED_PDP_GROUPS_INFO, assignedPdpGroups); ToscaPolicyIdentifier toscaPolicyIdentifier = new ToscaPolicyIdentifier(policyName, version); pdpGroups.getGroups().stream().anyMatch(pdpGroup -> diff --git a/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java b/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java index 7e3fe8cf4..cf3c1656c 100644 --- a/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java +++ b/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java @@ -101,4 +101,16 @@ public class PoliciesPdpMerger { policyJsonNode.get("type_version").getAsString()); mergeJsonElement(policyJsonNode, supportedPdpGroupsJson); } + + /** + * This method removes the pdp States added for one policy. + * + * @param policyJsonNode The policy node in Json + */ + public static JsonObject removePdpStatesOnePolicy(JsonObject policyJsonNode) { + // Simply remove the nodes we have added. + policyJsonNode.remove(PdpGroupsAnalyzer.ASSIGNED_PDP_GROUPS_INFO); + policyJsonNode.remove(PdpGroupsAnalyzer.SUPPORTED_PDP_GROUPS_INFO); + return policyJsonNode; + } }
\ No newline at end of file |