Browse Source

[DS-15489][style]rename the vo object suffix (#15504)

- the naming suffix of the objects under the package dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo is not unified, such as AlertPluginInstanceVO and ScheduleVO, etc.
- this issue solve it, and uniformly modified to the VO suffix

Co-authored-by: fuchanghai <changhaifu@apache.org>
3.2.1-prepare
silenceland 11 months ago committed by GitHub
parent
commit
16c97ef44d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java
  2. 18
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java
  3. 36
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java
  4. 12
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java
  5. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java
  6. 4
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/ScheduleVO.java
  7. 10
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskDefinitionVO.java
  8. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskInstanceCountVO.java
  9. 10
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowDefinitionCountVO.java
  10. 8
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowInstanceCountVO.java
  11. 12
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java
  12. 4
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/DataAnalysisController.java

@ -27,9 +27,9 @@ import org.apache.dolphinscheduler.api.dto.CommandStateCount;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.DataAnalysisService; import org.apache.dolphinscheduler.api.service.DataAnalysisService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVo; import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVO;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
@ -71,7 +71,7 @@ public class DataAnalysisController extends BaseController {
@GetMapping(value = "/task-state-count") @GetMapping(value = "/task-state-count")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(TASK_INSTANCE_STATE_COUNT_ERROR) @ApiException(TASK_INSTANCE_STATE_COUNT_ERROR)
public Result<TaskInstanceCountVo> getTaskInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result<TaskInstanceCountVO> getTaskInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate, @RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate, @RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectCode", required = false) Long projectCode) { @RequestParam(value = "projectCode", required = false) Long projectCode) {
@ -91,7 +91,7 @@ public class DataAnalysisController extends BaseController {
@GetMapping(value = "/process-state-count") @GetMapping(value = "/process-state-count")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(COUNT_PROCESS_INSTANCE_STATE_ERROR) @ApiException(COUNT_PROCESS_INSTANCE_STATE_ERROR)
public Result<WorkflowInstanceCountVo> getWorkflowInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result<WorkflowInstanceCountVO> getWorkflowInstanceStateCount(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "startDate", required = false) String startDate, @RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate, @RequestParam(value = "endDate", required = false) String endDate,
@RequestParam(value = "projectCode", required = false) Long projectCode) { @RequestParam(value = "projectCode", required = false) Long projectCode) {
@ -109,7 +109,7 @@ public class DataAnalysisController extends BaseController {
@GetMapping(value = "/define-user-count") @GetMapping(value = "/define-user-count")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR) @ApiException(COUNT_PROCESS_DEFINITION_USER_ERROR)
public Result<WorkflowDefinitionCountVo> countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, public Result<WorkflowDefinitionCountVO> countDefinitionByUser(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "projectCode", required = false) Long projectCode) { @RequestParam(value = "projectCode", required = false) Long projectCode) {
if (projectCode == null) { if (projectCode == null) {
return Result.success(dataAnalysisService.getAllWorkflowDefinitionCount(loginUser)); return Result.success(dataAnalysisService.getAllWorkflowDefinitionCount(loginUser));

18
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/DataAnalysisService.java

@ -21,9 +21,9 @@ import org.apache.dolphinscheduler.api.dto.CommandStateCount;
import org.apache.dolphinscheduler.api.dto.DefineUserDto; import org.apache.dolphinscheduler.api.dto.DefineUserDto;
import org.apache.dolphinscheduler.api.dto.TaskCountDto; import org.apache.dolphinscheduler.api.dto.TaskCountDto;
import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest; import org.apache.dolphinscheduler.api.dto.project.StatisticsStateRequest;
import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVo; import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVO;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import java.util.List; import java.util.List;
@ -34,27 +34,27 @@ import java.util.Map;
*/ */
public interface DataAnalysisService { public interface DataAnalysisService {
TaskInstanceCountVo getTaskInstanceStateCountByProject(User loginUser, TaskInstanceCountVO getTaskInstanceStateCountByProject(User loginUser,
Long projectCode, Long projectCode,
String startDate, String startDate,
String endDate); String endDate);
TaskInstanceCountVo getAllTaskInstanceStateCount(User loginUser, TaskInstanceCountVO getAllTaskInstanceStateCount(User loginUser,
String startDate, String startDate,
String endDate); String endDate);
WorkflowInstanceCountVo getWorkflowInstanceStateCountByProject(User loginUser, WorkflowInstanceCountVO getWorkflowInstanceStateCountByProject(User loginUser,
Long projectCodes, Long projectCodes,
String startDate, String startDate,
String endDate); String endDate);
WorkflowInstanceCountVo getAllWorkflowInstanceStateCount(User loginUser, WorkflowInstanceCountVO getAllWorkflowInstanceStateCount(User loginUser,
String startDate, String startDate,
String endDate); String endDate);
WorkflowDefinitionCountVo getWorkflowDefinitionCountByProject(User loginUser, Long projectCode); WorkflowDefinitionCountVO getWorkflowDefinitionCountByProject(User loginUser, Long projectCode);
WorkflowDefinitionCountVo getAllWorkflowDefinitionCount(User loginUser); WorkflowDefinitionCountVO getAllWorkflowDefinitionCount(User loginUser);
/** /**
* statistics the workflow quantities of certain user * statistics the workflow quantities of certain user

36
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataAnalysisServiceImpl.java

@ -27,9 +27,9 @@ import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.DataAnalysisService; import org.apache.dolphinscheduler.api.service.DataAnalysisService;
import org.apache.dolphinscheduler.api.service.ProjectService; import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVo; import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowDefinitionCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVO;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.CommandType;
@ -105,7 +105,7 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
private TaskDefinitionMapper taskDefinitionMapper; private TaskDefinitionMapper taskDefinitionMapper;
@Override @Override
public TaskInstanceCountVo getTaskInstanceStateCountByProject(User loginUser, public TaskInstanceCountVO getTaskInstanceStateCountByProject(User loginUser,
Long projectCode, Long projectCode,
String startDate, String startDate,
String endDate) { String endDate) {
@ -114,26 +114,26 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
Date end = endDate == null ? null : transformDate(endDate); Date end = endDate == null ? null : transformDate(endDate);
List<TaskInstanceStatusCountDto> taskInstanceStatusCounts = List<TaskInstanceStatusCountDto> taskInstanceStatusCounts =
taskInstanceMapper.countTaskInstanceStateByProjectCodes(start, end, Lists.newArrayList(projectCode)); taskInstanceMapper.countTaskInstanceStateByProjectCodes(start, end, Lists.newArrayList(projectCode));
return TaskInstanceCountVo.of(taskInstanceStatusCounts); return TaskInstanceCountVO.of(taskInstanceStatusCounts);
} }
@Override @Override
public TaskInstanceCountVo getAllTaskInstanceStateCount(User loginUser, public TaskInstanceCountVO getAllTaskInstanceStateCount(User loginUser,
String startDate, String startDate,
String endDate) { String endDate) {
List<Long> projectCodes = projectService.getAuthorizedProjectCodes(loginUser); List<Long> projectCodes = projectService.getAuthorizedProjectCodes(loginUser);
if (CollectionUtils.isEmpty(projectCodes)) { if (CollectionUtils.isEmpty(projectCodes)) {
return TaskInstanceCountVo.empty(); return TaskInstanceCountVO.empty();
} }
Date start = startDate == null ? null : transformDate(startDate); Date start = startDate == null ? null : transformDate(startDate);
Date end = endDate == null ? null : transformDate(endDate); Date end = endDate == null ? null : transformDate(endDate);
List<TaskInstanceStatusCountDto> taskInstanceStatusCounts = List<TaskInstanceStatusCountDto> taskInstanceStatusCounts =
taskInstanceMapper.countTaskInstanceStateByProjectCodes(start, end, projectCodes); taskInstanceMapper.countTaskInstanceStateByProjectCodes(start, end, projectCodes);
return TaskInstanceCountVo.of(taskInstanceStatusCounts); return TaskInstanceCountVO.of(taskInstanceStatusCounts);
} }
@Override @Override
public WorkflowInstanceCountVo getWorkflowInstanceStateCountByProject(User loginUser, public WorkflowInstanceCountVO getWorkflowInstanceStateCountByProject(User loginUser,
Long projectCode, Long projectCode,
String startDate, String startDate,
String endDate) { String endDate) {
@ -142,40 +142,40 @@ public class DataAnalysisServiceImpl extends BaseServiceImpl implements DataAnal
Date end = endDate == null ? null : transformDate(endDate); Date end = endDate == null ? null : transformDate(endDate);
List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCountDtos = processInstanceMapper List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCountDtos = processInstanceMapper
.countWorkflowInstanceStateByProjectCodes(start, end, Lists.newArrayList(projectCode)); .countWorkflowInstanceStateByProjectCodes(start, end, Lists.newArrayList(projectCode));
return WorkflowInstanceCountVo.of(workflowInstanceStatusCountDtos); return WorkflowInstanceCountVO.of(workflowInstanceStatusCountDtos);
} }
@Override @Override
public WorkflowInstanceCountVo getAllWorkflowInstanceStateCount(User loginUser, public WorkflowInstanceCountVO getAllWorkflowInstanceStateCount(User loginUser,
String startDate, String startDate,
String endDate) { String endDate) {
List<Long> projectCodes = projectService.getAuthorizedProjectCodes(loginUser); List<Long> projectCodes = projectService.getAuthorizedProjectCodes(loginUser);
if (CollectionUtils.isEmpty(projectCodes)) { if (CollectionUtils.isEmpty(projectCodes)) {
return WorkflowInstanceCountVo.empty(); return WorkflowInstanceCountVO.empty();
} }
Date start = startDate == null ? null : transformDate(startDate); Date start = startDate == null ? null : transformDate(startDate);
Date end = endDate == null ? null : transformDate(endDate); Date end = endDate == null ? null : transformDate(endDate);
List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCountDtos = List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCountDtos =
processInstanceMapper.countWorkflowInstanceStateByProjectCodes(start, end, projectCodes); processInstanceMapper.countWorkflowInstanceStateByProjectCodes(start, end, projectCodes);
return WorkflowInstanceCountVo.of(workflowInstanceStatusCountDtos); return WorkflowInstanceCountVO.of(workflowInstanceStatusCountDtos);
} }
@Override @Override
public WorkflowDefinitionCountVo getWorkflowDefinitionCountByProject(User loginUser, Long projectCode) { public WorkflowDefinitionCountVO getWorkflowDefinitionCountByProject(User loginUser, Long projectCode) {
projectService.checkProjectAndAuthThrowException(loginUser, projectCode, PROJECT_OVERVIEW); projectService.checkProjectAndAuthThrowException(loginUser, projectCode, PROJECT_OVERVIEW);
List<WorkflowDefinitionCountDto> workflowDefinitionCounts = List<WorkflowDefinitionCountDto> workflowDefinitionCounts =
processDefinitionMapper.countDefinitionByProjectCodes(Lists.newArrayList(projectCode)); processDefinitionMapper.countDefinitionByProjectCodes(Lists.newArrayList(projectCode));
return WorkflowDefinitionCountVo.of(workflowDefinitionCounts); return WorkflowDefinitionCountVO.of(workflowDefinitionCounts);
} }
@Override @Override
public WorkflowDefinitionCountVo getAllWorkflowDefinitionCount(User loginUser) { public WorkflowDefinitionCountVO getAllWorkflowDefinitionCount(User loginUser) {
List<Long> projectCodes = projectService.getAuthorizedProjectCodes(loginUser); List<Long> projectCodes = projectService.getAuthorizedProjectCodes(loginUser);
if (CollectionUtils.isEmpty(projectCodes)) { if (CollectionUtils.isEmpty(projectCodes)) {
return WorkflowDefinitionCountVo.empty(); return WorkflowDefinitionCountVO.empty();
} }
return WorkflowDefinitionCountVo.of(processDefinitionMapper.countDefinitionByProjectCodes(projectCodes)); return WorkflowDefinitionCountVO.of(processDefinitionMapper.countDefinitionByProjectCodes(projectCodes));
} }
@Override @Override

12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java

@ -31,7 +31,7 @@ import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.SchedulerService; import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.api.vo.ScheduleVo; import org.apache.dolphinscheduler.api.vo.ScheduleVO;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.Priority;
@ -462,12 +462,12 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
scheduleMapper.queryByProjectAndProcessDefineCodePaging(page, projectCode, processDefineCode, scheduleMapper.queryByProjectAndProcessDefineCodePaging(page, projectCode, processDefineCode,
searchVal); searchVal);
List<ScheduleVo> scheduleList = new ArrayList<>(); List<ScheduleVO> scheduleList = new ArrayList<>();
for (Schedule schedule : schedulePage.getRecords()) { for (Schedule schedule : schedulePage.getRecords()) {
scheduleList.add(new ScheduleVo(schedule)); scheduleList.add(new ScheduleVO(schedule));
} }
PageInfo<ScheduleVo> pageInfo = new PageInfo<>(pageNo, pageSize); PageInfo<ScheduleVO> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotal((int) schedulePage.getTotal()); pageInfo.setTotal((int) schedulePage.getTotal());
pageInfo.setTotalList(scheduleList); pageInfo.setTotalList(scheduleList);
result.setData(pageInfo); result.setData(pageInfo);
@ -528,9 +528,9 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
} }
List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(project.getName()); List<Schedule> schedules = scheduleMapper.querySchedulerListByProjectName(project.getName());
List<ScheduleVo> scheduleList = new ArrayList<>(); List<ScheduleVO> scheduleList = new ArrayList<>();
for (Schedule schedule : schedules) { for (Schedule schedule : schedules) {
scheduleList.add(new ScheduleVo(schedule)); scheduleList.add(new ScheduleVO(schedule));
} }
result.put(Constants.DATA_LIST, scheduleList); result.put(Constants.DATA_LIST, scheduleList);

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskDefinitionServiceImpl.java

@ -39,7 +39,7 @@ import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.TaskDefinitionService; import org.apache.dolphinscheduler.api.service.TaskDefinitionService;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.api.vo.TaskDefinitionVo; import org.apache.dolphinscheduler.api.vo.TaskDefinitionVO;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.ConditionType; import org.apache.dolphinscheduler.common.enums.ConditionType;
@ -1167,7 +1167,7 @@ public class TaskDefinitionServiceImpl extends BaseServiceImpl implements TaskDe
taskRelationList = taskRelationList.stream() taskRelationList = taskRelationList.stream()
.filter(v -> v.getPreTaskCode() != 0).collect(Collectors.toList()); .filter(v -> v.getPreTaskCode() != 0).collect(Collectors.toList());
} }
TaskDefinitionVo taskDefinitionVo = TaskDefinitionVo.fromTaskDefinition(taskDefinition); TaskDefinitionVO taskDefinitionVo = TaskDefinitionVO.fromTaskDefinition(taskDefinition);
taskDefinitionVo.setProcessTaskRelationList(taskRelationList); taskDefinitionVo.setProcessTaskRelationList(taskRelationList);
result.put(Constants.DATA_LIST, taskDefinitionVo); result.put(Constants.DATA_LIST, taskDefinitionVo);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);

4
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/ScheduleVo.java → dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/ScheduleVO.java

@ -30,7 +30,7 @@ import java.util.Date;
import lombok.Data; import lombok.Data;
@Data @Data
public class ScheduleVo { public class ScheduleVO {
private int id; private int id;
@ -140,7 +140,7 @@ public class ScheduleVo {
*/ */
private String environmentName; private String environmentName;
public ScheduleVo(Schedule schedule) { public ScheduleVO(Schedule schedule) {
this.setId(schedule.getId()); this.setId(schedule.getId());
this.setCrontab(schedule.getCrontab()); this.setCrontab(schedule.getCrontab());
this.setProjectName(schedule.getProjectName()); this.setProjectName(schedule.getProjectName());

10
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskDefinitionVo.java → dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskDefinitionVO.java

@ -31,22 +31,22 @@ import org.springframework.beans.BeanUtils;
* @author fanwanlong * @author fanwanlong
*/ */
@Data @Data
public class TaskDefinitionVo extends TaskDefinition { public class TaskDefinitionVO extends TaskDefinition {
/** /**
* process task related list * process task related list
*/ */
private List<ProcessTaskRelation> processTaskRelationList; private List<ProcessTaskRelation> processTaskRelationList;
public TaskDefinitionVo() { public TaskDefinitionVO() {
} }
public TaskDefinitionVo(List<ProcessTaskRelation> processTaskRelationList) { public TaskDefinitionVO(List<ProcessTaskRelation> processTaskRelationList) {
this.processTaskRelationList = processTaskRelationList; this.processTaskRelationList = processTaskRelationList;
} }
public static TaskDefinitionVo fromTaskDefinition(TaskDefinition taskDefinition) { public static TaskDefinitionVO fromTaskDefinition(TaskDefinition taskDefinition) {
TaskDefinitionVo taskDefinitionVo = new TaskDefinitionVo(); TaskDefinitionVO taskDefinitionVo = new TaskDefinitionVO();
BeanUtils.copyProperties(taskDefinition, taskDefinitionVo); BeanUtils.copyProperties(taskDefinition, taskDefinitionVo);
if (TimeoutFlag.CLOSE == taskDefinition.getTimeoutFlag()) { if (TimeoutFlag.CLOSE == taskDefinition.getTimeoutFlag()) {
taskDefinitionVo.setTimeoutNotifyStrategy(null); taskDefinitionVo.setTimeoutNotifyStrategy(null);

8
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskInstanceCountVo.java → dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/TaskInstanceCountVO.java

@ -34,17 +34,17 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class TaskInstanceCountVo { public class TaskInstanceCountVO {
private int totalCount; private int totalCount;
private List<TaskInstanceStatusCountDto> taskInstanceStatusCounts; private List<TaskInstanceStatusCountDto> taskInstanceStatusCounts;
public static TaskInstanceCountVo empty() { public static TaskInstanceCountVO empty() {
return of(Collections.emptyList()); return of(Collections.emptyList());
} }
public static TaskInstanceCountVo of(List<TaskInstanceStatusCountDto> taskInstanceStatusCounts) { public static TaskInstanceCountVO of(List<TaskInstanceStatusCountDto> taskInstanceStatusCounts) {
taskInstanceStatusCounts = new ArrayList<>(taskInstanceStatusCounts); taskInstanceStatusCounts = new ArrayList<>(taskInstanceStatusCounts);
Map<TaskExecutionStatus, TaskInstanceStatusCountDto> taskInstanceStatusCountMap = Map<TaskExecutionStatus, TaskInstanceStatusCountDto> taskInstanceStatusCountMap =
@ -57,7 +57,7 @@ public class TaskInstanceCountVo {
} }
} }
TaskInstanceCountVo taskInstanceCountVo = new TaskInstanceCountVo(); TaskInstanceCountVO taskInstanceCountVo = new TaskInstanceCountVO();
taskInstanceCountVo.setTaskInstanceStatusCounts(taskInstanceStatusCounts); taskInstanceCountVo.setTaskInstanceStatusCounts(taskInstanceStatusCounts);
taskInstanceCountVo taskInstanceCountVo
.setTotalCount(taskInstanceStatusCounts.stream().mapToInt(TaskInstanceStatusCountDto::getCount).sum()); .setTotalCount(taskInstanceStatusCounts.stream().mapToInt(TaskInstanceStatusCountDto::getCount).sum());

10
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowDefinitionCountVo.java → dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowDefinitionCountVO.java

@ -31,21 +31,21 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class WorkflowDefinitionCountVo { public class WorkflowDefinitionCountVO {
private int count; private int count;
private List<WorkflowDefinitionCountDto> userList; private List<WorkflowDefinitionCountDto> userList;
public static WorkflowDefinitionCountVo empty() { public static WorkflowDefinitionCountVO empty() {
return new WorkflowDefinitionCountVo(0, Collections.emptyList()); return new WorkflowDefinitionCountVO(0, Collections.emptyList());
} }
public static WorkflowDefinitionCountVo of(List<WorkflowDefinitionCountDto> workflowDefinitionCounts) { public static WorkflowDefinitionCountVO of(List<WorkflowDefinitionCountDto> workflowDefinitionCounts) {
if (CollectionUtils.isEmpty(workflowDefinitionCounts)) { if (CollectionUtils.isEmpty(workflowDefinitionCounts)) {
return empty(); return empty();
} }
WorkflowDefinitionCountVo workflowDefinitionCountVo = new WorkflowDefinitionCountVo(); WorkflowDefinitionCountVO workflowDefinitionCountVo = new WorkflowDefinitionCountVO();
workflowDefinitionCountVo.setUserList(workflowDefinitionCounts); workflowDefinitionCountVo.setUserList(workflowDefinitionCounts);
workflowDefinitionCountVo workflowDefinitionCountVo
.setCount(workflowDefinitionCounts.stream().mapToInt(WorkflowDefinitionCountDto::getCount).sum()); .setCount(workflowDefinitionCounts.stream().mapToInt(WorkflowDefinitionCountDto::getCount).sum());

8
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowInstanceCountVo.java → dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/vo/WorkflowInstanceCountVO.java

@ -34,17 +34,17 @@ import lombok.NoArgsConstructor;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class WorkflowInstanceCountVo { public class WorkflowInstanceCountVO {
private int totalCount; private int totalCount;
private List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCounts; private List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCounts;
public static WorkflowInstanceCountVo empty() { public static WorkflowInstanceCountVO empty() {
return of(Collections.emptyList()); return of(Collections.emptyList());
} }
public static WorkflowInstanceCountVo of(List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCountDtos) { public static WorkflowInstanceCountVO of(List<WorkflowInstanceStatusCountDto> workflowInstanceStatusCountDtos) {
workflowInstanceStatusCountDtos = new ArrayList<>(workflowInstanceStatusCountDtos); workflowInstanceStatusCountDtos = new ArrayList<>(workflowInstanceStatusCountDtos);
Map<WorkflowExecutionStatus, WorkflowInstanceStatusCountDto> workflowExecutionStatusWorkflowInstanceStatusCountMap = Map<WorkflowExecutionStatus, WorkflowInstanceStatusCountDto> workflowExecutionStatusWorkflowInstanceStatusCountMap =
@ -56,7 +56,7 @@ public class WorkflowInstanceCountVo {
} }
} }
WorkflowInstanceCountVo workflowInstanceCountVo = new WorkflowInstanceCountVo(); WorkflowInstanceCountVO workflowInstanceCountVo = new WorkflowInstanceCountVO();
workflowInstanceCountVo.setWorkflowInstanceStatusCounts(workflowInstanceStatusCountDtos); workflowInstanceCountVo.setWorkflowInstanceStatusCounts(workflowInstanceStatusCountDtos);
workflowInstanceCountVo.setTotalCount( workflowInstanceCountVo.setTotalCount(
workflowInstanceStatusCountDtos.stream().mapToInt(WorkflowInstanceStatusCountDto::getCount).sum()); workflowInstanceStatusCountDtos.stream().mapToInt(WorkflowInstanceStatusCountDto::getCount).sum());

12
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/DataAnalysisControllerTest.java

@ -24,8 +24,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVo; import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVO;
import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVo; import org.apache.dolphinscheduler.api.vo.WorkflowInstanceCountVO;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.Project; import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
@ -77,8 +77,8 @@ public class DataAnalysisControllerTest extends AbstractControllerTest {
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn(); .andReturn();
Result<TaskInstanceCountVo> result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result<TaskInstanceCountVO> result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(),
new TypeReference<Result<TaskInstanceCountVo>>() { new TypeReference<Result<TaskInstanceCountVO>>() {
}); });
assertThat(result.getCode()) assertThat(result.getCode())
.isNotNull() .isNotNull()
@ -101,8 +101,8 @@ public class DataAnalysisControllerTest extends AbstractControllerTest {
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn(); .andReturn();
Result<WorkflowInstanceCountVo> result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result<WorkflowInstanceCountVO> result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(),
new TypeReference<Result<WorkflowInstanceCountVo>>() { new TypeReference<Result<WorkflowInstanceCountVO>>() {
}); });
assertThat(result.getCode()) assertThat(result.getCode())
.isEqualTo(Status.SUCCESS.getCode()); .isEqualTo(Status.SUCCESS.getCode());

4
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DataAnalysisServiceTest.java

@ -32,7 +32,7 @@ import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService; import org.apache.dolphinscheduler.api.permission.ResourcePermissionCheckService;
import org.apache.dolphinscheduler.api.service.impl.DataAnalysisServiceImpl; import org.apache.dolphinscheduler.api.service.impl.DataAnalysisServiceImpl;
import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVo; import org.apache.dolphinscheduler.api.vo.TaskInstanceCountVO;
import org.apache.dolphinscheduler.common.constants.Constants; import org.apache.dolphinscheduler.common.constants.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.CommandType;
@ -201,7 +201,7 @@ public class DataAnalysisServiceTest {
user.setUserType(UserType.GENERAL_USER); user.setUserType(UserType.GENERAL_USER);
when(taskInstanceMapper.countTaskInstanceStateByProjectCodes(any(), any(), any())) when(taskInstanceMapper.countTaskInstanceStateByProjectCodes(any(), any(), any()))
.thenReturn(Collections.emptyList()); .thenReturn(Collections.emptyList());
TaskInstanceCountVo taskInstanceStateCountByProject = TaskInstanceCountVO taskInstanceStateCountByProject =
dataAnalysisServiceImpl.getTaskInstanceStateCountByProject(user, 1L, null, null); dataAnalysisServiceImpl.getTaskInstanceStateCountByProject(user, 1L, null, null);
assertThat(taskInstanceStateCountByProject).isNotNull(); assertThat(taskInstanceStateCountByProject).isNotNull();
} }

Loading…
Cancel
Save