Search in sources :

Example 26 with TypeToken

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

the class WikiRelationServiceImpl method create.

@Override
public void create(Long projectId, List<WikiRelationVO> wikiRelationVOList) {
    List<WikiRelationDTO> wikiRelationDTOList = modelMapper.map(wikiRelationVOList, new TypeToken<List<WikiRelationDTO>>() {
    }.getType());
    if (wikiRelationDTOList != null && !wikiRelationDTOList.isEmpty()) {
        for (WikiRelationDTO wikiRelationDTO : wikiRelationDTOList) {
            if (!checkRepeat(wikiRelationDTO)) {
                iWikiRelationService.createBase(wikiRelationDTO);
                BaseFieldUtil.updateIssueLastUpdateInfo(wikiRelationDTO.getIssueId(), wikiRelationDTO.getProjectId());
            }
        }
    }
}
Also used : TypeToken(org.modelmapper.TypeToken) WikiRelationDTO(io.choerodon.agile.infra.dto.WikiRelationDTO)

Example 27 with TypeToken

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

the class ConfigCodeServiceImpl method queryByType.

@Override
public List<ConfigCodeVO> queryByType(String type) {
    if (!EnumUtil.contain(ConfigType.class, type)) {
        throw new CommonException("error.status.type.illegal");
    }
    ConfigCodeDTO configCode = new ConfigCodeDTO();
    configCode.setType(type);
    List<ConfigCodeDTO> configCodes = configCodeMapper.select(configCode);
    return modelMapper.map(configCodes, new TypeToken<List<ConfigCodeVO>>() {
    }.getType());
}
Also used : TypeToken(org.modelmapper.TypeToken) CommonException(io.choerodon.core.exception.CommonException) ConfigType(io.choerodon.agile.infra.enums.ConfigType) ConfigCodeDTO(io.choerodon.agile.infra.dto.ConfigCodeDTO) ConfigCodeVO(io.choerodon.agile.api.vo.ConfigCodeVO)

Example 28 with TypeToken

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

the class CustomChartServiceImpl method queryListByProject.

@Override
public List<CustomChartVO> queryListByProject(Long projectId) {
    CustomChartDTO customChartRecord = new CustomChartDTO();
    customChartRecord.setProjectId(projectId);
    List<CustomChartDTO> customChartList = customChartMapper.select(customChartRecord);
    if (CollectionUtils.isEmpty(customChartList)) {
        return new ArrayList<>();
    }
    List<CustomChartVO> results = modelMapper.map(customChartList, new TypeToken<List<CustomChartVO>>() {
    }.getType());
    results.forEach(customChartVO -> {
        if (customChartVO.getSearchJson() != null) {
            customChartVO.setSearchJson(EncryptionUtils.handlerPersonFilterJson(customChartVO.getSearchJson(), true));
        }
    });
    return results;
}
Also used : CustomChartDTO(io.choerodon.agile.infra.dto.CustomChartDTO) TypeToken(org.modelmapper.TypeToken) CustomChartVO(io.choerodon.agile.api.vo.CustomChartVO) ArrayList(java.util.ArrayList)

Example 29 with TypeToken

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

the class StateMachineSchemeServiceImpl method querySchemeWithConfigById.

@Override
public StateMachineSchemeVO querySchemeWithConfigById(Boolean isDraft, Long organizationId, Long schemeId, Long projectId) {
    StateMachineSchemeDTO scheme = schemeMapper.selectByPrimaryKey(schemeId);
    if (scheme == null) {
        throw new CommonException("error.stateMachineScheme.notFound");
    }
    StateMachineSchemeVO schemeVO = modelMapper.map(scheme, StateMachineSchemeVO.class);
    // 处理配置信息
    List<StatusMachineSchemeConfigVO> configs = configService.queryBySchemeId(isDraft, organizationId, schemeId);
    Map<Long, List<IssueTypeDTO>> map = new HashMap<>(configs.size());
    // 取默认配置到第一个
    Long defaultStateMachineId = null;
    for (StatusMachineSchemeConfigVO config : configs) {
        List<IssueTypeDTO> issueTypes = map.get(config.getStateMachineId());
        if (issueTypes == null) {
            issueTypes = new ArrayList<>();
        }
        IssueTypeDTO issueType;
        if (!config.getDefault()) {
            issueType = issueTypeMapper.selectWithAlias(config.getIssueTypeId(), projectId);
        } else {
            // 若为默认配置,则匹配的是所有为分配的问题类型
            issueType = new IssueTypeDTO();
            issueType.setName(WITHOUT_CONFIG_ISSUE_TYPE_NAME);
            issueType.setIcon(WITHOUT_CONFIG_ISSUE_TYPE_ICON);
            issueType.setColour(WITHOUT_CONFIG_ISSUE_TYPE_COLOUR);
            defaultStateMachineId = config.getStateMachineId();
        }
        issueTypes.add(issueType);
        map.put(config.getStateMachineId(), issueTypes);
    }
    List<StateMachineSchemeConfigViewVO> viewVOS = new ArrayList<>();
    // 处理默认配置
    viewVOS.add(handleDefaultConfig(organizationId, defaultStateMachineId, map));
    for (Map.Entry<Long, List<IssueTypeDTO>> entry : map.entrySet()) {
        Long stateMachineId = entry.getKey();
        List<IssueTypeDTO> issueTypes = entry.getValue();
        StatusMachineVO statusMachineVO = stateMachineService.queryStateMachineById(organizationId, stateMachineId);
        StateMachineSchemeConfigViewVO viewVO = new StateMachineSchemeConfigViewVO();
        viewVO.setStatusMachineVO(statusMachineVO);
        List<IssueTypeVO> issueTypeVOS = modelMapper.map(issueTypes, new TypeToken<List<IssueTypeVO>>() {
        }.getType());
        viewVO.setIssueTypeVOS(issueTypeVOS);
        viewVOS.add(viewVO);
    }
    schemeVO.setViewVOS(viewVOS);
    AgilePluginService agilePluginService = SpringBeanUtil.getExpandBean(AgilePluginService.class);
    if (agilePluginService != null) {
        agilePluginService.addApplyTypesToStateMachine(schemeVO, schemeId);
    }
    return schemeVO;
}
Also used : StateMachineSchemeDTO(io.choerodon.agile.infra.dto.StateMachineSchemeDTO) IssueTypeDTO(io.choerodon.agile.infra.dto.IssueTypeDTO) TypeToken(org.modelmapper.TypeToken) CommonException(io.choerodon.core.exception.CommonException)

Example 30 with TypeToken

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

the class LookupValueServiceImpl method queryLookupValueByCode.

@Override
public LookupTypeWithValuesVO queryLookupValueByCode(String typeCode, Long projectId) {
    LookupTypeWithValuesDTO typeWithValues = lookupValueMapper.queryLookupValueByCode(typeCode);
    if (LookupType.CONTEXT.equals(typeCode) && !ObjectUtils.isEmpty(projectId)) {
        List<LookupValueDTO> backlogs = filterBacklog(projectId, typeWithValues);
        List<LookupValueDTO> lookupValues = filterProjectType(projectId, typeWithValues);
        lookupValues.addAll(backlogs);
        typeWithValues.setLookupValues(lookupValues);
    }
    LookupTypeWithValuesVO result = modelMapper.map(typeWithValues, new TypeToken<LookupTypeWithValuesVO>() {
    }.getType());
    result.setLookupValues(modelMapper.map(typeWithValues.getLookupValues(), new TypeToken<List<LookupValueVO>>() {
    }.getType()));
    return result;
}
Also used : LookupTypeWithValuesDTO(io.choerodon.agile.infra.dto.LookupTypeWithValuesDTO) LookupTypeWithValuesVO(io.choerodon.agile.api.vo.LookupTypeWithValuesVO) TypeToken(org.modelmapper.TypeToken) LookupValueDTO(io.choerodon.agile.infra.dto.LookupValueDTO) ArrayList(java.util.ArrayList) List(java.util.List)

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