summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java/org/onap
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2020-03-30 16:43:08 +0200
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2020-03-31 13:43:23 +0200
commit5aa8f54481dfb850579df3d6c5c5e18a6dc49d42 (patch)
tree76e242ba6aa5751e9d1f9e1e0aa7b3189a0bd656 /bpmn/so-bpmn-tasks/src/main/java/org/onap
parent04aa13df605e9fe05743fa53cc82e3d087a299bc (diff)
workflowAction refactor
- extract code to private methods Issue-ID: SO-2634 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com> Change-Id: Ib5b88549ff410d2e2e93f79b9040211e47f4f6f0
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java76
1 files changed, 47 insertions, 29 deletions
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 e01149f981..d26b9d6d03 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
@@ -168,46 +168,22 @@ public class WorkflowAction {
}
public void selectExecutionList(DelegateExecution execution) throws Exception {
- execution.setVariable("sentSyncResponse", false);
- execution.setVariable("homing", false);
- execution.setVariable("calledHoming", false);
- execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true);
-
try {
final String bpmnRequest = (String) execution.getVariable(BBConstants.G_BPMN_REQUEST);
ServiceInstancesRequest sIRequest =
new ObjectMapper().readValue(bpmnRequest, ServiceInstancesRequest.class);
RequestDetails requestDetails = sIRequest.getRequestDetails();
- execution.setVariable("suppressRollback", requestDetails.getRequestInfo().getSuppressRollback());
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);
- if (!aLaCarte && isResume) {
- logger.debug("replacing URI {}", uri);
- uri = bbInputSetupUtils.loadOriginalInfraActiveRequestById(requestId).getRequestUrl();
- logger.debug("for RESUME with original value {}", uri);
- }
- Resource resource = extractResourceIdAndTypeFromUri(uri);
- WorkflowType resourceType = resource.getResourceType();
- execution.setVariable("resourceName", resourceType.toString());
- String resourceId = "";
String requestAction = (String) execution.getVariable(BBConstants.G_ACTION);
WorkflowResourceIds workflowResourceIds = populateResourceIdsFromApiHandler(execution);
- if (resource.isGenerated() && requestAction.equalsIgnoreCase("createInstance")
- && sIRequest.getRequestDetails().getRequestInfo().getInstanceName() != null) {
- resourceId = validateResourceIdInAAI(resource.getResourceId(), resourceType,
- sIRequest.getRequestDetails().getRequestInfo().getInstanceName(), sIRequest.getRequestDetails(),
- workflowResourceIds);
- } else {
- resourceId = resource.getResourceId();
- }
- String serviceInstanceId = (String) execution.getVariable("serviceInstanceId");
- if ((serviceInstanceId == null || serviceInstanceId.isEmpty()) && resourceType == WorkflowType.SERVICE) {
- serviceInstanceId = resourceId;
- }
- execution.setVariable("resourceId", resourceId);
- execution.setVariable("resourceType", resourceType);
+ 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(aLaCarte, resourceType, requestAction, serviceInstanceId)) {
flowsToExecute = bbInputSetupUtils.loadOriginalFlowExecutionPath(requestId);
@@ -1681,4 +1657,46 @@ public class WorkflowAction {
}
return generatedResourceId;
}
+
+ private void fillExecution(DelegateExecution execution, boolean suppressRollback, String resourceId,
+ WorkflowType resourceType) {
+ execution.setVariable("sentSyncResponse", false);
+ execution.setVariable("homing", false);
+ execution.setVariable("calledHoming", false);
+ execution.setVariable(BBConstants.G_ISTOPLEVELFLOW, true);
+ execution.setVariable("suppressRollback", suppressRollback);
+ execution.setVariable("resourceId", resourceId);
+ execution.setVariable("resourceType", resourceType);
+ execution.setVariable("resourceName", resourceType.toString());
+ }
+
+ private Resource getResource(BBInputSetupUtils bbInputSetupUtils, boolean isResume, boolean alaCarte, String uri,
+ String requestId) {
+ if (!alaCarte && isResume) {
+ logger.debug("replacing URI {}", uri);
+ uri = bbInputSetupUtils.loadOriginalInfraActiveRequestById(requestId).getRequestUrl();
+ logger.debug("for RESUME with original value {}", uri);
+ }
+ return extractResourceIdAndTypeFromUri(uri);
+ }
+
+ private String getResourceId(Resource resource, String requestAction, RequestDetails requestDetails,
+ WorkflowResourceIds workflowResourceIds) throws Exception {
+ if (resource.isGenerated() && requestAction.equalsIgnoreCase("createInstance")
+ && requestDetails.getRequestInfo().getInstanceName() != null) {
+ return validateResourceIdInAAI(resource.getResourceId(), resource.getResourceType(),
+ requestDetails.getRequestInfo().getInstanceName(), requestDetails, workflowResourceIds);
+ } else {
+ return resource.getResourceId();
+ }
+ }
+
+ private String getServiceInstanceId(DelegateExecution execution, String resourceId, WorkflowType resourceType) {
+ String serviceInstanceId = (String) execution.getVariable("serviceInstanceId");
+ if ((serviceInstanceId == null || serviceInstanceId.isEmpty()) && WorkflowType.SERVICE.equals(resourceType)) {
+ serviceInstanceId = resourceId;
+ }
+ return serviceInstanceId;
+ }
+
}