Search in sources :

Example 1 with StateMachineConfigDraftDTO

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

the class StateMachineConfigServiceImpl method create.

@Override
public StateMachineConfigVO create(Long organizationId, Long stateMachineId, Long transformId, StateMachineConfigVO configDTO) {
    if (Boolean.FALSE.equals(EnumUtil.contain(ConfigType.class, configDTO.getType()))) {
        throw new CommonException(ERROR_STATUS_TYPE_ILLEGAL);
    }
    // 验证configCode
    checkCode(transformId, configDTO.getType(), configDTO.getCode());
    configDTO.setTransformId(transformId);
    configDTO.setOrganizationId(organizationId);
    StateMachineConfigDraftDTO config = modelMapper.map(configDTO, StateMachineConfigDraftDTO.class);
    config.setStateMachineId(stateMachineId);
    int isInsert = configDraftMapper.insert(config);
    if (isInsert != 1) {
        throw new CommonException("error.stateMachineConfig.create");
    }
    config = configDraftMapper.queryById(organizationId, config.getId());
    return modelMapper.map(config, StateMachineConfigVO.class);
}
Also used : CommonException(io.choerodon.core.exception.CommonException) ConfigType(io.choerodon.agile.infra.enums.ConfigType) StateMachineConfigDraftDTO(io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO)

Example 2 with StateMachineConfigDraftDTO

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

the class ConfigCodeServiceImpl method queryByTransformId.

@Override
public List<ConfigCodeVO> queryByTransformId(Long organizationId, Long transformId, String type) {
    if (type == null) {
        throw new CommonException("error.type.notNull");
    }
    if (!EnumUtil.contain(ConfigType.class, type)) {
        throw new CommonException("error.status.type.illegal");
    }
    StateMachineConfigDraftDTO config = new StateMachineConfigDraftDTO();
    config.setOrganizationId(organizationId);
    config.setTransformId(transformId);
    config.setType(type);
    List<StateMachineConfigDraftDTO> configs = configDraftMapper.select(config);
    List<String> configCodes = configs.stream().map(StateMachineConfigDraftDTO::getCode).collect(Collectors.toList());
    // 过滤掉已经配置的,返回未配置的code
    return queryByType(type).stream().filter(configCodeDTO -> !configCodes.contains(configCodeDTO.getCode())).collect(Collectors.toList());
}
Also used : EnumUtil(io.choerodon.agile.infra.utils.EnumUtil) Logger(org.slf4j.Logger) TypeToken(org.modelmapper.TypeToken) ConfigCodeService(io.choerodon.agile.app.service.ConfigCodeService) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) ConfigCodeVO(io.choerodon.agile.api.vo.ConfigCodeVO) ConfigCodeMapper(io.choerodon.agile.infra.mapper.ConfigCodeMapper) ModelMapper(org.modelmapper.ModelMapper) List(java.util.List) StateMachineConfigDraftDTO(io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO) ConfigCodeDTO(io.choerodon.agile.infra.dto.ConfigCodeDTO) Service(org.springframework.stereotype.Service) ConfigType(io.choerodon.agile.infra.enums.ConfigType) PropertyData(io.choerodon.agile.infra.statemachineclient.dto.PropertyData) CommonException(io.choerodon.core.exception.CommonException) StateMachineConfigDraftMapper(io.choerodon.agile.infra.mapper.StateMachineConfigDraftMapper) CommonException(io.choerodon.core.exception.CommonException) ConfigType(io.choerodon.agile.infra.enums.ConfigType) StateMachineConfigDraftDTO(io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO)

Example 3 with StateMachineConfigDraftDTO

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

the class StateMachineConfigServiceImpl method delete.

@Override
public Boolean delete(Long organizationId, Long configId) {
    StateMachineConfigDraftDTO config = new StateMachineConfigDraftDTO();
    config.setId(configId);
    config.setOrganizationId(organizationId);
    int isDelete = configDraftMapper.delete(config);
    if (isDelete != 1) {
        throw new CommonException("error.stateMachineConfig.delete");
    }
    return true;
}
Also used : CommonException(io.choerodon.core.exception.CommonException) StateMachineConfigDraftDTO(io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO)

Example 4 with StateMachineConfigDraftDTO

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

the class StateMachineConfigServiceImpl method checkCode.

public void checkCode(Long transformId, String type, String code) {
    List<ConfigCodeVO> configCodeVOS = configCodeService.queryByType(type);
    if (configCodeVOS.stream().noneMatch(configCodeDTO -> configCodeDTO.getCode().equals(code))) {
        throw new CommonException("error.configCode.illegal");
    }
    StateMachineConfigDraftDTO configDraft = new StateMachineConfigDraftDTO();
    configDraft.setTransformId(transformId);
    configDraft.setCode(code);
    if (!configDraftMapper.select(configDraft).isEmpty()) {
        throw new CommonException("error.configCode.exist");
    }
}
Also used : CommonException(io.choerodon.core.exception.CommonException) ConfigCodeVO(io.choerodon.agile.api.vo.ConfigCodeVO) StateMachineConfigDraftDTO(io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO)

Aggregations

StateMachineConfigDraftDTO (io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO)4 CommonException (io.choerodon.core.exception.CommonException)4 ConfigCodeVO (io.choerodon.agile.api.vo.ConfigCodeVO)2 ConfigType (io.choerodon.agile.infra.enums.ConfigType)2 ConfigCodeService (io.choerodon.agile.app.service.ConfigCodeService)1 ConfigCodeDTO (io.choerodon.agile.infra.dto.ConfigCodeDTO)1 ConfigCodeMapper (io.choerodon.agile.infra.mapper.ConfigCodeMapper)1 StateMachineConfigDraftMapper (io.choerodon.agile.infra.mapper.StateMachineConfigDraftMapper)1 PropertyData (io.choerodon.agile.infra.statemachineclient.dto.PropertyData)1 EnumUtil (io.choerodon.agile.infra.utils.EnumUtil)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ModelMapper (org.modelmapper.ModelMapper)1 TypeToken (org.modelmapper.TypeToken)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1