Search in sources :

Example 1 with RuleGroupResponse

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

the class RuleGroupController method getRuleByRuleGroupId.

@GET
@Path("/{rule_group_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public GeneralResponse<?> getRuleByRuleGroupId(@PathParam("rule_group_id") Long ruleGroupId) throws UnExpectedRequestException {
    try {
        // 查看ruleGroup是否存在
        RuleGroup ruleGroupInDb = ruleGroupDao.findById(ruleGroupId);
        if (ruleGroupInDb == null) {
            throw new UnExpectedRequestException(String.format("Rule Group: %s {&DOES_NOT_EXIST}", ruleGroupId));
        }
        List<RuleResponse> ruleList = ruleDao.findByRuleGroup(ruleGroupInDb).stream().map(rule -> new RuleResponse(rule)).collect(Collectors.toList());
        return new GeneralResponse<>("200", "Succeed to find rules by rule group id", new RuleGroupResponse(ruleGroupId, ruleList));
    } catch (UnExpectedRequestException e) {
        throw new UnExpectedRequestException(e.getMessage());
    } catch (Exception e) {
        LOGGER.error("Failed to get rules by rule group id. rule_group_id: {}, caused by: {}", ruleGroupId, e.getMessage(), e);
        return new GeneralResponse<>("500", "{&FAILED_TO_GET_RULES_BY_RULE_GROUP}", null);
    }
}
Also used : Logger(org.slf4j.Logger) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) ModifyRuleGroupRequest(com.webank.wedatasphere.qualitis.rule.request.ModifyRuleGroupRequest) LoggerFactory(org.slf4j.LoggerFactory) RuleResponse(com.webank.wedatasphere.qualitis.rule.response.RuleResponse) Autowired(org.springframework.beans.factory.annotation.Autowired) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) Collectors(java.util.stream.Collectors) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) MediaType(javax.ws.rs.core.MediaType) List(java.util.List) javax.ws.rs(javax.ws.rs) RuleDao(com.webank.wedatasphere.qualitis.rule.dao.RuleDao) RuleGroupDao(com.webank.wedatasphere.qualitis.rule.dao.RuleGroupDao) RuleGroupResponse(com.webank.wedatasphere.qualitis.rule.response.RuleGroupResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) RuleDetailResponse(com.webank.wedatasphere.qualitis.rule.response.RuleDetailResponse) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) RuleResponse(com.webank.wedatasphere.qualitis.rule.response.RuleResponse) RuleGroupResponse(com.webank.wedatasphere.qualitis.rule.response.RuleGroupResponse) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)

Aggregations

UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 RuleDao (com.webank.wedatasphere.qualitis.rule.dao.RuleDao)1 RuleGroupDao (com.webank.wedatasphere.qualitis.rule.dao.RuleGroupDao)1 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)1 RuleGroup (com.webank.wedatasphere.qualitis.rule.entity.RuleGroup)1 ModifyRuleGroupRequest (com.webank.wedatasphere.qualitis.rule.request.ModifyRuleGroupRequest)1 RuleDetailResponse (com.webank.wedatasphere.qualitis.rule.response.RuleDetailResponse)1 RuleGroupResponse (com.webank.wedatasphere.qualitis.rule.response.RuleGroupResponse)1 RuleResponse (com.webank.wedatasphere.qualitis.rule.response.RuleResponse)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 javax.ws.rs (javax.ws.rs)1 MediaType (javax.ws.rs.core.MediaType)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1