use of org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse in project incubator-inlong by apache.
the class WorkflowQueryServiceImpl method getProcessDetail.
private ProcessDetailResponse getProcessDetail(Integer processId, WorkflowProcessEntity processEntity) {
List<WorkflowTaskEntity> taskList = this.listApproveHistory(processId);
List<TaskResponse> history = taskList.stream().map(WorkflowBeanUtils::fromTaskEntity).collect(Collectors.toList());
WorkflowBriefDTO workflowDTO = this.getBriefFromProcessEntity(processEntity);
ProcessDetailResponse processDetail = new ProcessDetailResponse();
processDetail.setProcessInfo(WorkflowBeanUtils.fromProcessEntity(processEntity));
processDetail.setTaskHistory(history);
processDetail.setWorkflow(workflowDTO);
return processDetail;
}
use of org.apache.inlong.manager.common.pojo.workflow.ProcessDetailResponse in project incubator-inlong by apache.
the class WorkflowQueryServiceImpl method detail.
@Override
public ProcessDetailResponse detail(Integer processId, Integer taskId, String operator) {
WorkflowProcessEntity processEntity = this.getProcessEntity(processId);
if (processEntity == null) {
return null;
}
WorkflowTaskEntity taskEntity = null;
if (taskId == null) {
if (!operator.equals(processEntity.getApplicant())) {
throw new WorkflowException("current user is not the applicant of the process");
}
} else {
taskEntity = this.getTaskEntity(taskId);
List<String> taskApprovers = Arrays.asList(taskEntity.getApprovers().split(","));
if (!taskApprovers.contains(operator)) {
WorkflowApproverQuery query = new WorkflowApproverQuery();
query.setProcessName(processEntity.getName());
List<WorkflowApproverEntity> approverList = approverMapper.selectByQuery(query);
boolean match = approverList.stream().anyMatch(approverEntity -> {
String[] approverArr = approverEntity.getApprovers().split(",");
for (String approver : approverArr) {
if (Objects.equals(approver, operator)) {
return true;
}
}
return false;
});
if (!match) {
throw new WorkflowException("current user is not the approver of the process");
}
}
}
WorkflowProcess process = definitionRepository.get(processEntity.getName());
TaskResponse currentTask = null;
if (taskEntity != null) {
currentTask = WorkflowBeanUtils.fromTaskEntity(taskEntity);
if (process != null && TaskStatus.PENDING.equals(currentTask.getStatus())) {
WorkflowTask task = process.getTaskByName(currentTask.getName());
currentTask.setFormData(this.getEmptyTaskForm(task));
}
if (!processId.equals(currentTask.getProcessId())) {
throw new WorkflowException("task [" + taskId + "] not belongs to process [" + processId + "]");
}
}
ProcessDetailResponse detailResponse = this.getProcessDetail(processId, processEntity);
detailResponse.setCurrentTask(currentTask);
if (process == null || process.getProcessDetailHandler() == null) {
return detailResponse;
}
return process.getProcessDetailHandler().handle(detailResponse);
}
Aggregations