Search in sources :

Example 6 with UserTask

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);
}
Also used : WorkflowTaskEntityMapper(org.apache.inlong.manager.dao.mapper.WorkflowTaskEntityMapper) Date(java.util.Date) ArrayUtils(org.apache.commons.lang3.ArrayUtils) StringUtils(org.apache.commons.lang3.StringUtils) Lists(com.google.common.collect.Lists) Preconditions(org.apache.inlong.manager.common.util.Preconditions) TaskEvent(org.apache.inlong.manager.workflow.event.task.TaskEvent) Map(java.util.Map) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) ImmutableSet(com.google.common.collect.ImmutableSet) TaskStatus(org.apache.inlong.manager.common.enums.TaskStatus) WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) Set(java.util.Set) Maps(com.google.common.collect.Maps) WorkflowEventNotifier(org.apache.inlong.manager.workflow.core.impl.WorkflowEventNotifier) List(java.util.List) TaskEventNotifier(org.apache.inlong.manager.workflow.event.task.TaskEventNotifier) UserTask(org.apache.inlong.manager.workflow.definition.UserTask) Element(org.apache.inlong.manager.workflow.definition.Element) WorkflowAction(org.apache.inlong.manager.workflow.WorkflowAction) Optional(java.util.Optional) JsonUtils(org.apache.inlong.manager.common.util.JsonUtils) Collections(java.util.Collections) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)

Example 7 with UserTask

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);
    }
}
Also used : NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) ElementDTO(org.apache.inlong.manager.common.pojo.workflow.ElementDTO) Element(org.apache.inlong.manager.workflow.definition.Element) NextableElement(org.apache.inlong.manager.workflow.definition.NextableElement) UserTask(org.apache.inlong.manager.workflow.definition.UserTask)

Example 8 with UserTask

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");
}
Also used : UserTask(org.apache.inlong.manager.workflow.definition.UserTask) WorkflowTask(org.apache.inlong.manager.workflow.definition.WorkflowTask) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) WorkflowApproverEntity(org.apache.inlong.manager.dao.entity.WorkflowApproverEntity) Date(java.util.Date)

Aggregations

UserTask (org.apache.inlong.manager.workflow.definition.UserTask)8 Date (java.util.Date)4 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)3 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)3 TaskStatus (org.apache.inlong.manager.common.enums.TaskStatus)2 Element (org.apache.inlong.manager.workflow.definition.Element)2 EndEvent (org.apache.inlong.manager.workflow.definition.EndEvent)2 StartEvent (org.apache.inlong.manager.workflow.definition.StartEvent)2 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)2 JavaType (com.fasterxml.jackson.databind.JavaType)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 ArrayUtils (org.apache.commons.lang3.ArrayUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1