Search in sources :

Example 1 with IssueConvertDTO

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

the class StateMachineClientServiceImpl method createSubIssue.

/**
 * 创建subIssue,用于敏捷
 *
 * @param issueSubCreateVO
 * @return
 */
@Override
public IssueSubVO createSubIssue(IssueSubCreateVO issueSubCreateVO) {
    IssueConvertDTO subIssueConvertDTO = issueAssembler.toTarget(issueSubCreateVO, IssueConvertDTO.class);
    Long projectId = subIssueConvertDTO.getProjectId();
    Long issueId = handlerSubIssue(projectId, subIssueConvertDTO, issueSubCreateVO);
    Set<Long> influenceIssueIds = new HashSet<>();
    issueService.doStateMachineCustomFlow(projectId, issueId, SchemeApplyType.AGILE, influenceIssueIds, new TriggerCarrierVO());
    // 前端请求创建issue和创建自定义字段是两个接口,issue创建不走切面,解决issue创建和自定义字段创建都走切面导致某个触发器失败的问题
    IssueSubVO issueSubVO = issueService.queryIssueSubByCreateWithoutRuleNotice(subIssueConvertDTO.getProjectId(), issueId);
    issueSubVO.setInfluenceIssueIds(new ArrayList<>(influenceIssueIds));
    return issueSubVO;
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueSubVO(io.choerodon.agile.api.vo.IssueSubVO) TriggerCarrierVO(io.choerodon.agile.api.vo.business.TriggerCarrierVO)

Example 2 with IssueConvertDTO

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

the class StateMachineClientServiceImpl method createSubIssueWithoutRuleNotice.

@Override
public IssueSubVO createSubIssueWithoutRuleNotice(IssueSubCreateVO issueSubCreateVO) {
    IssueConvertDTO subIssueConvertDTO = issueAssembler.toTarget(issueSubCreateVO, IssueConvertDTO.class);
    Long projectId = subIssueConvertDTO.getProjectId();
    Long issueId = handlerSubIssue(projectId, subIssueConvertDTO, issueSubCreateVO);
    Set<Long> influenceIssueIds = new HashSet<>();
    issueService.doStateMachineCustomFlow(projectId, issueId, SchemeApplyType.AGILE, influenceIssueIds, new TriggerCarrierVO());
    IssueSubVO issueSubVO = issueService.queryIssueSubByCreateWithoutRuleNotice(subIssueConvertDTO.getProjectId(), issueId);
    issueSubVO.setInfluenceIssueIds(new ArrayList<>(influenceIssueIds));
    return issueSubVO;
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueSubVO(io.choerodon.agile.api.vo.IssueSubVO) TriggerCarrierVO(io.choerodon.agile.api.vo.business.TriggerCarrierVO)

Example 3 with IssueConvertDTO

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

the class StateMachineClientServiceImpl method handlerIssue.

private Long handlerIssue(IssueCreateVO issueCreateVO, String applyType) {
    issueValidator.checkIssueCreate(issueCreateVO, applyType);
    if (agilePluginService != null) {
        agilePluginService.checkBeforeCreateIssue(issueCreateVO, applyType);
    }
    if (agileWaterfallService != null) {
        agileWaterfallService.checkBeforeCreateIssue(issueCreateVO, applyType);
    }
    IssueConvertDTO issueConvertDTO = issueAssembler.toTarget(issueCreateVO, IssueConvertDTO.class);
    Long projectId = issueConvertDTO.getProjectId();
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    // 获取状态机id
    Long stateMachineId = statusMachineSchemeConfigMapper.selectStatusMachineIdByIssueTypeId(organizationId, projectId, applyType, issueConvertDTO.getIssueTypeId());
    if (stateMachineId == null) {
        throw new CommonException(ERROR_ISSUE_STATE_MACHINE_NOT_FOUND);
    }
    Long initStatusId = issueCreateVO.getStatusId();
    if (ObjectUtils.isEmpty(initStatusId)) {
        // 获取初始状态
        initStatusId = instanceService.queryInitStatusId(organizationId, stateMachineId);
        if (initStatusId == null) {
            throw new CommonException(ERROR_ISSUE_STATUS_NOT_FOUND);
        }
    }
    // 获取项目信息
    ProjectInfoDTO projectInfoDTO = new ProjectInfoDTO();
    projectInfoDTO.setProjectId(projectId);
    ProjectInfoDTO projectInfo = projectInfoMapper.selectOne(projectInfoDTO);
    if (projectInfo == null) {
        throw new CommonException(ERROR_PROJECT_INFO_NOT_FOUND);
    }
    // 创建issue
    issueConvertDTO.setApplyType(applyType);
    issueService.handleInitIssue(issueConvertDTO, initStatusId, projectInfo);
    Long issueId = issueAccessDataService.create(issueConvertDTO).getIssueId();
    BaseFieldUtil.updateIssueLastUpdateInfo(issueConvertDTO.getRelateIssueId(), issueConvertDTO.getProjectId());
    // 创建史诗,初始化排序
    if ("issue_epic".equals(issueCreateVO.getTypeCode())) {
        initRank(issueCreateVO, issueId, "epic");
    }
    CreateIssuePayload createIssuePayload = new CreateIssuePayload(issueCreateVO, issueConvertDTO, projectInfo);
    InputDTO inputDTO = new InputDTO(issueId, JSON.toJSONString(createIssuePayload));
    // 通过状态机客户端创建实例, 反射验证/条件/后置动作
    StateMachineTransformDTO initTransform = modelMapper.map(instanceService.queryInitTransform(organizationId, stateMachineId), StateMachineTransformDTO.class);
    stateMachineClient.createInstance(initTransform, inputDTO);
    issueService.afterCreateIssue(issueId, issueConvertDTO, issueCreateVO, projectInfo);
    if (agilePluginService != null) {
        agilePluginService.handlerBusinessAfterCreateIssue(issueConvertDTO, projectId, issueId, issueCreateVO);
    }
    if (agileWaterfallService != null) {
        agileWaterfallService.handlerWaterfallAfterCreateIssue(projectId, issueId, issueCreateVO);
    }
    // 创建交付物
    if (agileWaterfallService != null && issueCreateVO.getTypeCode().equals(IssueTypeCode.MILESTONE.value()) && !ObjectUtils.isEmpty(issueCreateVO.getWaterfallIssueVO()) && !CollectionUtils.isEmpty(issueCreateVO.getWaterfallIssueVO().getWfDeliverableVOS())) {
        agileWaterfallService.createDeliverableService(issueId, issueCreateVO.getWaterfallIssueVO().getWfDeliverableVOS());
    }
    return issueId;
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) StateMachineTransformDTO(io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO) CreateIssuePayload(io.choerodon.agile.api.vo.event.CreateIssuePayload) CommonException(io.choerodon.core.exception.CommonException) InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO) ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Example 4 with IssueConvertDTO

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

the class IssueServiceImpl method handlerStatus.

private void handlerStatus(Long projectId, IssueUpdateTypeVO issueUpdateTypeVO) {
    IssueConvertDTO issueConvertDTO = queryIssueByProjectIdAndIssueId(projectId, issueUpdateTypeVO.getIssueId());
    Long currentStateMachineId = projectConfigService.queryStateMachineId(projectId, issueUpdateTypeVO.getApplyType(), issueUpdateTypeVO.getIssueTypeId());
    // 查询状态机里面的状态
    List<StatusMachineNodeVO> statusMachineNodeVOS = stateMachineNodeService.queryByStateMachineId(ConvertUtil.getOrganizationId(projectId), currentStateMachineId, false);
    if (CollectionUtils.isEmpty(statusMachineNodeVOS)) {
        throw new CommonException("error.current.state.machine.node.null");
    }
    List<Long> list = statusMachineNodeVOS.stream().map(StatusMachineNodeVO::getStatusId).collect(Collectors.toList());
    if (!list.contains(issueConvertDTO.getStatusId())) {
        StatusMachineNodeVO statusMachineNodeVO = statusMachineNodeVOS.stream().filter(v -> NodeType.INIT.equals(v.getType())).findAny().orElse(null);
        if (ObjectUtils.isEmpty(statusMachineNodeVO)) {
            throw new CommonException("error.init.node.not.found");
        }
        issueConvertDTO.setStatusId(statusMachineNodeVO.getStatusId());
        issueAccessDataService.update(issueConvertDTO, new String[] { STATUS_ID });
    }
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) CommonException(io.choerodon.core.exception.CommonException)

Example 5 with IssueConvertDTO

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

the class IssueServiceImpl method dragEpic.

@Override
public synchronized EpicDataVO dragEpic(Long projectId, EpicSequenceVO epicSequenceVO) {
    if (epicSequenceVO.getAfterSequence() == null && epicSequenceVO.getBeforeSequence() == null) {
        throw new CommonException("error.dragEpic.noSequence");
    }
    IssueDTO issueDTO = new IssueDTO();
    issueDTO.setIssueId(epicSequenceVO.getEpicId());
    issueDTO.setProjectId(projectId);
    IssueConvertDTO issueConvertDTO = modelMapper.map(issueMapper.selectOne(issueDTO), IssueConvertDTO.class);
    if (issueConvertDTO == null) {
        throw new CommonException("error.issue.notFound");
    } else {
        if (epicSequenceVO.getAfterSequence() == null) {
            Integer maxSequence = productVersionMapper.queryMaxAfterSequence(epicSequenceVO.getBeforeSequence(), projectId);
            epicSequenceVO.setAfterSequence(maxSequence);
        } else if (epicSequenceVO.getBeforeSequence() == null) {
            Integer minSequence = productVersionMapper.queryMinBeforeSequence(epicSequenceVO.getAfterSequence(), projectId);
            epicSequenceVO.setBeforeSequence(minSequence);
        }
        handleSequence(epicSequenceVO, projectId, issueConvertDTO);
    }
    return epicDataAssembler.toTarget(issueMapper.queryEpicListByEpic(epicSequenceVO.getEpicId(), projectId), EpicDataVO.class);
}
Also used : IssueConvertDTO(io.choerodon.agile.infra.dto.business.IssueConvertDTO) IssueDTO(io.choerodon.agile.infra.dto.business.IssueDTO) CommonException(io.choerodon.core.exception.CommonException)

Aggregations

IssueConvertDTO (io.choerodon.agile.infra.dto.business.IssueConvertDTO)19 IssueDTO (io.choerodon.agile.infra.dto.business.IssueDTO)9 CommonException (io.choerodon.core.exception.CommonException)7 IssueSubVO (io.choerodon.agile.api.vo.IssueSubVO)2 TriggerCarrierVO (io.choerodon.agile.api.vo.business.TriggerCarrierVO)2 InputDTO (io.choerodon.agile.infra.statemachineclient.dto.InputDTO)2 CreateIssuePayload (io.choerodon.agile.api.vo.event.CreateIssuePayload)1 LookupValueDTO (io.choerodon.agile.infra.dto.LookupValueDTO)1 ProjectInfoDTO (io.choerodon.agile.infra.dto.ProjectInfoDTO)1 StateMachineTransformDTO (io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO)1 CustomUserDetails (io.choerodon.core.oauth.CustomUserDetails)1 BigDecimal (java.math.BigDecimal)1 Transactional (org.springframework.transaction.annotation.Transactional)1