diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-23 08:48:58 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2018-08-23 08:49:17 -0400 |
commit | 4db25ff7b585c21f14e1acb306aec752bd362610 (patch) | |
tree | fdd50bf5b0c28b5b569cb95a6e9e122a0ed24f45 /bpmn/so-bpmn-tasks/src | |
parent | bb6310f30287b352ad941ecc97aeb278a327d595 (diff) |
write update status of BBs progress
added in the missing bpmn file change
add implementation to update status of BBs progress
Change-Id: If913b4e4da2a548e7b5660be947721cb17c60d3f
Issue-ID: SO-890
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
3 files changed, 70 insertions, 0 deletions
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 ee6af61d0f..101a355c2f 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 @@ -81,6 +81,45 @@ public class WorkflowActionBBTasks { execution.setVariable(G_CURRENT_SEQUENCE, currentSequence); } } + + public void updateFlowStatistics(DelegateExecution execution) { + int currentSequence = (int) execution.getVariable(G_CURRENT_SEQUENCE); + if(currentSequence > 1) { + InfraActiveRequests request = this.getUpdatedRequest(execution, currentSequence); + requestDbclient.updateInfraActiveRequests(request); + } + } + + protected InfraActiveRequests getUpdatedRequest(DelegateExecution execution, int currentSequence) { + List<ExecuteBuildingBlock> flowsToExecute = (List<ExecuteBuildingBlock>) execution + .getVariable("flowsToExecute"); + String requestId = (String) execution.getVariable(G_REQUEST_ID); + InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId); + ExecuteBuildingBlock completedBB = flowsToExecute.get(currentSequence - 2); + ExecuteBuildingBlock nextBB = flowsToExecute.get(currentSequence - 1); + int completedBBs = currentSequence - 1; + int totalBBs = flowsToExecute.size(); + int remainingBBs = totalBBs - completedBBs; + String statusMessage = this.getStatusMessage(completedBB.getBuildingBlock().getBpmnFlowName(), + nextBB.getBuildingBlock().getBpmnFlowName(), completedBBs, remainingBBs); + Long percentProgress = this.getPercentProgress(completedBBs, totalBBs); + request.setStatusMessage(statusMessage); + request.setProgress(percentProgress); + request.setLastModifiedBy("CamundaBPMN"); + return request; + } + + protected Long getPercentProgress(int completedBBs, int totalBBs) { + double ratio = (completedBBs / (totalBBs * 1.0)); + int percentProgress = (int) (ratio * 95); + return new Long(percentProgress + 5); + } + + protected String getStatusMessage(String completedBB, String nextBB, int completedBBs, int remainingBBs) { + return "Execution of " + completedBB + " has completed successfully, next invoking " + nextBB + + " (Execution Path progress: BBs completed = " + completedBBs + "; BBs remaining = " + remainingBBs + + ")."; + } public void sendSyncAck(DelegateExecution execution) { final String requestId = (String) execution.getVariable(G_REQUEST_ID); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java index 501e64f4d4..87852e9922 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java @@ -27,6 +27,7 @@ import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup; import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper; +import org.onap.so.client.db.request.RequestsDbClient; import org.onap.so.client.orchestration.AAICollectionResources; import org.onap.so.client.orchestration.AAIInstanceGroupResources; import org.onap.so.client.orchestration.AAINetworkResources; @@ -108,6 +109,9 @@ public abstract class BaseTaskTest extends TestDataSetup { @MockBean protected CatalogDbClient catalogDbClient; + @MockBean + protected RequestsDbClient requestsDbClient; + @Mock protected BBInputSetupUtils bbSetupUtils; diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java index d856b5e184..27173b7502 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java @@ -37,6 +37,7 @@ import org.junit.rules.ExpectedException; import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.request.beans.InfraActiveRequests; import org.springframework.beans.factory.annotation.Autowired; public class WorkflowActionBBTasksTest extends BaseTaskTest { @@ -80,6 +81,32 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest { } @Test + public void getUpdatedRequestTest() throws Exception{ + List<ExecuteBuildingBlock> flowsToExecute = new ArrayList(); + ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock(); + BuildingBlock bb1 = new BuildingBlock(); + bb1.setBpmnFlowName("CreateNetworkBB"); + flowsToExecute.add(ebb1); + ebb1.setBuildingBlock(bb1); + ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock(); + BuildingBlock bb2 = new BuildingBlock(); + bb2.setBpmnFlowName("ActivateNetworkBB"); + flowsToExecute.add(ebb2); + ebb2.setBuildingBlock(bb2); + String requestId = "requestId"; + execution.setVariable("mso-request-id", requestId); + execution.setVariable("flowsToExecute", flowsToExecute); + int currentSequence = 2; + String expectedStatusMessage = "Execution of CreateNetworkBB has completed successfully, next invoking ActivateNetworkBB (Execution Path progress: BBs completed = 1; BBs remaining = 1)."; + Long expectedLong = new Long(52); + InfraActiveRequests mockedRequest = new InfraActiveRequests(); + when(requestsDbClient.getInfraActiveRequestbyRequestId(requestId)).thenReturn(mockedRequest); + InfraActiveRequests actual = workflowActionBBTasks.getUpdatedRequest(execution, currentSequence); + assertEquals(expectedStatusMessage, actual.getStatusMessage()); + assertEquals(expectedLong, actual.getProgress()); + } + + @Test public void select2BBTest() throws Exception{ String gAction = "Delete-Network-Collection"; execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); |