Search in sources :

Example 1 with WorkSpaceVO

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

the class WikiRelationServiceImpl method queryByIssueId.

@Override
public KnowledgeRelationVO queryByIssueId(Long projectId, Long issueId) {
    WikiRelationDTO wikiRelationDTO = new WikiRelationDTO();
    wikiRelationDTO.setIssueId(issueId);
    List<WikiRelationDTO> wikiRelationDTOList = wikiRelationMapper.select(wikiRelationDTO);
    List<WikiRelationVO> result = new ArrayList<>();
    if (wikiRelationDTOList != null && !wikiRelationDTOList.isEmpty()) {
        List<Long> spaceIds = wikiRelationDTOList.stream().map(WikiRelationDTO::getSpaceId).collect(Collectors.toList());
        Map<Long, WorkSpaceVO> workSpaceMap = new HashMap<>();
        workSpaceMap.putAll(knowledgebaseClientOperator.querySpaceByIds(projectId, spaceIds).stream().collect(Collectors.toMap(WorkSpaceVO::getId, Function.identity())));
        for (WikiRelationDTO wikiRelation : wikiRelationDTOList) {
            WorkSpaceVO workSpaceVO = workSpaceMap.get(wikiRelation.getSpaceId());
            if (!ObjectUtils.isEmpty(workSpaceVO)) {
                WikiRelationVO wikiRelationVO = new WikiRelationVO();
                BeanUtils.copyProperties(wikiRelation, wikiRelationVO);
                wikiRelationVO.setWorkSpaceVO(workSpaceVO);
                result.add(wikiRelationVO);
            }
        }
    }
    KnowledgeRelationVO knowledgeRelation = new KnowledgeRelationVO();
    knowledgeRelation.setKnowledgeRelationList(result);
    return knowledgeRelation;
}
Also used : KnowledgeRelationVO(io.choerodon.agile.api.vo.KnowledgeRelationVO) HashMap(java.util.HashMap) WikiRelationDTO(io.choerodon.agile.infra.dto.WikiRelationDTO) ArrayList(java.util.ArrayList) WikiRelationVO(io.choerodon.agile.api.vo.WikiRelationVO) WorkSpaceVO(io.choerodon.agile.api.vo.WorkSpaceVO)

Aggregations

KnowledgeRelationVO (io.choerodon.agile.api.vo.KnowledgeRelationVO)1 WikiRelationVO (io.choerodon.agile.api.vo.WikiRelationVO)1 WorkSpaceVO (io.choerodon.agile.api.vo.WorkSpaceVO)1 WikiRelationDTO (io.choerodon.agile.infra.dto.WikiRelationDTO)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1