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);
}
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());
}
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;
}
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");
}
}
Aggregations