use of com.netflix.conductor.core.execution.mapper.TaskMapperContext in project conductor by Netflix.
the class DeciderService method getTasksToBeScheduled.
public List<Task> getTasksToBeScheduled(Workflow workflow, WorkflowTask taskToSchedule, int retryCount, String retriedTaskId) {
workflow = populateWorkflowAndTaskData(workflow);
Map<String, Object> input = parametersUtils.getTaskInput(taskToSchedule.getInputParameters(), workflow, null, null);
TaskType taskType = TaskType.USER_DEFINED;
String type = taskToSchedule.getType();
if (TaskType.isSystemTask(type)) {
taskType = TaskType.valueOf(type);
}
// get tasks already scheduled (in progress/terminal) for this workflow instance
List<String> tasksInWorkflow = workflow.getTasks().stream().filter(runningTask -> runningTask.getStatus().equals(Status.IN_PROGRESS) || runningTask.getStatus().isTerminal()).map(Task::getReferenceTaskName).collect(Collectors.toList());
String taskId = IDGenerator.generate();
TaskMapperContext taskMapperContext = TaskMapperContext.newBuilder().withWorkflowDefinition(workflow.getWorkflowDefinition()).withWorkflowInstance(workflow).withTaskDefinition(taskToSchedule.getTaskDefinition()).withTaskToSchedule(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
List<Task> tasks = taskMappers.get(taskType.name()).getMappedTasks(taskMapperContext).stream().filter(task -> !tasksInWorkflow.contains(task.getReferenceTaskName())).collect(Collectors.toList());
tasks.forEach(this::externalizeTaskData);
return tasks;
}
Aggregations