Search in sources :

Example 6 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class WorkflowServiceImplTest method testListTaskExecuteLogs.

@Test
public void testListTaskExecuteLogs() {
    // insert process instance
    String groupId = "test_group";
    WorkflowProcessEntity process = new WorkflowProcessEntity();
    process.setId(1);
    process.setInlongGroupId(groupId);
    process.setName("CREATE_GROUP_RESOURCE");
    process.setDisplayName("Group-Resource");
    process.setHidden(1);
    process.setStatus(ProcessStatus.COMPLETED.name());
    processEntityMapper.insert(process);
    // insert task instance
    WorkflowTaskEntity task = new WorkflowTaskEntity();
    task.setId(1);
    task.setType("ServiceTask");
    task.setProcessId(1);
    taskEntityMapper.insert(task);
    // query execute logs
    TaskExecuteLogQuery query = new TaskExecuteLogQuery();
    query.setInlongGroupId(groupId);
    query.setProcessNames(Collections.singletonList("CREATE_GROUP_RESOURCE"));
    PageInfo<WorkflowExecuteLog> logPageInfo = workflowService.listTaskExecuteLogs(query);
    Assert.assertEquals(1, logPageInfo.getTotal());
}
Also used : TaskExecuteLogQuery(org.apache.inlong.manager.common.pojo.workflow.TaskExecuteLogQuery) WorkflowProcessEntity(org.apache.inlong.manager.dao.entity.WorkflowProcessEntity) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) Test(org.junit.Test) ServiceBaseTest(org.apache.inlong.manager.service.ServiceBaseTest)

Example 7 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class UserTaskProcessor method completeTaskInstance.

private void completeTaskInstance(WorkflowContext.ActionContext actionContext) {
    WorkflowTaskEntity taskEntity = actionContext.getTaskEntity();
    TaskStatus taskStatus = toTaskState(actionContext.getAction());
    taskEntity.setStatus(taskStatus.name());
    taskEntity.setOperator(actionContext.getOperator());
    taskEntity.setRemark(actionContext.getRemark());
    UserTask userTask = (UserTask) actionContext.getTask();
    if (needForm(userTask, actionContext.getAction())) {
        Preconditions.checkNotNull(actionContext.getForm(), "form cannot be null");
        Preconditions.checkTrue(actionContext.getForm().getClass().isAssignableFrom(userTask.getFormClass()), "form type not match, should be class " + userTask.getFormClass());
        actionContext.getForm().validate();
        taskEntity.setFormData(JsonUtils.toJson(actionContext.getForm()));
    } else {
        Preconditions.checkNull(actionContext.getForm(), "no form required");
    }
    taskEntity.setEndTime(new Date());
    taskEntity.setExtParams(handlerExt(actionContext, taskEntity.getExtParams()));
    taskEntityMapper.update(taskEntity);
}
Also used : UserTask(org.apache.inlong.manager.workflow.definition.UserTask) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) TaskStatus(org.apache.inlong.manager.common.enums.TaskStatus) Date(java.util.Date)

Example 8 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity 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 9 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class UserTaskProcessor method checkOperator.

private void checkOperator(WorkflowContext.ActionContext actionContext) {
    WorkflowTaskEntity workflowTaskEntity = actionContext.getTaskEntity();
    if (!SHOULD_CHECK_OPERATOR_ACTIONS.contains(actionContext.getAction())) {
        return;
    }
    boolean operatorIsApprover = ArrayUtils.contains(workflowTaskEntity.getApprovers().split(WorkflowTaskEntity.APPROVERS_DELIMITER), actionContext.getOperator());
    if (!operatorIsApprover) {
        throw new WorkflowException(String.format("current operator %s not in approvers list: %s", actionContext.getOperator(), workflowTaskEntity.getApprovers()));
    }
}
Also used : WorkflowException(org.apache.inlong.manager.common.exceptions.WorkflowException) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)

Example 10 with WorkflowTaskEntity

use of org.apache.inlong.manager.dao.entity.WorkflowTaskEntity in project incubator-inlong by apache.

the class WorkflowContextBuilderImpl method buildContextForTask.

@SneakyThrows
@Override
public WorkflowContext buildContextForTask(Integer taskId, WorkflowAction action) {
    WorkflowTaskEntity taskEntity = taskEntityMapper.selectById(taskId);
    WorkflowProcess process = definitionRepository.get(taskEntity.getProcessName()).clone();
    TaskForm taskForm = WorkflowFormParserUtils.parseTaskForm(taskEntity, process);
    List<String> transferToUsers = getTransferToUsers(taskEntity.getExtParams());
    return buildContextForTask(taskId, action, taskForm, transferToUsers, taskEntity.getRemark(), taskEntity.getOperator());
}
Also used : TaskForm(org.apache.inlong.manager.common.pojo.workflow.form.TaskForm) WorkflowTaskEntity(org.apache.inlong.manager.dao.entity.WorkflowTaskEntity) WorkflowProcess(org.apache.inlong.manager.workflow.definition.WorkflowProcess) SneakyThrows(lombok.SneakyThrows)

Aggregations

WorkflowTaskEntity (org.apache.inlong.manager.dao.entity.WorkflowTaskEntity)17 WorkflowProcessEntity (org.apache.inlong.manager.dao.entity.WorkflowProcessEntity)6 WorkflowContext (org.apache.inlong.manager.workflow.WorkflowContext)6 Date (java.util.Date)5 WorkflowProcess (org.apache.inlong.manager.workflow.definition.WorkflowProcess)3 WorkflowTask (org.apache.inlong.manager.workflow.definition.WorkflowTask)3 SneakyThrows (lombok.SneakyThrows)2 TaskStatus (org.apache.inlong.manager.common.enums.TaskStatus)2 WorkflowException (org.apache.inlong.manager.common.exceptions.WorkflowException)2 ProcessDetailResponse (org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse)2 TaskResponse (org.apache.inlong.manager.common.pojo.workflow.TaskResponse)2 UserTask (org.apache.inlong.manager.workflow.definition.UserTask)2 TaskExecuteLogQuery (org.apache.inlong.manager.common.pojo.workflow.TaskExecuteLogQuery)1 TaskQuery (org.apache.inlong.manager.common.pojo.workflow.TaskQuery)1 WorkflowApproverQuery (org.apache.inlong.manager.common.pojo.workflow.WorkflowApproverQuery)1 WorkflowBriefDTO (org.apache.inlong.manager.common.pojo.workflow.WorkflowBriefDTO)1 ProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.ProcessForm)1 TaskForm (org.apache.inlong.manager.common.pojo.workflow.form.TaskForm)1 WorkflowApproverEntity (org.apache.inlong.manager.dao.entity.WorkflowApproverEntity)1 ServiceBaseTest (org.apache.inlong.manager.service.ServiceBaseTest)1