diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2020-06-26 09:39:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-06-26 09:39:33 +0000 |
commit | bd348d21b29a00e37f4828b5f0e967ceba0591f1 (patch) | |
tree | b124a2c1a879751353e5d7def91c954fff7b0ee0 /bpmn/so-bpmn-tasks/src/main | |
parent | d99ac569a32064d4b61475c73c9ff41aa93596a6 (diff) | |
parent | bd8108c98564c76aff752ccd64b18927342afc8c (diff) |
Merge "Workflow refactoring - revert changes"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
4 files changed, 133 insertions, 90 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java index a4ffb45370..415d4614da 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/activity/ExecuteActivity.java @@ -166,16 +166,10 @@ public class ExecuteActivity implements JavaDelegate { String bpmnRequest = (String) execution.getVariable(G_BPMN_REQUEST); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); RequestDetails requestDetails = sIRequest.getRequestDetails(); - ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); - executeBuildingBlock.setaLaCarte(true); - executeBuildingBlock.setRequestAction((String) execution.getVariable(G_ACTION)); - executeBuildingBlock.setResourceId((String) execution.getVariable(VNF_ID)); - executeBuildingBlock.setVnfType((String) execution.getVariable(VNF_TYPE)); - executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); - executeBuildingBlock.setRequestId(requestId); - executeBuildingBlock.setBuildingBlock(buildingBlock); - executeBuildingBlock.setRequestDetails(requestDetails); - return executeBuildingBlock; + return new ExecuteBuildingBlock().setaLaCarte(true).setRequestAction((String) execution.getVariable(G_ACTION)) + .setResourceId((String) execution.getVariable(VNF_ID)) + .setVnfType((String) execution.getVariable(VNF_TYPE)).setWorkflowResourceIds(workflowResourceIds) + .setRequestId(requestId).setBuildingBlock(buildingBlock).setRequestDetails(requestDetails); } protected void buildAndThrowException(DelegateExecution execution, String msg, Exception ex) { 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 index d22435c495..1852485083 100644 --- 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 @@ -20,48 +20,136 @@ 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.BuildingBlockBase; +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; -import java.util.List; -public class ConfigBuildingBlocksDataObject extends BuildingBlockBase { +public class ConfigBuildingBlocksDataObject { - private DelegateExecution execution; + private ServiceInstancesRequest sIRequest; private List<OrchestrationFlow> orchFlows; + private String requestId; private Resource resourceKey; - private ServiceInstancesRequest sIRequest; + 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 void setsIRequest(ServiceInstancesRequest sIRequest) { + public ConfigBuildingBlocksDataObject setsIRequest(ServiceInstancesRequest sIRequest) { this.sIRequest = sIRequest; + return this; } public List<OrchestrationFlow> getOrchFlows() { return orchFlows; } - public void setOrchFlows(List<OrchestrationFlow> orchFlows) { + public ConfigBuildingBlocksDataObject setOrchFlows(List<OrchestrationFlow> 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 void setResourceKey(Resource 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 void setExecution(DelegateExecution 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 99a825006e..a057fe0102 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 @@ -176,32 +176,25 @@ public class WorkflowAction { final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST); ServiceInstancesRequest sIRequest = new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class); - - final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID); - + RequestDetails requestDetails = sIRequest.getRequestDetails(); String uri = (String) execution.getVariable(BBConstants.G_URI); + final String requestId = (String) execution.getVariable(BBConstants.G_REQUEST_ID); + final boolean aLaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); boolean isResume = isUriResume(uri); - - final boolean isALaCarte = (boolean) execution.getVariable(BBConstants.G_ALACARTE); - Resource resource = getResource(bbInputSetupUtils, isResume, isALaCarte, uri, requestId); - - WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); - RequestDetails requestDetails = sIRequest.getRequestDetails(); String requestAction = (String) execution.getVariable(BBConstants.G_ACTION); + WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution); + Resource resource = getResource(bbInputSetupUtils, isResume, aLaCarte, uri, requestId); String resourceId = getResourceId(resource, requestAction, requestDetails, workflowResourceIds); WorkflowType resourceType = resource.getResourceType(); - String serviceInstanceId = getServiceInstanceId(execution, resourceId, resourceType); - fillExecution(execution, requestDetails.getRequestInfo().getSuppressRollback(), resourceId, resourceType); List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>(); - - if (isRequestMacroServiceResume(isALaCarte, resourceType, requestAction, serviceInstanceId)) { + if (isRequestMacroServiceResume(aLaCarte, resourceType, requestAction, serviceInstanceId)) { flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId); if (flowsToExecute == null) { buildAndThrowException(execution, "Could not resume Macro flow. Error loading execution path."); } - } else if (isALaCarte && isResume) { + } else if (aLaCarte && isResume) { flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId); if (flowsToExecute == null) { buildAndThrowException(execution, @@ -215,30 +208,20 @@ public class WorkflowAction { final String apiVersion = (String) execution.getVariable(BBConstants.G_APIVERSION); final String serviceType = Optional.ofNullable((String) execution.getVariable(BBConstants.G_SERVICE_TYPE)).orElse(""); - if (isALaCarte) { + if (aLaCarte) { if (orchFlows == null || orchFlows.isEmpty()) { orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, true, cloudOwner, serviceType); } Resource resourceKey = getResourceKey(sIRequest, resourceType); - if (isConfiguration(orchFlows) && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { - ConfigBuildingBlocksDataObject configBuildingBlocksDataObject = - new ConfigBuildingBlocksDataObject(); - configBuildingBlocksDataObject.setsIRequest(sIRequest); - configBuildingBlocksDataObject.setOrchFlows(orchFlows); - configBuildingBlocksDataObject.setRequestId(requestId); - configBuildingBlocksDataObject.setResourceKey(resourceKey); - configBuildingBlocksDataObject.setApiVersion(apiVersion); - configBuildingBlocksDataObject.setResourceId(resourceId); - configBuildingBlocksDataObject.setRequestAction(requestAction); - configBuildingBlocksDataObject.setaLaCarte(true); - configBuildingBlocksDataObject.setVnfType(vnfType); - configBuildingBlocksDataObject.setWorkflowResourceIds(workflowResourceIds); - configBuildingBlocksDataObject.setRequestDetails(requestDetails); - configBuildingBlocksDataObject.setExecution(execution); - - List<ExecuteBuildingBlock> configBuildingBlocks = - getConfigBuildingBlocks(configBuildingBlocksDataObject); + boolean isConfiguration = isConfiguration(orchFlows); + if (isConfiguration && !requestAction.equalsIgnoreCase(CREATEINSTANCE)) { + List<ExecuteBuildingBlock> configBuildingBlocks = getConfigBuildingBlocks( + new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) + .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) + .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) + .setRequestDetails(requestDetails).setExecution(execution)); flowsToExecute.addAll(configBuildingBlocks); } @@ -249,23 +232,12 @@ public class WorkflowAction { || requestAction.equalsIgnoreCase(REPLACEINSTANCERETAINASSIGNMENTS)) && resourceType.equals(WorkflowType.VFMODULE)) { logger.debug("Build a BB list for replacing BB modules"); - - ConfigBuildingBlocksDataObject configBuildingBlocksDataObject = - new ConfigBuildingBlocksDataObject(); - configBuildingBlocksDataObject.setsIRequest(sIRequest); - configBuildingBlocksDataObject.setOrchFlows(orchFlows); - configBuildingBlocksDataObject.setRequestId(requestId); - configBuildingBlocksDataObject.setResourceKey(resourceKey); - configBuildingBlocksDataObject.setApiVersion(apiVersion); - configBuildingBlocksDataObject.setResourceId(resourceId); - configBuildingBlocksDataObject.setRequestAction(requestAction); - configBuildingBlocksDataObject.setaLaCarte(true); - configBuildingBlocksDataObject.setVnfType(vnfType); - configBuildingBlocksDataObject.setWorkflowResourceIds(workflowResourceIds); - configBuildingBlocksDataObject.setRequestDetails(requestDetails); - configBuildingBlocksDataObject.setExecution(execution); - - orchFlows = getVfModuleReplaceBuildingBlocks(configBuildingBlocksDataObject); + orchFlows = getVfModuleReplaceBuildingBlocks( + new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest).setOrchFlows(orchFlows) + .setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion) + .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(true) + .setVnfType(vnfType).setWorkflowResourceIds(workflowResourceIds) + .setRequestDetails(requestDetails).setExecution(execution)); } for (OrchestrationFlow orchFlow : orchFlows) { ExecuteBuildingBlock ebb = buildExecuteBuildingBlock(orchFlow, requestId, resourceKey, @@ -347,7 +319,7 @@ public class WorkflowAction { logger.info("Found {}", foundObjects); if (orchFlows == null || orchFlows.isEmpty()) { - orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, isALaCarte, + orchFlows = queryNorthBoundRequestCatalogDb(execution, requestAction, resourceType, aLaCarte, cloudOwner, serviceType); } boolean vnfReplace = false; @@ -1466,16 +1438,10 @@ public class WorkflowAction { resourceId = workflowResourceIds.getVolumeGroupId(); } - ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); - executeBuildingBlock.setApiVersion(apiVersion); - executeBuildingBlock.setaLaCarte(aLaCarte); - executeBuildingBlock.setRequestAction(requestAction); - executeBuildingBlock.setResourceId(resourceId); - executeBuildingBlock.setVnfType(vnfType); - executeBuildingBlock.setWorkflowResourceIds(workflowResourceIds); - executeBuildingBlock.setRequestId(requestId); - executeBuildingBlock.setBuildingBlock(buildingBlock); - executeBuildingBlock.setRequestDetails(requestDetails); + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock().setApiVersion(apiVersion) + .setaLaCarte(aLaCarte).setRequestAction(requestAction).setResourceId(resourceId).setVnfType(vnfType) + .setWorkflowResourceIds(workflowResourceIds).setRequestId(requestId).setBuildingBlock(buildingBlock) + .setRequestDetails(requestDetails); if (resource != null && (isConfiguration || resource.getResourceType().equals(WorkflowType.CONFIGURATION))) { ConfigurationResourceKeys configurationResourceKeys = new ConfigurationResourceKeys(); diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java index 31df5bbdc3..9d68b5a3f0 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasks.java @@ -493,16 +493,11 @@ public class WorkflowActionBBTasks { WorkflowResourceIds workflowResourceIds = ebb.getWorkflowResourceIds(); workflowResourceIds.setConfigurationId(configurationId); - ExecuteBuildingBlock configBB = new ExecuteBuildingBlock(); - configBB.setaLaCarte(ebb.isaLaCarte()); - configBB.setApiVersion(ebb.getApiVersion()); - configBB.setRequestAction(ebb.getRequestAction()); - configBB.setVnfType(ebb.getVnfType()); - configBB.setRequestId(ebb.getRequestId()); - configBB.setRequestDetails(ebb.getRequestDetails()); - configBB.setBuildingBlock(buildingBlock); - configBB.setWorkflowResourceIds(workflowResourceIds); - configBB.setConfigurationResourceKeys(configurationResourceKeys); + ExecuteBuildingBlock configBB = new ExecuteBuildingBlock().setaLaCarte(ebb.isaLaCarte()) + .setApiVersion(ebb.getApiVersion()).setRequestAction(ebb.getRequestAction()) + .setVnfType(ebb.getVnfType()).setRequestId(ebb.getRequestId()) + .setRequestDetails(ebb.getRequestDetails()).setBuildingBlock(buildingBlock) + .setWorkflowResourceIds(workflowResourceIds).setConfigurationResourceKeys(configurationResourceKeys); return configBB; } |