Search in sources :

Example 1 with CustomChartDTO

use of io.choerodon.agile.infra.dto.CustomChartDTO in project agile-service by open-hand.

the class CustomChartServiceImpl method updateCustomChart.

@Override
public CustomChartVO updateCustomChart(Long projectId, Long customChartId, CustomChartUpdateVO customChartUpdate) {
    CustomChartDTO customChartDTO = modelMapper.map(customChartUpdate, CustomChartDTO.class);
    customChartDTO.setId(customChartId);
    deleteCustomChartRedisById(projectId, customChartId);
    if (customChartDTO.getAnalysisField() != null && customChartDTO.getAnalysisFieldPredefined() == null) {
        throw new CommonException("error.customChart.analysisFieldPredefinedNotNull");
    }
    customChartDTO.setProjectId(projectId);
    validAndSetJson(customChartDTO);
    if (customChartMapper.updateByPrimaryKeySelective(customChartDTO) != 1) {
        throw new CommonException("error.CustomChart.update");
    }
    return queryById(customChartId);
}
Also used : CustomChartDTO(io.choerodon.agile.infra.dto.CustomChartDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 2 with CustomChartDTO

use of io.choerodon.agile.infra.dto.CustomChartDTO in project agile-service by open-hand.

the class CustomChartServiceImpl method validNameRepeat.

private boolean validNameRepeat(CustomChartDTO customChartDTO) {
    CustomChartDTO customChartRecord = new CustomChartDTO();
    customChartRecord.setName(customChartDTO.getName());
    customChartRecord.setProjectId(customChartDTO.getProjectId());
    List<CustomChartDTO> results = customChartMapper.select(customChartRecord);
    if (CollectionUtils.isEmpty(results)) {
        return false;
    }
    if (results.size() > (customChartDTO.getId() == null ? 0 : 1)) {
        return true;
    }
    return !results.get(0).getId().equals(customChartDTO.getId());
}
Also used : CustomChartDTO(io.choerodon.agile.infra.dto.CustomChartDTO)

Example 3 with CustomChartDTO

use of io.choerodon.agile.infra.dto.CustomChartDTO in project agile-service by open-hand.

the class CustomChartServiceImpl method createCustomChart.

@Override
public CustomChartVO createCustomChart(Long projectId, CustomChartCreateVO customChartCreate) {
    CustomChartDTO customChartDTO = modelMapper.map(customChartCreate, CustomChartDTO.class);
    customChartDTO.setProjectId(projectId);
    customChartDTO.setOrganizationId(ConvertUtil.getOrganizationId(projectId));
    validAndSetJson(customChartDTO);
    if (customChartMapper.insertSelective(customChartDTO) != 1) {
        throw new CommonException("error.customChart.insert");
    }
    return queryById(customChartDTO.getId());
}
Also used : CustomChartDTO(io.choerodon.agile.infra.dto.CustomChartDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 4 with CustomChartDTO

use of io.choerodon.agile.infra.dto.CustomChartDTO in project agile-service by open-hand.

the class CustomChartServiceImpl method deleteCustomChartRedisById.

private void deleteCustomChartRedisById(Long projectId, Long customChartId) {
    CustomChartDTO customChart = queryCustomChartByProjectAndId(projectId, customChartId);
    CustomChartSearchVO customChartSearchVO = customChartToDataSearch(customChart);
    if (customChartSearchVO == null) {
        return;
    }
    redisUtil.delete(CUSTOM_CHART + projectId + COLON + customChartSearchVO);
}
Also used : CustomChartDTO(io.choerodon.agile.infra.dto.CustomChartDTO) CustomChartSearchVO(io.choerodon.agile.api.vo.report.CustomChartSearchVO)

Example 5 with CustomChartDTO

use of io.choerodon.agile.infra.dto.CustomChartDTO in project agile-service by open-hand.

the class CustomChartServiceImpl method checkName.

@Override
public Boolean checkName(Long projectId, String name) {
    CustomChartDTO customChart = new CustomChartDTO();
    customChart.setProjectId(projectId);
    customChart.setName(name);
    return validNameRepeat(customChart);
}
Also used : CustomChartDTO(io.choerodon.agile.infra.dto.CustomChartDTO)

Aggregations

CustomChartDTO (io.choerodon.agile.infra.dto.CustomChartDTO)9 CommonException (io.choerodon.core.exception.CommonException)3 CustomChartVO (io.choerodon.agile.api.vo.CustomChartVO)2 CustomChartSearchVO (io.choerodon.agile.api.vo.report.CustomChartSearchVO)2 CustomChartDataVO (io.choerodon.agile.api.vo.report.CustomChartDataVO)1 ArrayList (java.util.ArrayList)1 TypeToken (org.modelmapper.TypeToken)1