@Override
    public List<Task> getMappedTasks(TaskMapperContext taskMapperContext) throws TerminateWorkflowException {

        logger.debug("TaskMapperContext {} in ForkJoinTaskMapper", taskMapperContext);

        WorkflowTask taskToSchedule = taskMapperContext.getTaskToSchedule();
        Map<String, Object> taskInput = taskMapperContext.getTaskInput();
        Workflow workflowInstance = taskMapperContext.getWorkflowInstance();
        int retryCount = taskMapperContext.getRetryCount();

        String taskId = taskMapperContext.getTaskId();

        List<Task> tasksToBeScheduled = new LinkedList<>();
        Task forkTask = new Task();
        forkTask.setTaskType(SystemTaskType.FORK.name());
        forkTask.setTaskDefName(SystemTaskType.FORK.name());
        forkTask.setReferenceTaskName(taskToSchedule.getTaskReferenceName());
        forkTask.setWorkflowInstanceId(workflowInstance.getWorkflowId());
        forkTask.setWorkflowType(workflowInstance.getWorkflowName());
        forkTask.setCorrelationId(workflowInstance.getCorrelationId());
        forkTask.setScheduledTime(System.currentTimeMillis());
        forkTask.setEndTime(System.currentTimeMillis());
        forkTask.setInputData(taskInput);
        forkTask.setTaskId(taskId);
        forkTask.setStatus(Task.Status.COMPLETED);
        forkTask.setWorkflowTask(taskToSchedule);

        tasksToBeScheduled.add(forkTask);
        List<List<WorkflowTask>> forkTasks = taskToSchedule.getForkTasks();
        for (List<WorkflowTask> wfts : forkTasks) {
            WorkflowTask wft = wfts.get(0);
            List<Task> tasks2 = taskMapperContext.getDeciderService()
                    .getTasksToBeScheduled(workflowInstance, wft, retryCount);
            tasksToBeScheduled.addAll(tasks2);
        }

        WorkflowTask joinWorkflowTask = workflowInstance
                .getWorkflowDefinition()
                .getNextTask(taskToSchedule.getTaskReferenceName());

        if (joinWorkflowTask == null || !joinWorkflowTask.getType().equals(TaskType.JOIN.name())) {
            throw new TerminateWorkflowException("Dynamic join definition is not followed by a join task.  Check the blueprint");
        }
        return tasksToBeScheduled;
    }
@ Override public List < Task > getMappedTasks ( TaskMapperContext taskMapperContext ) throws TerminateWorkflowException { logger . debug ( "TaskMapperContext {} in ForkJoinTaskMapper" , taskMapperContext ) ; WorkflowTask taskToSchedule = taskMapperContext . getTaskToSchedule ( ) ; Map < String , Object > taskInput = taskMapperContext . getTaskInput ( ) ; Workflow workflowInstance = taskMapperContext . getWorkflowInstance ( ) ; int retryCount = taskMapperContext . getRetryCount ( ) ; String taskId = taskMapperContext . getTaskId ( ) ; List < Task > tasksToBeScheduled = new LinkedList < > ( ) ; Task forkTask = new Task ( ) ; forkTask . setTaskType ( SystemTaskType . FORK . name ( ) ) ; forkTask . setTaskDefName ( SystemTaskType . FORK . name ( ) ) ; forkTask . setReferenceTaskName ( taskToSchedule . getTaskReferenceName ( ) ) ; forkTask . setWorkflowInstanceId ( workflowInstance . getWorkflowId ( ) ) ; forkTask . setWorkflowType ( workflowInstance . getWorkflowName ( ) ) ; forkTask . setCorrelationId ( workflowInstance . getCorrelationId ( ) ) ; forkTask . setScheduledTime ( System . currentTimeMillis ( ) ) ; forkTask . setEndTime ( System . currentTimeMillis ( ) ) ; forkTask . setInputData ( taskInput ) ; forkTask . setTaskId ( taskId ) ; forkTask . setStatus ( Task . Status . COMPLETED ) ; forkTask . setWorkflowTask ( taskToSchedule ) ; tasksToBeScheduled . add ( forkTask ) ; List < List < WorkflowTask > > forkTasks = taskToSchedule . getForkTasks ( ) ; for ( List < WorkflowTask > wfts : forkTasks ) { WorkflowTask wft = wfts . get ( 0 ) ; List < Task > tasks2 = taskMapperContext . getDeciderService ( ) . getTasksToBeScheduled ( workflowInstance , wft , retryCount ) ; tasksToBeScheduled . addAll ( tasks2 ) ; } WorkflowTask joinWorkflowTask = workflowInstance . getWorkflowDefinition ( ) . getNextTask ( taskToSchedule . getTaskReferenceName ( ) ) ; if ( joinWorkflowTask == null || ! joinWorkflowTask . getType ( ) . equals ( TaskType . JOIN . name ( ) ) ) { throw new TerminateWorkflowException ( "Dynamic join definition is not followed by a join task.  Check the blueprint" ) ; } return tasksToBeScheduled ; }
This method gets the list of tasks that need to scheduled when the the task to scheduled is of type {@link TaskType#FORK_JOIN}.

@param taskMapperContext: A wrapper class containing the {@link WorkflowTask}, {@link WorkflowDef}, {@link Workflow} and a string representation of the TaskId
@return List of tasks in the following order:
* <ul>
<li>
{@link SystemTaskType#FORK} with {@link Task.Status#COMPLETED}
</li>
<li>
Might be any kind of task, but in most cases is a UserDefinedTask with {@link Task.Status#SCHEDULED}
</li>
</ul>
@throws TerminateWorkflowException When the task after {@link TaskType#FORK_JOIN} is not a {@link TaskType#JOIN}