private PauseReason findPauseReason(Long executionId, String branchId) { // 1. Check the configuration according to branch (can be null or not null...) if (workerConfigurationService.isExecutionPaused(executionId, branchId)) { ExecutionSummary execSummary = pauseService.readPausedExecution(executionId, branchId); if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) { return execSummary.getPauseReason(); } // 2. Check the parent if we're in branch (subflow or MI\Parallel lane). // If the user pressed Pause on the Parent then we need to pause the branch (the parent is in the Suspended table). } else if (branchId != null && workerConfigurationService.isExecutionPaused(executionId, null)) { ExecutionSummary execSummary = pauseService.readPausedExecution(executionId, null); if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) { PauseReason reason = execSummary.getPauseReason(); // we only care about User-Paused here! // we don't want to Pause if the parent is paused due to branch_paused! (other branch is paused for some reason (e.g. required_input), so the parent is paused as well). if (PauseReason.USER_PAUSED.equals(reason)) { return reason; } } } return null; // not paused }
private boolean handlePausedFlowAfterStep(Execution execution) throws InterruptedException { String branchId = execution.getSystemContext().getBranchId(); PauseReason reason = null; ExecutionSummary execSummary = pauseService.readPausedExecution(execution.getExecutionId(), branchId); if (execSummary != null && execSummary.getStatus().equals(ExecutionStatus.PENDING_PAUSE)) { reason = execSummary.getPauseReason(); } if (reason != null) { // need to pause the execution pauseFlow(reason, execution); return true; } return false; }
private Long pauseExecution(Execution execution) { String branchId = execution.getSystemContext().getBranchId(); ExecutionSummary pe = pauseResumeService.readPausedExecution(execution.getExecutionId(), branchId); //Check if this execution is not paused already (by user) Long pauseId; if (pe == null) { // When cancel execution and no worker in group it should return to be paused without any termination type execution.getSystemContext().setFlowTerminationType(null); pauseId = pauseResumeService.pauseExecution(execution.getExecutionId(), branchId, PauseReason.NO_WORKERS_IN_GROUP); pauseResumeService.writeExecutionObject(execution.getExecutionId(), branchId, execution); } else { pauseId = null; //If yes - just write the object pauseResumeService.writeExecutionObject(execution.getExecutionId(), branchId, execution); } return pauseId; }