Search in sources :

Example 1 with ConfigCodeDTO

use of io.choerodon.agile.infra.dto.ConfigCodeDTO 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 2 with ConfigCodeDTO

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

the class ConfigCodeServiceImpl method handlePropertyData.

@Override
public void handlePropertyData(PropertyData propertyData) {
    String service = propertyData.getServiceName();
    if (service == null) {
        throw new CommonException("error.handlePropertyData.service.notNull");
    }
    // 先删除该服务的ConfigCode
    ConfigCodeDTO delete = new ConfigCodeDTO();
    delete.setService(propertyData.getServiceName());
    configCodeMapper.delete(delete);
    // 再插入扫描到的ConfigCode
    List<ConfigCodeDTO> configCodeVOS = modelMapper.map(propertyData.getList(), new TypeToken<List<ConfigCodeDTO>>() {
    }.getType());
    configCodeVOS.forEach(configCode -> {
        configCode.setService(service);
        configCodeMapper.insert(modelMapper.map(configCode, ConfigCodeDTO.class));
        logger.info("handlePropertyData service:{} insert code:{} successful", service, configCode.getCode());
    });
    logger.info("handlePropertyData load service:{} successful", service);
}
Also used : TypeToken(org.modelmapper.TypeToken) CommonException(io.choerodon.core.exception.CommonException) ConfigCodeDTO(io.choerodon.agile.infra.dto.ConfigCodeDTO)

Example 3 with ConfigCodeDTO

use of io.choerodon.agile.infra.dto.ConfigCodeDTO 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)

Aggregations

ConfigCodeDTO (io.choerodon.agile.infra.dto.ConfigCodeDTO)3 CommonException (io.choerodon.core.exception.CommonException)3 TypeToken (org.modelmapper.TypeToken)3 ConfigCodeVO (io.choerodon.agile.api.vo.ConfigCodeVO)2 ConfigType (io.choerodon.agile.infra.enums.ConfigType)2 ConfigCodeService (io.choerodon.agile.app.service.ConfigCodeService)1 StateMachineConfigDraftDTO (io.choerodon.agile.infra.dto.StateMachineConfigDraftDTO)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 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1