io.choerodon.core.exception.CommonException Java Examples

The following examples show how to use io.choerodon.core.exception.CommonException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IssueStatusServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public IssueStatusVO create(Long projectId, String applyType, IssueStatusVO issueStatusVO) {
    IssueStatusValidator.checkCreateStatus(projectId, issueStatusVO);
    StatusVO statusVO = new StatusVO();
    statusVO.setType(issueStatusVO.getCategoryCode());
    statusVO.setName(issueStatusVO.getName());
    statusVO = projectConfigService.createStatusForAgile(projectId, applyType, statusVO);
    if (statusVO != null && statusVO.getId() != null) {
        Long statusId = statusVO.getId();
        if (issueStatusMapper.selectByStatusId(projectId, statusId) != null) {
            throw new CommonException("error.status.exist");
        }
        issueStatusVO.setCompleted(false);
        issueStatusVO.setStatusId(statusId);
        IssueStatusDTO issueStatusDTO = modelMapper.map(issueStatusVO, IssueStatusDTO.class);
        return modelMapper.map(insertIssueStatus(issueStatusDTO), IssueStatusVO.class);
    } else {
        throw new CommonException("error.status.create");
    }
}
 
Example #2
Source File: IssueController.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_MEMBER, InitRoleCode.PROJECT_OWNER})
@ApiOperation("分页搜索查询issue列表(包含子任务)")
@CustomPageRequest
@GetMapping(value = "/summary")
public ResponseEntity<PageInfo<IssueNumVO>> queryIssueByOption(@ApiIgnore
                                                            @ApiParam(value = "分页信息", required = true)
                                                            @SortDefault(value = "issueId", direction = Sort.Direction.DESC)
                                                                    PageRequest pageRequest,
                                                               @ApiParam(value = "项目id", required = true)
                                                            @PathVariable(name = "project_id") Long projectId,
                                                               @ApiParam(value = "issueId")
                                                            @RequestParam(required = false) Long issueId,
                                                               @ApiParam(value = "issueNum")
                                                            @RequestParam(required = false) String issueNum,
                                                               @ApiParam(value = "only active sprint", required = true)
                                                            @RequestParam Boolean onlyActiveSprint,
                                                               @ApiParam(value = "是否包含自身", required = true)
                                                            @RequestParam() Boolean self,
                                                               @ApiParam(value = "搜索内容", required = false)
                                                            @RequestParam(required = false) String content) {
    return Optional.ofNullable(issueService.queryIssueByOption(projectId, issueId, issueNum, onlyActiveSprint, self, content, pageRequest))
            .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
            .orElseThrow(() -> new CommonException("error.Issue.queryIssueByOption"));
}
 
Example #3
Source File: IssueTypeSchemeServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Object> checkDelete(Long organizationId, Long issueTypeSchemeId) {
    Map<String, Object> result = new HashMap<>();
    result.put("canDelete", true);
    IssueTypeSchemeDTO issueTypeScheme = issueTypeSchemeMapper.selectByPrimaryKey(issueTypeSchemeId);
    if (issueTypeScheme == null) {
        throw new CommonException("error.issueTypeScheme.notFound");
    }
    if (!issueTypeScheme.getOrganizationId().equals(organizationId)) {
        throw new CommonException("error.issueTypeScheme.illegal");
    }
    //判断要删除的issueTypeScheme是否有使用中的项目【toDo】


    return result;
}
 
Example #4
Source File: IssueController.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_MEMBER, InitRoleCode.PROJECT_OWNER})
@ApiOperation("更新issue")
@PutMapping
public ResponseEntity<IssueVO> updateIssue(@ApiParam(value = "项目id", required = true)
                                            @PathVariable(name = "project_id") Long projectId,
                                           @ApiParam(value = "更新issue对象", required = true)
                                            @RequestBody JSONObject issueUpdate) {
    issueValidator.verifyUpdateData(issueUpdate, projectId);
    IssueUpdateVO issueUpdateVO = new IssueUpdateVO();
    List<String> fieldList = verifyUpdateUtil.verifyUpdateData(issueUpdate, issueUpdateVO);
    if (issueUpdate.get("featureVO") != null) {
        issueUpdateVO.setFeatureVO(JSONObject.parseObject(JSON.toJSONString(issueUpdate.get("featureVO")), FeatureVO.class));
    }
    return Optional.ofNullable(issueService.updateIssue(projectId, issueUpdateVO, fieldList))
            .map(result -> new ResponseEntity<>(result, HttpStatus.CREATED))
            .orElseThrow(() -> new CommonException("error.Issue.updateIssue"));
}
 
Example #5
Source File: PriorityServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public PriorityVO enablePriority(Long organizationId, Long id, Boolean enable) {
    if (!enable) {
        checkLastPriority(organizationId, id);
    }
    PriorityDTO priority = priorityMapper.selectByPrimaryKey(id);
    if (priority == null) {
        throw new CommonException(NOT_FOUND);
    }
    priority.setEnable(enable);
    Criteria criteria = new Criteria();
    criteria.update("enable");
    priorityMapper.updateByPrimaryKeyOptions(priority, criteria);
    //失效之后再进行默认优先级的重置
    if (!enable && priority.getDefault()) {
        updateOtherDefault(organizationId);
    }
    return queryById(organizationId, id);
}
 
Example #6
Source File: ProjectConfigServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public ProjectConfigDTO create(Long projectId, Long schemeId, String schemeType, String applyType) {
    if (!EnumUtil.contain(SchemeType.class, schemeType)) {
        throw new CommonException("error.schemeType.illegal");
    }
    if (!EnumUtil.contain(SchemeApplyType.class, applyType)) {
        throw new CommonException(ERROR_APPLYTYPE_ILLEGAL);
    }
    ProjectConfigDTO projectConfig = new ProjectConfigDTO(projectId, schemeId, schemeType, applyType);
    //保证幂等性
    List<ProjectConfigDTO> configs = projectConfigMapper.select(projectConfig);
    if (!configs.isEmpty()) {
        return configs.get(0);
    }
    int result = projectConfigMapper.insert(projectConfig);
    if (result != 1) {
        throw new CommonException("error.projectConfig.create");
    }

    //若是关联状态机方案,设置状态机方案、状态机为活跃
    if (schemeType.equals(SchemeType.STATE_MACHINE)) {
        stateMachineSchemeService.activeSchemeWithRefProjectConfig(schemeId);
    }
    return projectConfig;
}
 
Example #7
Source File: StatusServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean delete(Long organizationId, Long statusId) {
    StatusDTO status = statusMapper.queryById(organizationId, statusId);
    if (status == null) {
        throw new CommonException("error.status.delete.nofound");
    }
    Long draftUsed = nodeDraftMapper.checkStateDelete(organizationId, statusId);
    Long deployUsed = nodeDeployMapper.checkStateDelete(organizationId, statusId);
    if (draftUsed != 0 || deployUsed != 0) {
        throw new CommonException("error.status.delete");
    }
    if (status.getCode() != null) {
        throw new CommonException("error.status.illegal");
    }
    int isDelete = statusMapper.deleteByPrimaryKey(statusId);
    if (isDelete != 1) {
        throw new CommonException("error.status.delete");
    }
    return true;
}
 
Example #8
Source File: StatusServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public StatusVO create(Long organizationId, StatusVO statusVO) {
    if (checkName(organizationId, statusVO.getName()).getStatusExist()) {
        throw new CommonException("error.statusName.exist");
    }
    if (!EnumUtil.contain(StatusType.class, statusVO.getType())) {
        throw new CommonException("error.status.type.illegal");
    }
    statusVO.setOrganizationId(organizationId);
    StatusDTO status = modelMapper.map(statusVO, StatusDTO.class);
    List<StatusDTO> select = statusMapper.select(status);
    if (select.isEmpty()) {
        int isInsert = statusMapper.insert(status);
        if (isInsert != 1) {
            throw new CommonException("error.status.create");
        }
    } else {
        status = select.get(0);
    }
    status = statusMapper.queryById(organizationId, status.getId());
    return modelMapper.map(status, StatusVO.class);
}
 
Example #9
Source File: ObjectSchemeFieldServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public List<AgileIssueHeadVO> getIssueHeadForAgile(Long organizationId, Long projectId, String schemeCode) {
    if (!EnumUtil.contain(ObjectSchemeCode.class, schemeCode)) {
        throw new CommonException(ERROR_SCHEMECODE_ILLEGAL);
    }
    ObjectSchemeFieldSearchVO searchDTO = new ObjectSchemeFieldSearchVO();
    searchDTO.setSchemeCode(schemeCode);
    List<ObjectSchemeFieldDTO> objectSchemeFields = listQuery(organizationId, projectId, searchDTO)
            .stream().filter(objectSchemeField -> !objectSchemeField.getSystem()).collect(Collectors.toList());
    List<AgileIssueHeadVO> agileIssueHeadDTOS = new ArrayList<>();
    objectSchemeFields.forEach(objectSchemeField -> {
        AgileIssueHeadVO agileIssueHeadDTO = new AgileIssueHeadVO();
        agileIssueHeadDTO.setTitle(objectSchemeField.getName());
        agileIssueHeadDTO.setCode(objectSchemeField.getCode());
        agileIssueHeadDTO.setSortId(objectSchemeField.getCode());
        agileIssueHeadDTO.setFieldType(objectSchemeField.getFieldType());
        agileIssueHeadDTOS.add(agileIssueHeadDTO);
    });
    return agileIssueHeadDTOS;
}
 
Example #10
Source File: StatusServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public StatusVO createStatusForAgile(Long organizationId, Long stateMachineId, StatusVO statusVO) {
    if (stateMachineId == null) {
        throw new CommonException("error.stateMachineId.notNull");
    }
    if (stateMachineMapper.queryById(organizationId, stateMachineId) == null) {
        throw new CommonException("error.stateMachine.notFound");
    }

    String statusName = statusVO.getName();
    StatusDTO select = new StatusDTO();
    select.setName(statusName);
    select.setOrganizationId(organizationId);
    List<StatusDTO> list = statusMapper.select(select);
    if (list.isEmpty()) {
        statusVO = create(organizationId, statusVO);
    } else {
        statusVO = modelMapper.map(list.get(0), StatusVO.class);
    }
    //将状态加入状态机中,直接加到发布表中
    nodeService.createNodeAndTransformForAgile(organizationId, stateMachineId, statusVO);
    //清理状态机实例
    instanceCache.cleanStateMachine(stateMachineId);
    return statusVO;
}
 
Example #11
Source File: IssueComponentController.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_MEMBER, InitRoleCode.PROJECT_OWNER})
@ApiOperation("根据project id查询component")
@CustomPageRequest
@PostMapping(value = "/query_all")
public ResponseEntity<PageInfo<ComponentForListVO>> listByProjectId(@ApiParam(value = "项目id", required = true)
                                                                 @PathVariable(name = "project_id") Long projectId,
                                                                    @ApiParam(value = "当前模块id")
                                                                 @RequestParam(required = false) Long componentId,
                                                                    @ApiParam(value = "是否包含测试")
                                                                 @RequestParam(required = false, name = "no_issue_test", defaultValue = "false") Boolean noIssueTest,
                                                                    @ApiParam(value = "查询参数")
                                                                 @RequestBody(required = false) SearchVO searchVO,
                                                                    @ApiParam(value = "分页信息", required = true)
                                                                 @SortDefault(value = "component_id", direction = Sort.Direction.DESC)
                                                                 @ApiIgnore PageRequest pageRequest) {
    return Optional.ofNullable(issueComponentService.queryComponentByProjectId(projectId, componentId, noIssueTest, searchVO, pageRequest))
            .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
            .orElseThrow(() -> new CommonException("error.componentList.get"));
}
 
Example #12
Source File: FeedbackAttachmentServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean delete(Long projectId, Long id) {
    FeedbackAttachmentDTO feedbackAttachmentDTO = feedbackAttachmentMapper.selectByPrimaryKey(id);
    if (feedbackAttachmentDTO == null) {
        throw new CommonException("error.attachment.get");
    }
    Boolean result = deleteById(projectId, id);
    String url = null;
    try {
        url = URLDecoder.decode(feedbackAttachmentDTO.getUrl(), "UTF-8");
        fileFeignClient.deleteFile(BACKETNAME, attachmentUrl + "/" + BACKETNAME + "/" + url);
    } catch (Exception e) {
        LOGGER.error("error.attachment.delete", e);
    }
    return result;
}
 
Example #13
Source File: IssueController.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_MEMBER, InitRoleCode.PROJECT_OWNER})
@ApiOperation("分页过滤查询issue列表提供给测试模块用")
@CustomPageRequest
@PostMapping(value = "/test_component/no_sub")
public ResponseEntity<PageInfo<IssueListTestVO>> listIssueWithoutSubToTestComponent(@ApiIgnore
                                                                                 @ApiParam(value = "分页信息", required = true)
                                                                                 @SortDefault(value = "issueId", direction = Sort.Direction.DESC)
                                                                                         PageRequest pageRequest,
                                                                                    @ApiParam(value = "项目id", required = true)
                                                                                 @PathVariable(name = "project_id") Long projectId,
                                                                                    @ApiParam(value = "组织id", required = true)
                                                                                 @RequestParam Long organizationId,
                                                                                    @ApiParam(value = "查询参数", required = true)
                                                                                 @RequestBody(required = false) SearchVO searchVO) {
    return Optional.ofNullable(issueService.listIssueWithoutSubToTestComponent(projectId, searchVO, pageRequest, organizationId))
            .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
            .orElseThrow(() -> new CommonException("error.Issue.listIssueWithoutSubToTestComponent"));
}
 
Example #14
Source File: StateMachineNodeServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Object> checkDelete(Long organizationId, Long stateMachineId, Long statusId) {
    Map<String, Object> result = new HashMap<>(2);
    StateMachineDTO stateMachine = stateMachineMapper.queryById(organizationId, stateMachineId);
    if (stateMachine == null) {
        throw new CommonException("error.stateMachine.notFound");
    }
    StatusDTO status = statusMapper.queryById(organizationId, statusId);
    if (status == null) {
        throw new CommonException("error.status.notFound");
    }
    //只有草稿状态才进行删除校验
    if (stateMachine.getStatus().equals(StateMachineStatus.CREATE)) {
        result.put("canDelete", true);
    } else {
        result = stateMachineService.checkDeleteNode(organizationId, stateMachineId, statusId);
    }
    return result;
}
 
Example #15
Source File: PiServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public PiDTO startPi(Long programId, PiVO piVO) {
    piValidator.checkPiStart(piVO);
    // create sprint in each project
    createSprintWhenStartPi(programId, piVO.getId());
    // update pi status: doing
    if (piMapper.updateByPrimaryKeySelective(new PiDTO(programId, piVO.getId(), PI_DOING, new Date(), piVO.getObjectVersionNumber())) != 1) {
        throw new CommonException("error.pi.update");
    }
    // update issue status
    List<IssueDTO> issueDTOList = issueMapper.selectStatusChangeIssueByPiId(programId, piVO.getId());
    Long updateStatusId = piVO.getUpdateStatusId();
    if (updateStatusId != null) {
        if (issueDTOList != null && !issueDTOList.isEmpty()) {
            CustomUserDetails customUserDetails = DetailsHelper.getUserDetails();
            issueAccessDataService.updateStatusIdBatch(programId, updateStatusId, issueDTOList, customUserDetails.getUserId(), new Date());
        }
    }
    return piMapper.selectByPrimaryKey(piVO.getId());
}
 
Example #16
Source File: IssueTypeSchemeServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化方案
 *
 * @param projectId
 * @param organizationId
 * @param name
 * @param defaultIssueTypeId
 * @param schemeApplyType
 * @param issueTypeMap
 */
private void initScheme(Long projectId, Long organizationId, String name, Long defaultIssueTypeId, String schemeApplyType, Map<String, IssueTypeDTO> issueTypeMap) {
    //初始化敏捷问题类型方案
    IssueTypeSchemeDTO issueTypeScheme = new IssueTypeSchemeDTO();
    issueTypeScheme.setName(name);
    issueTypeScheme.setDefaultIssueTypeId(defaultIssueTypeId);
    issueTypeScheme.setApplyType(schemeApplyType);
    issueTypeScheme.setOrganizationId(organizationId);
    issueTypeScheme.setDescription(name);
    //保证幂等性
    List<IssueTypeSchemeDTO> issueTypeSchemes = issueTypeSchemeMapper.select(issueTypeScheme);
    if (issueTypeSchemes.isEmpty()) {
        baseCreate(issueTypeScheme);
        Integer sequence = 0;
        for (InitIssueType initIssueType : InitIssueType.listByApplyType(schemeApplyType)) {
            sequence++;
            IssueTypeDTO issueType = issueTypeMap.get(initIssueType.getTypeCode());
            IssueTypeSchemeConfigDTO schemeConfig = new IssueTypeSchemeConfigDTO(issueTypeScheme.getId(), issueType.getId(), organizationId, BigDecimal.valueOf(sequence));
            if (issueTypeSchemeConfigMapper.insert(schemeConfig) != 1) {
                throw new CommonException("error.issueTypeSchemeConfig.create");
            }
        }
        //创建与项目的关联关系
        projectConfigService.create(projectId, issueTypeScheme.getId(), SchemeType.ISSUE_TYPE, schemeApplyType);
    }
}
 
Example #17
Source File: PriorityServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
private PriorityDTO savePrority(Long organizationId, String name, BigDecimal sequence, String colour, Boolean isDefault) {
    PriorityDTO priority = new PriorityDTO();
    priority.setOrganizationId(organizationId);
    priority.setName(name);
    priority.setSequence(sequence);
    priority.setColour(colour);
    priority.setDescription(name);
    priority.setDefault(isDefault);
    priority.setEnable(true);
    //保证幂等性
    List<PriorityDTO> list = priorityMapper.select(priority);
    if (list.isEmpty()) {
        if (priorityMapper.insert(priority) != 1) {
            throw new CommonException("error.prority.insert");
        }
    } else {
        priority = list.get(0);
    }

    return priority;
}
 
Example #18
Source File: IssueServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
private Map<String, String[]> handleExportFieldsInProgram(List<String> exportFieldCodes) {
    Map<String, String[]> fieldMap = new HashMap<>(2);
    if (exportFieldCodes != null && exportFieldCodes.size() != 0) {
        Map<String, String> data = new HashMap<>(FIELDS_IN_PROGRAM.length);
        for (int i = 0; i < FIELDS_IN_PROGRAM.length; i++) {
            data.put(FIELDS_IN_PROGRAM[i], FIELDS_NAME_IN_PROGRAM[i]);
        }
        List<String> fieldCodes = new ArrayList<>(exportFieldCodes.size());
        List<String> fieldNames = new ArrayList<>(exportFieldCodes.size());
        exportFieldCodes.stream().forEach(code -> {
            String name = data.get(code);
            if (name != null) {
                fieldCodes.add(code);
                fieldNames.add(name);
            } else {
                throw new CommonException("error.issue.exportFieldIllegal");
            }
        });
        fieldMap.put(FIELD_CODES, fieldCodes.stream().toArray(String[]::new));
        fieldMap.put(FIELD_NAMES, fieldNames.stream().toArray(String[]::new));
    } else {
        fieldMap.put(FIELD_CODES, FIELDS_IN_PROGRAM);
        fieldMap.put(FIELD_NAMES, FIELDS_NAME_IN_PROGRAM);
    }
    return fieldMap;
}
 
Example #19
Source File: ObjectSchemeFieldServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public Map<String, Object> listQuery(Long organizationId, Long projectId, String schemeCode) {
    Map<String, Object> result = new HashMap<>(2);
    if (!EnumUtil.contain(ObjectSchemeCode.class, schemeCode)) {
        throw new CommonException(ERROR_SCHEMECODE_ILLEGAL);
    }
    ObjectSchemeFieldSearchVO searchDTO = new ObjectSchemeFieldSearchVO();
    searchDTO.setSchemeCode(schemeCode);
    List<ObjectSchemeFieldVO> fieldDTOS = modelMapper.map(listQuery(organizationId, projectId, searchDTO), new TypeToken<List<ObjectSchemeFieldVO>>() {
    }.getType());
    fillContextName(fieldDTOS);
    ObjectSchemeDTO select = new ObjectSchemeDTO();
    select.setSchemeCode(schemeCode);
    result.put("name", objectSchemeMapper.selectOne(select).getName());
    result.put("content", fieldDTOS);
    return result;
}
 
Example #20
Source File: StateMachineSchemeServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化状态机方案
 *
 * @param name
 * @param schemeApplyType
 * @param projectEvent
 */
private void initScheme(String name, String schemeApplyType, ProjectEvent projectEvent) {
    Long projectId = projectEvent.getProjectId();
    Long organizationId = projectUtil.getOrganizationId(projectId);
    Long stateMachineId = initService.createStateMachineWithCreateProject(organizationId, schemeApplyType, projectEvent);

    StateMachineSchemeDTO scheme = new StateMachineSchemeDTO();
    scheme.setStatus(StateMachineSchemeStatus.CREATE);
    scheme.setName(name);
    scheme.setDescription(name);
    scheme.setOrganizationId(organizationId);
    //保证幂等性
    List<StateMachineSchemeDTO> stateMachines = schemeMapper.select(scheme);
    if (stateMachines.isEmpty()) {
        int isInsert = schemeMapper.insert(scheme);
        if (isInsert != 1) {
            throw new CommonException("error.stateMachineScheme.create");
        }
        //创建默认状态机配置
        configService.createDefaultConfig(organizationId, scheme.getId(), stateMachineId);
        //创建与项目的关联关系
        projectConfigService.create(projectId, scheme.getId(), SchemeType.STATE_MACHINE, schemeApplyType);
    }
}
 
Example #21
Source File: IssueTypeSchemeServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean delete(Long organizationId, Long issueTypeSchemeId) {
    Map<String, Object> result = checkDelete(organizationId, issueTypeSchemeId);
    Boolean canDelete = (Boolean) result.get("canDelete");
    if (canDelete) {
        int isDelete = issueTypeSchemeMapper.deleteByPrimaryKey(issueTypeSchemeId);
        if (isDelete != 1) {
            throw new CommonException("error.issueType.delete");
        }
        issueTypeSchemeConfigMapper.deleteBySchemeId(organizationId, issueTypeSchemeId);
        //关联删除一些东西【toDo】
    } else {
        return false;
    }
    return true;
}
 
Example #22
Source File: ProductVersionServiceImpl.java    From agile-service-old with Apache License 2.0 6 votes vote down vote up
@Saga(code = "agile-delete-version", description = "删除版本", inputSchemaClass = VersionPayload.class)
private Boolean simpleDeleteVersion(Long projectId, Long versionId) {
    try {
        ProductVersionDTO version = new ProductVersionDTO();
        version.setProjectId(projectId);
        version.setVersionId(versionId);
        ProductVersionDTO versionDTO = productVersionMapper.selectOne(version);
        if (versionDTO == null) {
            throw new CommonException(NOT_FOUND);
        }
        Boolean deleteResult = iProductVersionService.delete(versionDTO);
        VersionPayload versionPayload = new VersionPayload();
        versionPayload.setVersionId(versionDTO.getVersionId());
        versionPayload.setProjectId(versionDTO.getProjectId());
        sagaClient.startSaga("agile-delete-version", new StartInstanceDTO(JSON.toJSONString(versionPayload), "", "", ResourceLevel.PROJECT.value(), projectId));
        return deleteResult;
    } catch (Exception e) {
        throw new CommonException(e.getMessage());
    }
}
 
Example #23
Source File: ObjectSchemeFieldServiceImpl.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean checkName(Long organizationId, Long projectId, String name, String schemeCode) {
    if (!EnumUtil.contain(ObjectSchemeCode.class, schemeCode)) {
        throw new CommonException(ERROR_SCHEMECODE_ILLEGAL);
    }
    ObjectSchemeFieldSearchVO search = new ObjectSchemeFieldSearchVO();
    search.setName(name);
    search.setSchemeCode(schemeCode);
    return !listQuery(organizationId, projectId, search).isEmpty();
}
 
Example #24
Source File: ArtServiceImpl.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Override
public ArtDTO startArt(Long programId, ArtVO artVO) {
    artValidator.checkArtStart(artVO);
    if (artMapper.updateByPrimaryKeySelective(new ArtDTO(programId, artVO.getId(), ART_DOING, artVO.getObjectVersionNumber())) != 1) {
        throw new CommonException("error.art.update");
    }
    ArtDTO artDTO = artMapper.selectByPrimaryKey(artVO.getId());
    piService.createPi(programId, artDTO, artDTO.getStartDate());
    // 开启ART第一个PI
    startArtFirstPI(programId, artDTO.getId());
    return artDTO;
}
 
Example #25
Source File: IssueTypeServiceImpl.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Override
public IssueTypeVO create(Long organizationId, IssueTypeVO issueTypeVO) {
    if (!checkName(organizationId, issueTypeVO.getName(), null)) {
        throw new CommonException("error.issueType.checkName");
    }
    issueTypeVO.setOrganizationId(organizationId);
    IssueTypeDTO issueType = modelMapper.map(issueTypeVO, IssueTypeDTO.class);
    return modelMapper.map(createIssueType(issueType), IssueTypeVO.class);
}
 
Example #26
Source File: BoardSprintAttrServiceImpl.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Override
public BoardSprintAttrVO updateColumnWidth(Long projectId, Long sprintId, Integer columnWidth) {
    BoardSprintAttrDTO origin = queryBySprintId(projectId, sprintId);
    if (origin == null) {
        create(projectId, sprintId, columnWidth);
    } else {
        if (columnWidth > MAX_COLUMN_WIDTH || columnWidth < MIN_COLUMN_WIDTH) {
            throw new CommonException(ILLEGAL_ERROR);
        }
        origin.setColumnWidth(columnWidth);
        update(origin);
    }
    return modelMapper.map(queryBySprintId(projectId, sprintId), BoardSprintAttrVO.class);
}
 
Example #27
Source File: ProductVersionController.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_MEMBER, InitRoleCode.PROJECT_OWNER})
@ApiOperation(value = "dashboard根据版本下类别统计数量数量")
@GetMapping(value = "/{versionId}/issue_count")
public ResponseEntity<VersionIssueCountVO> queryByCategoryCode(@ApiParam(value = "项目id", required = true)
                                                                @PathVariable(name = "project_id") Long projectId,
                                                               @ApiParam(value = "version id", required = true)
                                                                @PathVariable Long versionId) {
    return Optional.ofNullable(productVersionService.queryByCategoryCode(projectId, versionId))
            .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
            .orElseThrow(() -> new CommonException("error.VersionIssueCountVO.get"));
}
 
Example #28
Source File: StateMachineConfigServiceImpl.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
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");
    }

}
 
Example #29
Source File: IssueCommentController.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Permission(type = ResourceType.PROJECT, roles = {InitRoleCode.PROJECT_MEMBER, InitRoleCode.PROJECT_OWNER})
@ApiOperation("通过issueId查询issue评论列表")
@GetMapping(value = "/{issueId}")
public ResponseEntity<List<IssueCommentVO>> queryIssueCommentList(@ApiParam(value = "项目id", required = true)
                                                                   @PathVariable(name = "project_id") Long projectId,
                                                                  @ApiParam(value = "issueId", required = true)
                                                                   @PathVariable Long issueId) {
    return Optional.ofNullable(issueCommentService.queryIssueCommentList(projectId, issueId))
            .map(result -> new ResponseEntity<>(result, HttpStatus.OK))
            .orElseThrow(() -> new CommonException("error.IssueComment.queryIssueCommentList"));
}
 
Example #30
Source File: TimeZoneWorkCalendarServiceImpl.java    From agile-service-old with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteTimeZoneWorkCalendarRef(Long organizationId, Long calendarId) {
    TimeZoneWorkCalendarRefDTO timeZoneWorkCalendarRefDTO = new TimeZoneWorkCalendarRefDTO();
    timeZoneWorkCalendarRefDTO.setOrganizationId(organizationId);
    timeZoneWorkCalendarRefDTO.setCalendarId(calendarId);
    int isDelete = timeZoneWorkCalendarRefMapper.delete(timeZoneWorkCalendarRefDTO);
    if (isDelete != 1) {
        throw new CommonException(DELETE_ERROR);
    }
}