use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class IssueValidator method verifyUpdateData.
public void verifyUpdateData(JSONObject issueUpdate, Long projectId) {
Long organizationId = ConvertUtil.getOrganizationId(projectId);
if (issueUpdate.get(ISSUE_ID) == null) {
throw new CommonException(ERROR_ISSUE_ID_NOT_FOUND);
}
Long issueId = decrypt(issueUpdate.get(ISSUE_ID).toString());
IssueDTO issueDTO = new IssueDTO();
issueDTO.setIssueId(issueId);
issueDTO.setProjectId(projectId);
issueDTO = issueMapper.selectByPrimaryKey(issueDTO);
if (issueDTO == null) {
throw new CommonException(ERROR_ISSUE_ID_NOT_FOUND);
}
// 不是epic类型的,不能修改颜色
if (issueUpdate.get(COLOR) != null && !ISSUE_EPIC.equals(issueDTO.getTypeCode())) {
throw new CommonException("error.IssueRule.color");
}
// 不是epic类型的,不能修改epicName
if (issueUpdate.get(EPIC_NAME) != null && !ISSUE_EPIC.equals(issueDTO.getTypeCode())) {
throw new CommonException("error.IssueRule.EpicName");
}
// 修改状态要有当前状态
if (issueUpdate.get(STATUS_ID) != null && issueStatusMapper.selectByStatusId(projectId, decrypt(issueUpdate.get(STATUS_ID).toString())) == null) {
throw new CommonException("error.IssueRule.statusId");
}
if (issueUpdate.containsKey("rank") && ObjectUtils.isEmpty(issueUpdate.get("rank"))) {
throw new CommonException("error.issue.rank.null");
}
if (issueUpdate.containsKey(PRIORITY_ID) && (ObjectUtils.isEmpty(issueUpdate.get(PRIORITY_ID)) || Objects.isNull(priorityMapper.selectOne(new PriorityDTO(organizationId, decrypt(issueUpdate.get(PRIORITY_ID).toString())))))) {
throw new CommonException("error.issue.priorityId.illegal");
}
if (issueUpdate.containsKey(STATUS_ID_FIELD) && (ObjectUtils.isEmpty(issueUpdate.get(STATUS_ID_FIELD)) || Objects.isNull(issueStatusMapper.selectByStatusId(projectId, decrypt(issueUpdate.get(STATUS_ID_FIELD).toString()))))) {
throw new CommonException("error.issue.statusId.illegal");
}
// 史诗校验
if (issueUpdate.containsKey(EPIC_ID)) {
if (ObjectUtils.isEmpty(issueUpdate.get(EPIC_ID))) {
throw new CommonException("error.issue.epic.null");
}
judgeEpicCanUpdateAndExist(projectId, decrypt(issueUpdate.get(EPIC_ID).toString()));
}
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class IssueValidator method judgeEpicCanUpdateAndExist.
public void judgeEpicCanUpdateAndExist(Long projectId, Long epicId) {
ProjectVO project = ConvertUtil.queryProject(projectId);
Set<String> categoryCodes = new HashSet<>(ProjectCategory.getProjectCategoryCodes(project));
boolean isOnlyAgile = categoryCodes.contains(ProjectCategory.MODULE_AGILE) && !categoryCodes.contains(ProjectCategory.MODULE_PROGRAM);
if (agilePluginService != null && isOnlyAgile && agilePluginService.isSubProjectAndArtDoing(projectId)) {
throw new CommonException("error.issue.can.not.update.epic");
}
if (epicId != null && !Objects.equals(epicId, 0L)) {
IssueDTO issueDTO = new IssueDTO();
issueDTO.setProjectId(projectId);
issueDTO.setTypeCode(ISSUE_EPIC);
issueDTO.setIssueId(epicId);
if (issueMapper.selectOne(issueDTO) == null) {
throw new CommonException("error.epic.notFound");
}
}
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class IssueServiceImpl method executionUpdateInfluenceIssue.
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public Boolean executionUpdateInfluenceIssue(Long issueId, Long executionStatusId, IssueDTO influenceIssue, Long projectId, String applyType, InfluenceIssueVO influenceIssueVO, Boolean isSub, Map<Long, LinkIssueStatusLinkageVO> linkIssueStatusMap, TriggerCarrierVO triggerCarrierVO) {
IssueDTO issue = issueMapper.selectByPrimaryKey(issueId);
triggerCarrierVO.setInstanceId(issue.getIssueId());
triggerCarrierVO.setProjectId(projectId);
triggerCarrierVO.setIssueTypeId(issue.getIssueTypeId());
triggerCarrierVO.setExecutedRules(new ArrayList<>());
triggerCarrierVO.setNoticeInstanceId(issue.getIssueId());
triggerCarrierVO.setFieldList(Collections.singletonList("statusId"));
triggerCarrierVO.setMemberFieldIds(new HashSet<>());
if (Boolean.TRUE.equals(influenceIssueVO.getLoop()) || Boolean.TRUE.equals(influenceIssueVO.getMaxDepth())) {
statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, linkIssueStatusMap, null, null);
return Boolean.TRUE;
}
if (Objects.equals("bug", issue.getTypeCode()) && !ObjectUtils.isEmpty(issue.getRelateIssueId()) && !Objects.equals(issue.getRelateIssueId(), 0L)) {
return Boolean.TRUE;
}
if (Objects.equals(issue.getStatusId(), executionStatusId)) {
statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, linkIssueStatusMap, TriggerExecutionStatus.STOP.getValue(), "same_status");
return Boolean.TRUE;
}
Boolean verifyStatusTransferSetting = transferSettingService.verifyStatusTransferSetting(projectId, issue, executionStatusId);
if (Boolean.TRUE.equals(verifyStatusTransferSetting)) {
statusLinkageExecutionLog(influenceIssueVO, issue.getIssueId(), influenceIssue, isSub, linkIssueStatusMap, TriggerExecutionStatus.STOP.getValue(), "condition_limit");
return Boolean.TRUE;
}
// 获取当前状态对应的transformId
Long stateMachineId = projectConfigService.queryStateMachineId(projectId, applyType, issue.getIssueTypeId());
// 获取开始状态和结束状态查询转换Id
Long organizationId = ConvertUtil.getOrganizationId(projectId);
List<StatusMachineTransformDTO> statusMachineTransformDTOS = statusMachineTransformMapper.selectTransformByStatusId(organizationId, stateMachineId, issue.getStatusId(), executionStatusId, false);
if (CollectionUtils.isEmpty(statusMachineTransformDTOS)) {
statusMachineTransformDTOS = statusMachineTransformMapper.selectTransformByStatusId(organizationId, stateMachineId, issue.getStatusId(), executionStatusId, true);
}
StatusMachineTransformDTO statusTransform = statusMachineTransformDTOS.get(0);
stateMachineClientService.executeTransform(projectId, issueId, statusTransform.getId(), issue.getObjectVersionNumber(), applyType, new InputDTO(issueId, "updateStatus", updateTrigger(true, influenceIssue)));
if (SchemeApplyType.AGILE.equals(applyType)) {
IssueConvertDTO issueConvertDTO = new IssueConvertDTO();
issueConvertDTO.setIssueId(issueId);
issueConvertDTO.setStayDate(new Date());
issueConvertDTO.setObjectVersionNumber(issueMapper.selectByPrimaryKey(issueId).getObjectVersionNumber());
issueAccessDataService.updateSelective(issueConvertDTO);
}
// 更新属性
statusFieldSettingService.handlerSettingToUpdateIssue(projectId, issueId, triggerCarrierVO);
AgilePluginService agilePluginService = SpringBeanUtil.getExpandBean(AgilePluginService.class);
if (agilePluginService != null) {
agilePluginService.storyLinkageFeature(projectId, issue, applyType);
}
// 记录联动的执行日志
statusLinkageExecutionLog(influenceIssueVO, issueId, influenceIssue, isSub, linkIssueStatusMap, null, null);
LOGGER.info("项目{}下状态联动触发{}编号为{}的issue状态变更", issue.getProjectId(), IssueConstant.ISSUE_CN, issue.getIssueNum());
triggerCarrierVO.setAuditDomain(issueMapper.selectByPrimaryKey(issueId));
this.self().batchUpdateInvokeTrigger(Collections.singletonList(triggerCarrierVO));
return Boolean.FALSE;
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class IssueServiceImpl method handlerInfluenceIssue.
@Override
public void handlerInfluenceIssue(Long projectId, String applyType, InfluenceIssueVO influenceIssueVO, Long linkIssueId, Map<Long, LinkIssueStatusLinkageVO> linkIssueStatusMap, Set<Long> influenceIssueIds) {
Long issueId = influenceIssueVO.getIssueId();
Long statusId = influenceIssueVO.getStatusId();
IssueDTO influenceIssue = issueMapper.selectByPrimaryKey(linkIssueId);
IssueDTO issue = issueMapper.selectByPrimaryKey(issueId);
Boolean isSub = Objects.equals("sub_task", influenceIssue.getTypeCode()) || (Objects.equals("bug", influenceIssue.getTypeCode()) && !ObjectUtils.isEmpty(influenceIssue.getRelateIssueId()) && !Objects.equals(influenceIssue.getRelateIssueId(), 0L));
// 变更issue的状态和更新属性
TriggerCarrierVO triggerCarrierVO = new TriggerCarrierVO();
this.self().executionUpdateInfluenceIssue(issueId, statusId, influenceIssue, projectId, applyType, influenceIssueVO, isSub, linkIssueStatusMap, triggerCarrierVO);
// 处理当前issue会影响的issue
List<InfluenceIssueVO> childrenVO = influenceIssueVO.getChildrenVO();
if (!CollectionUtils.isEmpty(childrenVO)) {
for (InfluenceIssueVO issueVO : childrenVO) {
try {
this.self().handlerInfluenceIssue(projectId, applyType, issueVO, issueId, linkIssueStatusMap, influenceIssueIds);
} catch (Exception e) {
influenceIssueIds.add(issueVO.getIssueId());
statusLinkageExecutionLog(issueVO, issueVO.getIssueId(), issue, false, linkIssueStatusMap, TriggerExecutionStatus.ERROR.getValue(), null);
LOGGER.info("error.update.link.issue", e);
}
}
}
}
use of io.choerodon.agile.infra.dto.business.IssueDTO in project agile-service by open-hand.
the class ExcelServiceImpl method validateAndSetFeature.
private void validateAndSetFeature(Row row, Integer col, ExcelColumnVO excelColumn, Map<Integer, List<Integer>> errorRowColMap, IssueCreateVO issueCreateVO, String issueTypeCode) {
if (IssueTypeCode.isStory(issueTypeCode)) {
Cell cell = row.getCell(col);
if (!isCellEmpty(cell)) {
int rowNum = row.getRowNum();
String value = cell.toString();
List<String> values = excelColumn.getPredefinedValues();
Map<String, Long> valueIdMap = excelColumn.getValueIdMap();
if (!values.contains(value)) {
cell.setCellValue(buildWithErrorMsg(value, "所属特性输入错误"));
addErrorColumn(rowNum, col, errorRowColMap);
} else {
Long featureId = valueIdMap.get(value);
issueCreateVO.setFeatureId(featureId);
// 如果特性关联史诗,也要设置史诗id
IssueDTO feature = issueMapper.selectByPrimaryKey(featureId);
if (feature != null && Objects.equals(0L, feature.getEpicId())) {
issueCreateVO.setEpicId(feature.getEpicId());
}
}
}
}
}
Aggregations