Search in sources :

Example 1 with TypeToken

use of org.modelmapper.TypeToken in project agile-service by open-hand.

the class StateMachineNodeServiceImpl method queryByStateMachineId.

@Override
public List<StatusMachineNodeVO> queryByStateMachineId(Long organizationId, Long stateMachineId, Boolean isDraft) {
    List<StatusMachineNodeVO> nodeVOS;
    if (Boolean.TRUE.equals(isDraft)) {
        // 获取节点
        List<StateMachineNodeDraftDTO> nodes = nodeDraftMapper.selectByStateMachineId(stateMachineId);
        Map<Long, StatusDTO> map = nodes.stream().filter(x -> x.getStatus() != null).collect(Collectors.toMap(StateMachineNodeDraftDTO::getId, StateMachineNodeDraftDTO::getStatus));
        nodeVOS = modelMapper.map(nodes, new TypeToken<List<StatusMachineNodeVO>>() {
        }.getType());
        for (StatusMachineNodeVO nodeVO : nodeVOS) {
            StatusDTO status = map.get(nodeVO.getId());
            if (status != null) {
                nodeVO.setStatusVO(modelMapper.map(status, StatusVO.class));
            }
        }
    } else {
        List<StatusMachineNodeDTO> nodes = nodeDeployMapper.selectByStateMachineId(stateMachineId);
        Map<Long, StatusDTO> map = nodes.stream().filter(x -> x.getStatus() != null).collect(Collectors.toMap(StatusMachineNodeDTO::getId, StatusMachineNodeDTO::getStatus));
        nodeVOS = modelMapper.map(nodes, new TypeToken<List<StatusMachineNodeVO>>() {
        }.getType());
        for (StatusMachineNodeVO nodeVO : nodeVOS) {
            StatusDTO status = map.get(nodeVO.getId());
            if (status != null) {
                nodeVO.setStatusVO(modelMapper.map(status, StatusVO.class));
            }
        }
    }
    return nodeVOS;
}
Also used : StateMachineNodeService(io.choerodon.agile.app.service.StateMachineNodeService) java.util(java.util) StatusVO(io.choerodon.agile.api.vo.StatusVO) TypeToken(org.modelmapper.TypeToken) StatusMachineTransformVO(io.choerodon.agile.api.vo.StatusMachineTransformVO) NodeSortVO(io.choerodon.agile.api.vo.NodeSortVO) ObjectUtils(org.springframework.util.ObjectUtils) StateMachineClientService(io.choerodon.agile.app.service.StateMachineClientService) io.choerodon.agile.infra.mapper(io.choerodon.agile.infra.mapper) Autowired(org.springframework.beans.factory.annotation.Autowired) io.choerodon.agile.infra.dto(io.choerodon.agile.infra.dto) StatusMachineNodeVO(io.choerodon.agile.api.vo.StatusMachineNodeVO) StateMachineService(io.choerodon.agile.app.service.StateMachineService) Collectors(java.util.stream.Collectors) RankUtil(io.choerodon.agile.infra.utils.RankUtil) ModelMapper(org.modelmapper.ModelMapper) io.choerodon.agile.infra.enums(io.choerodon.agile.infra.enums) Service(org.springframework.stereotype.Service) CollectionUtils(org.springframework.util.CollectionUtils) ChangeStateMachineStatus(io.choerodon.agile.infra.annotation.ChangeStateMachineStatus) CommonException(io.choerodon.core.exception.CommonException) BeanUtils(org.springframework.beans.BeanUtils) Transactional(org.springframework.transaction.annotation.Transactional) StatusMachineNodeVO(io.choerodon.agile.api.vo.StatusMachineNodeVO) StatusVO(io.choerodon.agile.api.vo.StatusVO)

Example 2 with TypeToken

use of org.modelmapper.TypeToken in project agile-service by open-hand.

the class PriorityServiceImpl method queryByOrganizationId.

@Override
public Map<Long, PriorityVO> queryByOrganizationId(Long organizationId) {
    PriorityDTO priority = new PriorityDTO();
    priority.setOrganizationId(organizationId);
    List<PriorityDTO> priorities = priorityMapper.select(priority);
    if (CollectionUtils.isEmpty(priorities)) {
        return new HashMap<>();
    }
    Map<Long, PriorityVO> result = new HashMap<>();
    List<PriorityVO> priorityVOS = modelMapper.map(priorities, new TypeToken<List<PriorityVO>>() {
    }.getType());
    result.putAll(priorityVOS.stream().collect(Collectors.toMap(PriorityVO::getId, Function.identity())));
    return result;
}
Also used : PriorityDTO(io.choerodon.agile.infra.dto.PriorityDTO) TypeToken(org.modelmapper.TypeToken) PriorityVO(io.choerodon.agile.api.vo.PriorityVO)

Example 3 with TypeToken

use of org.modelmapper.TypeToken in project agile-service by open-hand.

the class PriorityServiceImpl method queryDefaultByOrganizationId.

@Override
public PriorityVO queryDefaultByOrganizationId(Long organizationId) {
    PriorityDTO priority = new PriorityDTO();
    priority.setOrganizationId(organizationId);
    priority.setDefault(true);
    PriorityDTO result = priorityMapper.selectOne(priority);
    if (result == null) {
        throw new CommonException(NOT_FOUND);
    }
    return modelMapper.map(result, new TypeToken<PriorityVO>() {
    }.getType());
}
Also used : PriorityDTO(io.choerodon.agile.infra.dto.PriorityDTO) TypeToken(org.modelmapper.TypeToken) CommonException(io.choerodon.core.exception.CommonException)

Example 4 with TypeToken

use of org.modelmapper.TypeToken in project agile-service by open-hand.

the class QuickFilterServiceImpl method listByProjectId.

@Override
public Page<QuickFilterVO> listByProjectId(Long projectId, QuickFilterSearchVO quickFilterSearchVO, PageRequest pageRequest) {
    boolean isFirstPage = (pageRequest.getPage() == 0);
    List<Long> topIds = quickFilterSearchVO.getQuickFilterIds();
    List<QuickFilterDTO> list = new ArrayList<>();
    if (isFirstPage && !ObjectUtils.isEmpty(topIds)) {
        QuickFilterSearchVO search = new QuickFilterSearchVO();
        search.setQuickFilterIds(topIds);
        list.addAll(quickFilterMapper.queryFiltersByProjectId(projectId, search));
    }
    quickFilterSearchVO.setQuickFilterIds(null);
    quickFilterSearchVO.setIgnoredQuickFilterIds(topIds);
    Page<QuickFilterDTO> page = PageHelper.doPageAndSort(pageRequest, () -> quickFilterMapper.queryFiltersByProjectId(projectId, quickFilterSearchVO));
    list.addAll(page.getContent());
    list.forEach(v -> v.setDescription(handlerFilterDescription(v.getDescription(), true)));
    if (list.isEmpty()) {
        return PageUtil.emptyPage(pageRequest.getPage(), pageRequest.getSize());
    }
    List<QuickFilterVO> result = modelMapper.map(list, new TypeToken<List<QuickFilterVO>>() {
    }.getType());
    return PageUtil.buildPageInfoWithPageInfoList(page, result);
}
Also used : QuickFilterDTO(io.choerodon.agile.infra.dto.QuickFilterDTO) TypeToken(org.modelmapper.TypeToken) QuickFilterSearchVO(io.choerodon.agile.api.vo.QuickFilterSearchVO) QuickFilterVO(io.choerodon.agile.api.vo.QuickFilterVO)

Example 5 with TypeToken

use of org.modelmapper.TypeToken in project agile-service by open-hand.

the class IssuePredecessorServiceImpl method queryByIssueId.

@Override
public List<IssuePredecessorVO> queryByIssueId(Long projectId, Long currentIssueId, boolean withInfo) {
    IssuePredecessorDTO dto = new IssuePredecessorDTO();
    dto.setOrganizationId(ConvertUtil.getOrganizationId(projectId));
    dto.setProjectId(projectId);
    dto.setIssueId(currentIssueId);
    List<IssuePredecessorDTO> dtoList = issuePredecessorMapper.select(dto);
    ModelMapper modelMapper = new ModelMapper();
    List<IssuePredecessorVO> result = modelMapper.map(dtoList, new TypeToken<List<IssuePredecessorVO>>() {
    }.getType());
    if (Boolean.TRUE.equals(withInfo) && !CollectionUtils.isEmpty(result)) {
        Long organizationId = ConvertUtil.getOrganizationId(projectId);
        List<Long> issueIds = result.stream().map(IssuePredecessorVO::getPredecessorId).collect(Collectors.toList());
        // 类型、概要、编号、优先级、状态、经办人
        List<IssueDTO> issueDTOList = issueMapper.queryIssueListWithSubByIssueIds(issueIds, null, false, false);
        Map<Long, PriorityVO> priorityMap = priorityService.queryByOrganizationId(organizationId);
        Map<Long, StatusVO> statusMapDTOMap = statusService.queryAllStatusMap(organizationId);
        Map<Long, IssueTypeVO> issueTypeDTOMap = issueTypeService.listIssueTypeMap(organizationId, projectId);
        List<IssueListVO> issueList = issueAssembler.issueDoToIssueListDto(issueDTOList, priorityMap, statusMapDTOMap, issueTypeDTOMap);
        Map<Long, IssueListVO> issueMap = issueList.stream().collect(Collectors.toMap(IssueListVO::getIssueId, Function.identity()));
        result.forEach(vo -> vo.setPredecessorIssueVO(issueMap.get(vo.getPredecessorId())));
    }
    return result;
}
Also used : ModelMapper(org.modelmapper.ModelMapper) IssueListVO(io.choerodon.agile.api.vo.business.IssueListVO) IssuePredecessorDTO(io.choerodon.agile.infra.dto.IssuePredecessorDTO) TypeToken(org.modelmapper.TypeToken) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO)

Aggregations

TypeToken (org.modelmapper.TypeToken)33 CommonException (io.choerodon.core.exception.CommonException)12 ModelMapper (org.modelmapper.ModelMapper)7 Collectors (java.util.stream.Collectors)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 PriorityDTO (io.choerodon.agile.infra.dto.PriorityDTO)4 UserMessageDTO (io.choerodon.agile.infra.dto.UserMessageDTO)4 java.util (java.util)4 PriorityVO (io.choerodon.agile.api.vo.PriorityVO)3 Page (io.choerodon.core.domain.Page)3 PageRequest (io.choerodon.mybatis.pagehelper.domain.PageRequest)3 ArrayList (java.util.ArrayList)3 Service (org.springframework.stereotype.Service)3 Transactional (org.springframework.transaction.annotation.Transactional)3 ObjectUtils (org.springframework.util.ObjectUtils)3 IssueCommentDTO (io.choerodon.agile.infra.dto.IssueCommentDTO)2 LinkIssueStatusLinkageDTO (io.choerodon.agile.infra.dto.LinkIssueStatusLinkageDTO)2 IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)2 PageHelper (io.choerodon.mybatis.pagehelper.PageHelper)2 TestCycleCaseAttachmentRelVO (io.choerodon.test.manager.api.vo.TestCycleCaseAttachmentRelVO)2