Search in sources :

Example 1 with StatusVO

use of io.choerodon.agile.api.vo.StatusVO in project agile-service by open-hand.

the class IssueStatusServiceImpl method create.

@Override
public IssueStatusVO create(Long projectId, String applyType, IssueStatusVO issueStatusVO) {
    IssueStatusValidator.checkCreateStatus(projectId, issueStatusVO);
    StatusVO statusVO = new StatusVO();
    statusVO.setType(issueStatusVO.getCategoryCode());
    statusVO.setName(issueStatusVO.getName());
    statusVO = projectConfigService.createStatusForAgile(projectId, applyType, statusVO);
    if (statusVO != null && statusVO.getId() != null) {
        Long statusId = statusVO.getId();
        if (issueStatusMapper.selectByStatusId(projectId, statusId) != null) {
            throw new CommonException("error.status.exist");
        }
        issueStatusVO.setCompleted(false);
        issueStatusVO.setStatusId(statusId);
        IssueStatusDTO issueStatusDTO = modelMapper.map(issueStatusVO, IssueStatusDTO.class);
        return modelMapper.map(insertIssueStatus(issueStatusDTO), IssueStatusVO.class);
    } else {
        throw new CommonException("error.status.create");
    }
}
Also used : CommonException(io.choerodon.core.exception.CommonException) StatusVO(io.choerodon.agile.api.vo.StatusVO) IssueStatusVO(io.choerodon.agile.api.vo.IssueStatusVO)

Example 2 with StatusVO

use of io.choerodon.agile.api.vo.StatusVO in project agile-service by open-hand.

the class IssueLinkAssembler method issueLinkDTOToVO.

public List<IssueLinkVO> issueLinkDTOToVO(Long projectId, List<IssueLinkDTO> issueLinkDTOList) {
    List<IssueLinkVO> issueLinkVOList = new ArrayList<>(issueLinkDTOList.size());
    if (!issueLinkDTOList.isEmpty()) {
        Map<Long, IssueTypeVO> testIssueTypeDTOMap = ConvertUtil.getIssueTypeMap(projectId, SchemeApplyType.TEST);
        Map<Long, IssueTypeVO> agileIssueTypeDTOMap = ConvertUtil.getIssueTypeMap(projectId, SchemeApplyType.AGILE);
        Map<Long, StatusVO> statusMapDTOMap = ConvertUtil.getIssueStatusMap(projectId);
        Map<Long, PriorityVO> priorityDTOMap = ConvertUtil.getIssuePriorityMap(projectId);
        List<Long> assigneeIds = issueLinkDTOList.stream().filter(issue -> issue.getAssigneeId() != null && !Objects.equals(issue.getAssigneeId(), 0L)).map(IssueLinkDTO::getAssigneeId).distinct().collect(Collectors.toList());
        Map<Long, UserMessageDTO> usersMap = userService.queryUsersMap(assigneeIds, true);
        issueLinkDTOList.forEach(issueLinkDO -> {
            String assigneeName = usersMap.get(issueLinkDO.getAssigneeId()) != null ? usersMap.get(issueLinkDO.getAssigneeId()).getName() : null;
            String imageUrl = assigneeName != null ? usersMap.get(issueLinkDO.getAssigneeId()).getImageUrl() : null;
            IssueLinkVO issueLinkVO = new IssueLinkVO();
            BeanUtils.copyProperties(issueLinkDO, issueLinkVO);
            if (issueLinkDO.getApplyType().equals(SchemeApplyType.TEST)) {
                issueLinkVO.setIssueTypeVO(testIssueTypeDTOMap.get(issueLinkDO.getIssueTypeId()));
            } else {
                issueLinkVO.setIssueTypeVO(agileIssueTypeDTOMap.get(issueLinkDO.getIssueTypeId()));
            }
            issueLinkVO.setStatusVO(statusMapDTOMap.get(issueLinkDO.getStatusId()));
            issueLinkVO.setPriorityVO(priorityDTOMap.get(issueLinkDO.getPriorityId()));
            issueLinkVO.setAssigneeName(assigneeName);
            issueLinkVO.setImageUrl(imageUrl);
            issueLinkVOList.add(issueLinkVO);
        });
    }
    return issueLinkVOList;
}
Also used : StatusVO(io.choerodon.agile.api.vo.StatusVO) IssueTypeVO(io.choerodon.agile.api.vo.IssueTypeVO) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) PriorityVO(io.choerodon.agile.api.vo.PriorityVO) Objects(java.util.Objects) IssueLinkDTO(io.choerodon.agile.infra.dto.IssueLinkDTO) Component(org.springframework.stereotype.Component) List(java.util.List) SchemeApplyType(io.choerodon.agile.infra.enums.SchemeApplyType) Map(java.util.Map) UserService(io.choerodon.agile.app.service.UserService) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) ConvertUtil(io.choerodon.agile.infra.utils.ConvertUtil) IssueLinkVO(io.choerodon.agile.api.vo.IssueLinkVO) BeanUtils(org.springframework.beans.BeanUtils) ArrayList(java.util.ArrayList) IssueLinkDTO(io.choerodon.agile.infra.dto.IssueLinkDTO) IssueTypeVO(io.choerodon.agile.api.vo.IssueTypeVO) IssueLinkVO(io.choerodon.agile.api.vo.IssueLinkVO) UserMessageDTO(io.choerodon.agile.infra.dto.UserMessageDTO) StatusVO(io.choerodon.agile.api.vo.StatusVO) PriorityVO(io.choerodon.agile.api.vo.PriorityVO)

Example 3 with StatusVO

use of io.choerodon.agile.api.vo.StatusVO in project agile-service by open-hand.

the class IssueStatusServiceImpl method queryUnCorrespondStatus.

@Override
public List<StatusAndIssuesVO> queryUnCorrespondStatus(Long projectId, Long boardId, String applyType) {
    List<StatusVO> statusMapVOList = projectConfigService.queryStatusByProjectId(projectId, applyType);
    List<Long> realStatusIds = new ArrayList<>();
    for (StatusVO statusMapVO : statusMapVOList) {
        realStatusIds.add(statusMapVO.getId());
    }
    if (realStatusIds.isEmpty()) {
        return new ArrayList<>();
    }
    List<StatusAndIssuesDTO> statusAndIssuesDTOList = issueStatusMapper.queryUnCorrespondStatus(projectId, boardId, realStatusIds);
    if (statusAndIssuesDTOList != null && !statusAndIssuesDTOList.isEmpty()) {
        List<Long> ids = new ArrayList<>();
        for (StatusAndIssuesDTO statusAndIssuesDTO : statusAndIssuesDTOList) {
            ids.add(statusAndIssuesDTO.getStatusId());
        }
        Map<Long, StatusDTO> map = statusService.batchStatusGet(ids);
        for (StatusAndIssuesDTO statusAndIssuesDTO : statusAndIssuesDTOList) {
            StatusDTO status = map.get(statusAndIssuesDTO.getStatusId());
            statusAndIssuesDTO.setCategoryCode(status.getType());
            statusAndIssuesDTO.setName(status.getName());
        }
    }
    List<StatusAndIssuesVO> statusAndIssuesVOList = new ArrayList<>();
    if (statusAndIssuesDTOList != null) {
        statusAndIssuesVOList = modelMapper.map(statusAndIssuesDTOList, new TypeToken<List<StatusAndIssuesVO>>() {
        }.getType());
    }
    return statusAndIssuesVOList;
}
Also used : StatusAndIssuesVO(io.choerodon.agile.api.vo.StatusAndIssuesVO) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) StatusVO(io.choerodon.agile.api.vo.StatusVO) IssueStatusVO(io.choerodon.agile.api.vo.IssueStatusVO)

Aggregations

StatusVO (io.choerodon.agile.api.vo.StatusVO)3 IssueStatusVO (io.choerodon.agile.api.vo.IssueStatusVO)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 IssueLinkVO (io.choerodon.agile.api.vo.IssueLinkVO)1 IssueTypeVO (io.choerodon.agile.api.vo.IssueTypeVO)1 PriorityVO (io.choerodon.agile.api.vo.PriorityVO)1 StatusAndIssuesVO (io.choerodon.agile.api.vo.StatusAndIssuesVO)1 UserService (io.choerodon.agile.app.service.UserService)1 IssueLinkDTO (io.choerodon.agile.infra.dto.IssueLinkDTO)1 UserMessageDTO (io.choerodon.agile.infra.dto.UserMessageDTO)1 SchemeApplyType (io.choerodon.agile.infra.enums.SchemeApplyType)1 ConvertUtil (io.choerodon.agile.infra.utils.ConvertUtil)1 CommonException (io.choerodon.core.exception.CommonException)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 BeanUtils (org.springframework.beans.BeanUtils)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1