diff options
author | sebdet <sebastien.determe@intl.att.com> | 2021-02-16 14:53:43 +0100 |
---|---|---|
committer | S�bastien Determe <sebastien.determe@intl.att.com> | 2021-02-18 12:51:19 +0000 |
commit | a0a3a03686a386bf6def6f7da6de4d3f6a11ce61 (patch) | |
tree | e650166922cf34953ee3fd1810db8bb76e302f5f /src/main/java/org | |
parent | 3728547710dee7d4cbd02d8e6cfed2c1708e263c (diff) |
Introduce a new endpoint to create policy
One first part of the update is to create a policy version from an existing one (this is similar as the create new policy).
The policy-flow.xml has been refactored so that the same policy query is done for policies and loop related flows. A code has been added to remove fields from the UI that could be present (the PDP group info json enrichment)
Issue-ID: POLICY-2926
Signed-off-by: sebdet <sebastien.determe@intl.att.com>
Change-Id: Ia60c656a9b5100296042d3346d5c97c8dad5d041
Diffstat (limited to 'src/main/java/org')
-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 |