Search in sources :

Example 1 with ProjectInfoDTO

use of io.choerodon.agile.infra.dto.ProjectInfoDTO 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);
        // 同步工作项到第三方
        agilePluginService.issueSyncByIssueId(organizationId, issueId, OpenAppIssueSyncConstant.AppType.DIND.getValue(), OpenAppIssueSyncConstant.OperationType.CREATE);
        // 第三方实例关联:yqcloud等
        agilePluginService.createInstanceOpenRel(projectId, issueId, InstanceType.ISSUE, issueCreateVO.getInstanceOpenRelVO());
    }
    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 2 with ProjectInfoDTO

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

the class ProjectInfoServiceImpl method checkProjectCode.

@Override
public Boolean checkProjectCode(String projectName) {
    ProjectInfoDTO projectInfoDTO = new ProjectInfoDTO();
    projectInfoDTO.setProjectCode(projectName);
    return projectInfoMapper.selectOne(projectInfoDTO) != null;
}
Also used : ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Example 3 with ProjectInfoDTO

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

the class ProjectInfoServiceImpl method initializationProjectInfo.

@Override
public void initializationProjectInfo(ProjectEvent projectEvent) {
    ProjectInfoDTO projectInfoDTO = new ProjectInfoDTO();
    projectInfoDTO.setProjectId(projectEvent.getProjectId());
    List<ProjectInfoDTO> projectDTOS = projectInfoMapper.select(projectInfoDTO);
    if (!CollectionUtils.isEmpty(projectDTOS)) {
        return;
    }
    projectInfoDTO.setProjectCode(projectEvent.getProjectCode());
    projectInfoDTO.setFeedbackMaxNum(0L);
    projectInfoDTO.setIssueMaxNum(0L);
    int result = projectInfoMapper.insert(projectInfoDTO);
    if (result != 1) {
        throw new CommonException("error.projectInfo.initializationProjectInfo");
    }
    if (backlogExpandService != null) {
        backlogExpandService.initBacklogMaxNum(projectEvent.getProjectId(), 0L);
    }
}
Also used : CommonException(io.choerodon.core.exception.CommonException) ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Example 4 with ProjectInfoDTO

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

the class StateMachineClientServiceImpl method handlerSubIssue.

private Long handlerSubIssue(Long projectId, IssueConvertDTO subIssueConvertDTO, IssueSubCreateVO issueSubCreateVO) {
    Long organizationId = ConvertUtil.getOrganizationId(projectId);
    // 获取状态机id
    Long stateMachineId = projectConfigService.queryStateMachineId(projectId, SchemeApplyType.AGILE, subIssueConvertDTO.getIssueTypeId());
    if (stateMachineId == null) {
        throw new CommonException(ERROR_ISSUE_STATE_MACHINE_NOT_FOUND);
    }
    Long initStatusId = issueSubCreateVO.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(subIssueConvertDTO.getProjectId());
    ProjectInfoDTO projectInfo = modelMapper.map(projectInfoMapper.selectOne(projectInfoDTO), ProjectInfoDTO.class);
    if (projectInfo == null) {
        throw new CommonException(ERROR_PROJECT_INFO_NOT_FOUND);
    }
    // 创建issue
    subIssueConvertDTO.setApplyType(SchemeApplyType.AGILE);
    // 初始化subIssue
    issueService.handleInitSubIssue(subIssueConvertDTO, initStatusId, projectInfo);
    Long issueId = issueAccessDataService.create(subIssueConvertDTO).getIssueId();
    BaseFieldUtil.updateIssueLastUpdateInfo(issueSubCreateVO.getParentIssueId(), issueSubCreateVO.getProjectId());
    CreateSubIssuePayload createSubIssuePayload = new CreateSubIssuePayload(issueSubCreateVO, subIssueConvertDTO, projectInfo);
    InputDTO inputDTO = new InputDTO(issueId, JSON.toJSONString(createSubIssuePayload));
    // 通过状态机客户端创建实例, 反射验证/条件/后置动作
    StateMachineTransformDTO initTransform = modelMapper.map(instanceService.queryInitTransform(organizationId, stateMachineId), StateMachineTransformDTO.class);
    stateMachineClient.createInstance(initTransform, inputDTO);
    issueService.afterCreateSubIssue(issueId, subIssueConvertDTO, issueSubCreateVO, projectInfo);
    if (agileWaterfallService != null) {
        agileWaterfallService.handlerAfterCreateSubIssue(projectId, issueId, issueSubCreateVO);
    }
    if (agilePluginService != null) {
        agilePluginService.issueSyncByIssueId(organizationId, issueId, OpenAppIssueSyncConstant.AppType.DIND.getValue(), OpenAppIssueSyncConstant.OperationType.CREATE);
    }
    return issueId;
}
Also used : StateMachineTransformDTO(io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO) CreateSubIssuePayload(io.choerodon.agile.api.vo.event.CreateSubIssuePayload) CommonException(io.choerodon.core.exception.CommonException) InputDTO(io.choerodon.agile.infra.statemachineclient.dto.InputDTO) ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Example 5 with ProjectInfoDTO

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

the class ProjectInfoServiceImpl method queryProjectInfoByProjectId.

@Override
public ProjectInfoVO queryProjectInfoByProjectId(Long projectId) {
    ProjectInfoDTO projectInfoDTO = new ProjectInfoDTO();
    projectInfoDTO.setProjectId(projectId);
    ProjectInfoDTO dto = projectInfoMapper.selectOne(projectInfoDTO);
    if (ObjectUtils.isEmpty(dto)) {
        return null;
    } else {
        return modelMapper.map(dto, ProjectInfoVO.class);
    }
}
Also used : ProjectInfoDTO(io.choerodon.agile.infra.dto.ProjectInfoDTO)

Aggregations

ProjectInfoDTO (io.choerodon.agile.infra.dto.ProjectInfoDTO)6 CommonException (io.choerodon.core.exception.CommonException)3 InputDTO (io.choerodon.agile.infra.statemachineclient.dto.InputDTO)2 StateMachineTransformDTO (io.choerodon.agile.infra.statemachineclient.dto.StateMachineTransformDTO)2 ProjectVO (io.choerodon.agile.api.vo.ProjectVO)1 IssueVO (io.choerodon.agile.api.vo.business.IssueVO)1 CreateIssuePayload (io.choerodon.agile.api.vo.event.CreateIssuePayload)1 CreateSubIssuePayload (io.choerodon.agile.api.vo.event.CreateSubIssuePayload)1 UserMessageDTO (io.choerodon.agile.infra.dto.UserMessageDTO)1 IssueConvertDTO (io.choerodon.agile.infra.dto.business.IssueConvertDTO)1 Async (org.springframework.scheduling.annotation.Async)1