Search in sources :

Example 26 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class UserTaskProcessor method next.

@Override
public List<Element> next(UserTask userTask, WorkflowContext context) {
    WorkflowContext.ActionContext actionContext = context.getActionContext();
    if (userTask.isNeedAllApprove()) {
        WorkflowTaskEntity workflowTaskEntity = actionContext.getTaskEntity();
        int pendingCount = taskEntityMapper.countByStatus(workflowTaskEntity.getProcessId(), workflowTaskEntity.getName(), TaskStatus.PENDING);
        if (pendingCount > 0) {
            return Lists.newArrayList();
        }
    }
    return super.next(userTask, context);
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)

Example 27 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext 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 28 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class TaskServiceImpl method reject.

@Override
public WorkflowContext reject(Integer taskId, String remark, String operator) {
    WorkflowContext context = contextBuilder.buildContextForTask(taskId, WorkflowAction.REJECT, remark, operator);
    processorExecutor.executeComplete(context.getActionContext().getTask(), context);
    return context;
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext)

Example 29 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class TaskServiceImpl method complete.

@Override
public WorkflowContext complete(Integer taskId, String remark, String operator) {
    WorkflowContext context = contextBuilder.buildContextForTask(taskId, WorkflowAction.COMPLETE, remark, operator);
    processorExecutor.executeComplete(context.getActionContext().getTask(), context);
    return context;
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext)

Example 30 with WorkflowContext

use of org.apache.inlong.manager.workflow.WorkflowContext in project incubator-inlong by apache.

the class WorkflowContextBuilderImpl method buildContextForProcess.

@SneakyThrows
@Override
public WorkflowContext buildContextForProcess(Integer processId) {
    WorkflowProcessEntity processEntity = processEntityMapper.selectById(processId);
    Preconditions.checkNotNull(processEntity, "process not exist with id: " + processId);
    WorkflowProcess process = definitionRepository.get(processEntity.getName()).clone();
    return new WorkflowContext().setApplicant(processEntity.getApplicant()).setProcess(process).setProcessForm(WorkflowFormParserUtils.parseProcessForm(processEntity.getFormData(), process)).setProcessEntity(processEntity);
}
Also used : WorkflowContext(org.apache.inlong.manager.workflow.WorkflowContext) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) SneakyThrows(lombok.SneakyThrows)

Aggregations

WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)37 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)15 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)13 Test (org.junit.Test)11 ProcessResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessResponse)9 WorkflowResult (org.apache.inlong.manager.common.pojo.workflow.WorkflowResult)9 ServiceTask (org.apache.inlong.manager.workflow.definition.ServiceTask)9 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)8 UpdateGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.UpdateGroupProcessForm)8 TaskEventListener (org.apache.inlong.manager.workflow.event.task.TaskEventListener)8 WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)7 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)7 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)6 List (java.util.List)4 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)4 MockPlugin (org.apache.inlong.manager.service.mocks.MockPlugin)4 WorkflowServiceImplTest (org.apache.inlong.manager.service.workflow.WorkflowServiceImplTest)4 Collectors (java.util.stream.Collectors)3 SneakyThrows (lombok.SneakyThrows)3 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)3