public List<TaskModel> getTasksToBeScheduled(
            WorkflowModel workflow,
            WorkflowTask taskToSchedule,
            int retryCount,
            String retriedTaskId) {
        Map<String, Object> input =
                parametersUtils.getTaskInput(
                        taskToSchedule.getInputParameters(), workflow, null, null);

        String type = taskToSchedule.getType();

        // get tasks already scheduled (in progress/terminal) for  this workflow instance
        List<String> tasksInWorkflow =
                workflow.getTasks().stream()
                        .filter(
                                runningTask ->
                                        runningTask.getStatus().equals(TaskModel.Status.IN_PROGRESS)
                                                || runningTask.getStatus().isTerminal())
                        .map(TaskModel::getReferenceTaskName)
                        .collect(Collectors.toList());

        String taskId = idGenerator.generate();
        TaskMapperContext taskMapperContext =
                TaskMapperContext.newBuilder()
                        .withWorkflowModel(workflow)
                        .withTaskDefinition(taskToSchedule.getTaskDefinition())
                        .withWorkflowTask(taskToSchedule)
                        .withTaskInput(input)
                        .withRetryCount(retryCount)
                        .withRetryTaskId(retriedTaskId)
                        .withTaskId(taskId)
                        .withDeciderService(this)
                        .build();

        // For static forks, each branch of the fork creates a join task upon completion for
        // dynamic forks, a join task is created with the fork and also with each branch of the
        // fork.
        // A new task must only be scheduled if a task, with the same reference name is not already
        // in this workflow instance
        return taskMappers
                .getOrDefault(type, taskMappers.get(USER_DEFINED.name()))
                .getMappedTasks(taskMapperContext)
                .stream()
                .filter(task -> !tasksInWorkflow.contains(task.getReferenceTaskName()))
                .collect(Collectors.toList());
    }
Updates the workflow output.

@param workflow the workflow instance
@param task if not null, the output of this task will be copied to workflow output if no
    output parameters are specified in the workflow definition if null, the output of the
    last task in the workflow will be copied to workflow output of no output parameters are
    specified in the workflow definition
core/src/main/java/com/netflix/conductor/core/execution/DeciderService.java