use of org.apache.inlong.manager.workflow.definition.UserTask in project incubator-inlong by apache.
the class UserTaskProcessor method create.
@Override
public void create(UserTask userTask, WorkflowContext context) {
List<String> approvers = userTask.getApproverAssign().assign(context);
Preconditions.checkNotEmpty(approvers, "cannot assign approvers for task: " + userTask.getDisplayName() + ", as the approvers was empty");
if (!userTask.isNeedAllApprove()) {
approvers = Collections.singletonList(StringUtils.join(approvers, WorkflowTaskEntity.APPROVERS_DELIMITER));
}
WorkflowProcessEntity processEntity = context.getProcessEntity();
approvers.stream().map(approver -> saveTaskEntity(userTask, processEntity, approver)).forEach(context.getNewTaskList()::add);
taskEventNotifier.notify(TaskEvent.CREATE, context);
}
use of org.apache.inlong.manager.workflow.definition.UserTask in project incubator-inlong by apache.
the class WorkflowQueryServiceImpl method addNext.
private void addNext(NextableElement nextableElement, ElementDTO elementDTO, WorkflowContext context, Map<String, TaskStatus> nameToStatusMap) {
for (Element element : nextableElement.getNextList(context)) {
ElementDTO nextElement = new ElementDTO();
nextElement.setName(element.getName());
nextElement.setDisplayName(element.getDisplayName());
if (element instanceof UserTask) {
nextElement.setApprovers(((UserTask) element).getApproverAssign().assign(context));
nextElement.setStatus(nameToStatusMap.get(element.getName()));
}
elementDTO.getNext().add(nextElement);
if (!(element instanceof NextableElement)) {
continue;
}
addNext((NextableElement) element, nextElement, context, nameToStatusMap);
}
}
use of org.apache.inlong.manager.workflow.definition.UserTask in project incubator-inlong by apache.
the class WorkflowApproverServiceImpl method add.
@Override
public void add(WorkflowApprover approver, String operator) {
Date now = new Date();
approver.setCreateTime(now);
approver.setModifyTime(now);
approver.setModifier(operator);
approver.setCreator(operator);
WorkflowProcess process = workflowEngine.processDefinitionService().getByName(approver.getProcessName());
Preconditions.checkNotNull(process, "process not exit with name: " + approver.getProcessName());
WorkflowTask task = process.getTaskByName(approver.getTaskName());
Preconditions.checkNotNull(task, "task not exit with name: " + approver.getTaskName());
Preconditions.checkTrue(task instanceof UserTask, "task should be UserTask");
List<WorkflowApproverEntity> exist = this.workflowApproverMapper.selectByQuery(WorkflowApproverQuery.builder().processName(approver.getProcessName()).taskName(approver.getTaskName()).filterKey(approver.getFilterKey().name()).filterValue(approver.getFilterValue()).build());
Preconditions.checkEmpty(exist, "already exit the same config");
WorkflowApproverEntity entity = CommonBeanUtils.copyProperties(approver, WorkflowApproverEntity::new);
entity.setIsDeleted(EntityStatus.UN_DELETED.getCode());
int success = this.workflowApproverMapper.insert(entity);
Preconditions.checkTrue(success == 1, "add failed");
}
Aggregations