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());
}
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);
}
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);
}
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()));
}
}
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());
}
Aggregations