use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class EventListenerServiceImpl method triggerTaskEvent.
@Override
public void triggerTaskEvent(Integer taskId, TaskEvent taskEvent) {
WorkflowContext context = workflowContextBuilder.buildContextForTask(taskId, WorkflowAction.fromTaskEvent(taskEvent));
workflowEventNotifier.getTaskEventNotifier().notify(taskEvent, context);
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class WorkflowQueryServiceImpl method getBriefFromProcessEntity.
private WorkflowBriefDTO getBriefFromProcessEntity(WorkflowProcessEntity processEntity) {
WorkflowProcess process = definitionRepository.get(processEntity.getName());
if (process == null) {
return null;
}
Map<String, TaskStatus> nameStatusMap = this.getTaskNameStatusMap(processEntity);
ElementDTO elementDTO = new ElementDTO();
StartEvent startEvent = process.getStartEvent();
elementDTO.setName(startEvent.getName());
elementDTO.setDisplayName(startEvent.getDisplayName());
WorkflowContext context = WorkflowBeanUtils.buildContext(process, processEntity);
addNext(startEvent, elementDTO, context, nameStatusMap);
WorkflowBriefDTO briefDTO = new WorkflowBriefDTO();
briefDTO.setName(process.getName());
briefDTO.setDisplayName(process.getDisplayName());
briefDTO.setType(process.getType());
briefDTO.setStartEvent(elementDTO);
return briefDTO;
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class EndEventProcessor method complete.
@Override
public boolean complete(WorkflowContext context) {
WorkflowProcessEntity processEntity = context.getProcessEntity();
List<WorkflowTaskEntity> tasks = taskEntityMapper.selectByProcess(processEntity.getId(), TaskStatus.PENDING);
// If there are unfinished tasks, the process cannot be ended
if (!CollectionUtils.isEmpty(tasks)) {
log.warn("have pending task, end event not execute");
return true;
}
WorkflowContext.ActionContext actionContext = context.getActionContext();
processEntity.setStatus(getProcessStatus(actionContext.getAction()).name());
processEntity.setEndTime(new Date());
processEntityMapper.update(processEntity);
processEventNotifier.notify(mapToEvent(actionContext.getAction()), context);
return true;
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class ServiceTaskProcessor method complete.
@Override
public boolean complete(WorkflowContext context) {
WorkflowContext.ActionContext actionContext = context.getActionContext();
Preconditions.checkTrue(SUPPORT_ACTIONS.contains(actionContext.getAction()), "serviceTask not support action: " + actionContext.getAction());
WorkflowTaskEntity workflowTaskEntity = actionContext.getTaskEntity();
Preconditions.checkTrue(ALLOW_COMPLETE_STATE.contains(TaskStatus.valueOf(workflowTaskEntity.getStatus())), "task status should allow complete");
try {
this.taskEventNotifier.notify(TaskEvent.COMPLETE, context);
completeTaskEntity(actionContext, workflowTaskEntity, TaskStatus.COMPLETED);
return true;
} catch (Exception e) {
completeTaskEntity(actionContext, workflowTaskEntity, TaskStatus.FAILED);
this.taskEventNotifier.notify(TaskEvent.FAIL, context);
this.processEventNotifier.notify(ProcessEvent.FAIL, context);
return false;
}
}
use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.
the class ProcessEventNotifier method notify.
@Override
public void notify(String listenerName, boolean forceSync, WorkflowContext sourceContext) {
final WorkflowContext context = sourceContext.clone();
WorkflowProcess process = context.getProcess();
Optional.ofNullable(this.eventListenerManager.listener(listenerName)).ifPresent(logableNotify(forceSync, context));
Optional.ofNullable(process.listener(listenerName)).ifPresent(logableNotify(forceSync, context));
}
Aggregations