From c676aaa086988e3d3859a15eab790c3e62331dec Mon Sep 17 00:00:00 2001 From: Arindam Mondal Date: Wed, 15 May 2019 13:46:12 +0900 Subject: Sonar fix too many method param sonar:https://sonar.onap.org/issues?resolved=false&rules=squid%3AS00107 Issue-ID: SO-1878 Change-Id: I458fd436a85c7b3fb2c6a9df4a2a94591c6f6982 Signed-off-by: arindamm --- .../tasks/ConfigBuildingBlocksDataObject.java | 155 +++++++++++++++++++++ .../workflow/tasks/WorkflowAction.java | 45 +++--- 2 files changed, 179 insertions(+), 21 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java (limited to 'bpmn/so-bpmn-tasks') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java new file mode 100644 index 0000000000..1852485083 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ConfigBuildingBlocksDataObject.java @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import java.util.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; +import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; + +public class ConfigBuildingBlocksDataObject { + + private ServiceInstancesRequest sIRequest; + private List orchFlows; + private String requestId; + private Resource resourceKey; + private String apiVersion; + private String resourceId; + private String requestAction; + private boolean aLaCarte; + private String vnfType; + private WorkflowResourceIds workflowResourceIds; + private RequestDetails requestDetails; + private DelegateExecution execution; + + public ServiceInstancesRequest getsIRequest() { + return sIRequest; + } + + public ConfigBuildingBlocksDataObject setsIRequest(ServiceInstancesRequest sIRequest) { + this.sIRequest = sIRequest; + return this; + } + + public List getOrchFlows() { + return orchFlows; + } + + public ConfigBuildingBlocksDataObject setOrchFlows(List orchFlows) { + this.orchFlows = orchFlows; + return this; + } + + public String getRequestId() { + return requestId; + } + + public ConfigBuildingBlocksDataObject setRequestId(String requestId) { + this.requestId = requestId; + return this; + } + + public Resource getResourceKey() { + return resourceKey; + } + + public ConfigBuildingBlocksDataObject setResourceKey(Resource resourceKey) { + this.resourceKey = resourceKey; + return this; + } + + public String getApiVersion() { + return apiVersion; + } + + public ConfigBuildingBlocksDataObject setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + public String getResourceId() { + return resourceId; + } + + public ConfigBuildingBlocksDataObject setResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + public String getRequestAction() { + return requestAction; + } + + public ConfigBuildingBlocksDataObject setRequestAction(String requestAction) { + this.requestAction = requestAction; + return this; + } + + public boolean isaLaCarte() { + return aLaCarte; + } + + public ConfigBuildingBlocksDataObject setaLaCarte(boolean aLaCarte) { + this.aLaCarte = aLaCarte; + return this; + } + + public String getVnfType() { + return vnfType; + } + + public ConfigBuildingBlocksDataObject setVnfType(String vnfType) { + this.vnfType = vnfType; + return this; + } + + public WorkflowResourceIds getWorkflowResourceIds() { + return workflowResourceIds; + } + + public ConfigBuildingBlocksDataObject setWorkflowResourceIds(WorkflowResourceIds workflowResourceIds) { + this.workflowResourceIds = workflowResourceIds; + return this; + } + + public RequestDetails getRequestDetails() { + return requestDetails; + } + + public ConfigBuildingBlocksDataObject setRequestDetails(RequestDetails requestDetails) { + this.requestDetails = requestDetails; + return this; + } + + public DelegateExecution getExecution() { + return execution; + } + + public ConfigBuildingBlocksDataObject setExecution(DelegateExecution execution) { + this.execution = execution; + return this; + } + + + +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 2fc301f9d7..563246f87c 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -216,9 +216,13 @@ public class WorkflowAction { boolean isConfiguration = isConfiguration(orchFlows); Resource resourceKey = new Resource(resourceType, key, aLaCarte); if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - List configBuildingBlocks = getConfigBuildingBlocks(sIRequest, orchFlows, - requestId, resourceKey, apiVersion, resourceId, requestAction, aLaCarte, vnfType, - workflowResourceIds, requestDetails, execution); + List configBuildingBlocks = getConfigBuildingBlocks( + new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) + .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte) + .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) + .setRequestDetails(requestDetails).setExecution(execution)); + flowsToExecute.addAll(configBuildingBlocks); } orchFlows = orchFlows.stream().filter(item -> !item.getFlowName().contains(FABRIC_CONFIGURATION)) @@ -327,7 +331,8 @@ public class WorkflowAction { } } - // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is specified, + // If the user set "Homing_Solution" to "none", disable homing, else if "Homing_Solution" is + // specified, // enable it. if (sIRequest.getRequestDetails().getRequestParameters() != null && sIRequest.getRequestDetails().getRequestParameters().getUserParams() != null) { @@ -422,17 +427,14 @@ public class WorkflowAction { return false; } - protected List getConfigBuildingBlocks(ServiceInstancesRequest sIRequest, - List orchFlows, String requestId, Resource resourceKey, String apiVersion, - String resourceId, String requestAction, boolean aLaCarte, String vnfType, - WorkflowResourceIds workflowResourceIds, RequestDetails requestDetails, DelegateExecution execution) { + protected List getConfigBuildingBlocks(ConfigBuildingBlocksDataObject dataObj) { List flowsToExecuteConfigs = new ArrayList<>(); - List result = new ArrayList<>(orchFlows); - result = orchFlows.stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)) + List result = new ArrayList<>(dataObj.getOrchFlows()); + result = dataObj.getOrchFlows().stream().filter(item -> item.getFlowName().contains(FABRIC_CONFIGURATION)) .collect(Collectors.toList()); - String vnfId = workflowResourceIds.getVnfId(); - String vfModuleId = workflowResourceIds.getVfModuleId(); + String vnfId = dataObj.getWorkflowResourceIds().getVnfId(); + String vfModuleId = dataObj.getWorkflowResourceIds().getVfModuleId(); String vnfCustomizationUUID = bbInputSetupUtils.getAAIGenericVnf(vnfId).getModelCustomizationId(); String vfModuleCustomizationUUID = @@ -446,21 +448,22 @@ public class WorkflowAction { if (configurations.size() > 1) { String multipleRelationshipsError = "Multiple relationships exist from VNFC " + vnfc.getVnfcName() + " to Configurations"; - buildAndThrowException(execution, multipleRelationshipsError, + buildAndThrowException(dataObj.getExecution(), multipleRelationshipsError, new Exception(multipleRelationshipsError)); } for (org.onap.aai.domain.yang.Configuration configuration : configurations) { - workflowResourceIds.setConfigurationId(configuration.getConfigurationId()); + dataObj.getWorkflowResourceIds().setConfigurationId(configuration.getConfigurationId()); for (OrchestrationFlow orchFlow : result) { - resourceKey.setVfModuleCustomizationId(vfModuleCustomizationUUID); - resourceKey.setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); - resourceKey.setVnfCustomizationId(vnfCustomizationUUID); - ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, apiVersion, - resourceId, requestAction, aLaCarte, vnfType, workflowResourceIds, requestDetails, false, - null, true); + dataObj.getResourceKey().setVfModuleCustomizationId(vfModuleCustomizationUUID); + dataObj.getResourceKey().setCvnfModuleCustomizationId(vnfc.getModelCustomizationId()); + dataObj.getResourceKey().setVnfCustomizationId(vnfCustomizationUUID); + ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, dataObj.getRequestId(), + dataObj.getResourceKey(), dataObj.getApiVersion(), dataObj.getResourceId(), + dataObj.getRequestAction(), dataObj.isaLaCarte(), dataObj.getVnfType(), + dataObj.getWorkflowResourceIds(), dataObj.getRequestDetails(), false, null, true); String vnfcName = getVnfcNameForConfiguration(configuration); if (vnfcName == null || vnfcName.isEmpty()) { - buildAndThrowException(execution, "Exception in create execution list " + buildAndThrowException(dataObj.getExecution(), "Exception in create execution list " + ": VnfcName does not exist or is null while there is a configuration for the vfModule", new Exception("Vnfc and Configuration do not match")); } -- cgit 1.2.3-korg