use of io.choerodon.agile.infra.dto.StateMachineSchemeDTO in project agile-service by open-hand.
the class StateMachineSchemeServiceImpl method activeSchemeWithRefProjectConfig.
@Override
public void activeSchemeWithRefProjectConfig(Long schemeId) {
StateMachineSchemeDTO scheme = schemeMapper.selectByPrimaryKey(schemeId);
// 活跃状态机方案
if (scheme.getStatus().equals(StateMachineSchemeStatus.CREATE)) {
scheme.setStatus(StateMachineSchemeStatus.ACTIVE);
// Criteria criteria = new Criteria();
// criteria.update("status");
// int result = schemeMapper.updateByPrimaryKeyOptions(scheme, criteria);
int result = schemeMapper.updateOptional(scheme, "status");
if (result != 1) {
throw new CommonException("error.stateMachineScheme.activeScheme");
}
}
// 复制草稿配置到发布
configService.copyDraftToDeploy(false, scheme.getOrganizationId(), schemeId);
// 活跃方案下的所有新建状态机
List<StatusMachineSchemeConfigVO> configs = configService.queryBySchemeId(false, scheme.getOrganizationId(), schemeId);
stateMachineService.activeStateMachines(scheme.getOrganizationId(), configs.stream().map(StatusMachineSchemeConfigVO::getStateMachineId).distinct().collect(Collectors.toList()));
}
use of io.choerodon.agile.infra.dto.StateMachineSchemeDTO in project agile-service by open-hand.
the class StateMachineSchemeServiceImpl method checkName.
@Override
public Boolean checkName(Long organizationId, String name) {
StateMachineSchemeDTO scheme = new StateMachineSchemeDTO();
scheme.setOrganizationId(organizationId);
scheme.setName(name);
StateMachineSchemeDTO res = schemeMapper.selectOne(scheme);
return res != null;
}
use of io.choerodon.agile.infra.dto.StateMachineSchemeDTO in project agile-service by open-hand.
the class StateMachineSchemeServiceImpl method create.
@Override
public StateMachineSchemeVO create(Long organizationId, StateMachineSchemeVO schemeVO) {
if (checkName(organizationId, schemeVO.getName())) {
throw new CommonException("error.stateMachineName.exist");
}
schemeVO.setStatus(StateMachineSchemeStatus.CREATE);
StateMachineSchemeDTO scheme = modelMapper.map(schemeVO, StateMachineSchemeDTO.class);
scheme.setOrganizationId(organizationId);
int isInsert = schemeMapper.insert(scheme);
if (isInsert != 1) {
throw new CommonException("error.stateMachineScheme.create");
}
// 创建一个defaultConfig
StatusMachineVO statusMachineVO = stateMachineService.queryDefaultStateMachine(organizationId);
configService.createDefaultConfig(organizationId, scheme.getId(), statusMachineVO.getId());
scheme = schemeMapper.selectByPrimaryKey(scheme);
return modelMapper.map(scheme, StateMachineSchemeVO.class);
}
use of io.choerodon.agile.infra.dto.StateMachineSchemeDTO in project agile-service by open-hand.
the class StateMachineSchemeServiceImpl method pageQuery.
@Override
public Page<StateMachineSchemeVO> pageQuery(Long organizationId, PageRequest pageRequest, StateMachineSchemeVO schemeVO, String params) {
// 查询出组织下的所有项目
List<ProjectVO> projectVOS = baseFeignClient.listProjectsByOrgId(organizationId).getBody();
Map<Long, ProjectVO> projectMap = projectVOS.stream().collect(Collectors.toMap(ProjectVO::getId, x -> x));
// 查询组织下的所有问题类型
Map<Long, IssueTypeDTO> issueTypeMap = new HashMap<>();
issueTypeMapper.selectByOptions(organizationId, 0L, null).forEach(x -> {
IssueTypeDTO dto = modelMapper.map(x, IssueTypeDTO.class);
issueTypeMap.put(x.getId(), dto);
});
// 查询组织下的所有状态机
List<StatusMachineVO> statusMachineVOS = stateMachineService.queryByOrgId(organizationId);
Map<Long, StatusMachineVO> stateMachineVOMap = statusMachineVOS.stream().collect(Collectors.toMap(StatusMachineVO::getId, x -> x));
StateMachineSchemeDTO scheme = modelMapper.map(schemeVO, StateMachineSchemeDTO.class);
Page<StateMachineSchemeDTO> page = PageHelper.doPageAndSort(pageRequest, () -> schemeMapper.fulltextSearch(scheme, params));
List<StateMachineSchemeDTO> schemes = page.getContent();
List<StateMachineSchemeDTO> schemesWithConfigs = new ArrayList<>();
if (!schemes.isEmpty()) {
schemesWithConfigs = schemeMapper.queryByIdsWithConfig(organizationId, schemes.stream().map(StateMachineSchemeDTO::getId).collect(Collectors.toList()));
}
List<StateMachineSchemeVO> schemeVOS = ConvertUtils.convertStateMachineSchemesToVOS(schemesWithConfigs, projectMap);
if (schemeVOS != null) {
handleSchemeConfig(schemeVOS, issueTypeMap, stateMachineVOMap);
}
return PageUtil.buildPageInfoWithPageInfoList(page, schemeVOS);
}
use of io.choerodon.agile.infra.dto.StateMachineSchemeDTO in project agile-service by open-hand.
the class ChangeSchemeStatusAspect method interceptor.
@Around("updateStatusPointcut()")
public Object interceptor(ProceedingJoinPoint pjp) {
// 下面两个数组中,参数值和参数名的个数和位置是一一对应的。
Object[] args = pjp.getArgs();
String[] argNames = ((MethodSignature) pjp.getSignature()).getParameterNames();
Long schemeId = null;
for (int i = 0; i < argNames.length; i++) {
if (argNames[i].equals("schemeId")) {
schemeId = Long.valueOf(args[i] + "");
}
}
logger.info("schemeId:{}", schemeId);
StateMachineSchemeDTO scheme = schemeMapper.selectByPrimaryKey(schemeId);
if (scheme == null) {
throw new CommonException("error.scheme.notFound");
}
if (scheme.getStatus().equals(StateMachineSchemeStatus.ACTIVE)) {
scheme.setStatus(StateMachineSchemeStatus.DRAFT);
schemeMapper.updateOptional(scheme, "status");
}
try {
return pjp.proceed();
} catch (Throwable e) {
throw new CommonException("error.changeSchemeStatusAspect.proceed", e);
}
}
Aggregations