From a520d00e005db1b232b9dae0c70d4dc5d73b33e1 Mon Sep 17 00:00:00 2001 From: Ravi Mantena Date: Mon, 21 Dec 2020 11:31:55 -0500 Subject: BpGen refactor Code Quality Issue-ID: DCAEGEN2-2502 Issue-ID: DCAEGEN2-2502 Change-Id: If6e08f0bb88c9039fb27898d50d2645f79175ba4 Signed-off-by: Ravi Mantena --- .../service/common/PolicyNodeService.java | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java') diff --git a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java index 7f6c63d..43d819f 100644 --- a/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java +++ b/mod/bpgenerator/onap/src/main/java/org/onap/blueprintgenerator/service/common/PolicyNodeService.java @@ -41,31 +41,40 @@ import java.util.Map; /** * @author : Ravi Mantena - * @date 10/16/2020 - * Application: ONAP - Blueprint Generator - * Common ONAP Service used by ONAP and DMAAP Blueprint to add Policy Node + * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add Policy Node */ - - @Service("onapPolicyNodeService") public class PolicyNodeService { @Autowired private BlueprintHelperService blueprintHelperService; - // Method to add Policy Nodes and Inputs - public void addPolicyNodesAndInputs(OnapComponentSpec onapComponentSpec, Map nodeTemplate, Map> inputs) { + /** + * Creates Policy Nodes and Inputs + * + * @param onapComponentSpec OnapComponentSpec + * @param nodeTemplate Node Template + * @param inputs Inputs + * @return + */ + public void addPolicyNodesAndInputs( + OnapComponentSpec onapComponentSpec, + Map nodeTemplate, + Map> inputs) { List policyList = onapComponentSpec.getPolicyInfo().getTypePolicyList(); - for(TypePolicy policy: policyList){ + for (TypePolicy policy : policyList) { addPolicyNodesToNodeTemplate(policy, nodeTemplate); addPolicyInputs(policy, inputs); } } - private void addPolicyInputs(TypePolicy policy, Map> inputs) { + private void addPolicyInputs( + TypePolicy policy, Map> inputs) { String defaultValue = policy.getPolicy_id(); defaultValue = defaultValue != null ? defaultValue : ""; - inputs.put(policy.getNode_label() + "_policy_id", blueprintHelperService.createStringInput("policy_id", defaultValue)); + inputs.put( + policy.getNode_label() + "_policy_id", + blueprintHelperService.createStringInput("policy_id", defaultValue)); } private void addPolicyNodesToNodeTemplate(TypePolicy policy, Map nodeTemplate) { @@ -84,11 +93,16 @@ public class PolicyNodeService { return policyNodeProperties; } - // Method to add Policy Relationships + /** + * Creates Policy Relationships + * + * @param onapComponentSpec OnapComponentSpec + * @return + */ public List> getPolicyRelationships(OnapComponentSpec onapComponentSpec) { List> relationships = new ArrayList<>(); List policyList = onapComponentSpec.getPolicyInfo().getTypePolicyList(); - for(TypePolicy policy: policyList){ + for (TypePolicy policy : policyList) { Map relationship = new LinkedHashMap<>(); relationship.put("type", Constants.POLICY_RELATIONSHIP_TYPE); relationship.put("target", policy.getNode_label()); -- cgit 1.2.3-korg