Search in sources :

Example 1 with CustomRuleDetailResponse

use of com.webank.wedatasphere.qualitis.rule.response.CustomRuleDetailResponse in project Qualitis by WeBankFinTech.

the class CustomRuleServiceImpl method getCustomRuleDetail.

@Override
public GeneralResponse<CustomRuleDetailResponse> getCustomRuleDetail(Long ruleId) throws UnExpectedRequestException {
    // Check existence of rule
    Rule ruleInDb = ruleDao.findById(ruleId);
    if (ruleInDb == null) {
        throw new UnExpectedRequestException("rule_id [" + ruleId + "] {&DOES_NOT_EXIST}");
    }
    if (!ruleInDb.getRuleType().equals(RuleTypeEnum.CUSTOM_RULE.getCode())) {
        throw new UnExpectedRequestException("rule(id: [" + ruleId + "]) {&IS_NOT_A_CUSTOM_RULE}");
    }
    Long projectInDbId = ruleInDb.getProject().getId();
    String loginUser = HttpUtils.getUserName(httpServletRequest);
    projectService.checkProjectExistence(projectInDbId, loginUser);
    LOGGER.info("Succeed to find rule. rule_id: {}", ruleInDb.getId());
    CustomRuleDetailResponse response = new CustomRuleDetailResponse(ruleInDb);
    LOGGER.info("Succeed to get custom rule detail. response: {}", response);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_CUSTOM_RULE_DETAIL}", response);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) CustomRuleDetailResponse(com.webank.wedatasphere.qualitis.rule.response.CustomRuleDetailResponse) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Aggregations

UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)1 CustomRuleDetailResponse (com.webank.wedatasphere.qualitis.rule.response.CustomRuleDetailResponse)1