use of com.webank.wedatasphere.qualitis.rule.response.RuleResponse 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);
}
}
Aggregations