Search in sources :

Example 16 with RuleGroup

use of com.webank.wedatasphere.qualitis.rule.entity.RuleGroup 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

RuleGroup (com.webank.wedatasphere.qualitis.rule.entity.RuleGroup)16 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)15 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)12 ArrayList (java.util.ArrayList)12 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)10 Project (com.webank.wedatasphere.qualitis.project.entity.Project)8 IOException (java.io.IOException)6 PermissionDeniedRequestException (com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException)5 MetaDataAcquireFailedException (com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException)5 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)5 RuleDataSource (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource)5 Date (java.util.Date)5 ArgumentException (com.webank.wedatasphere.qualitis.exception.ArgumentException)4 BothNullDatasourceException (com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException)4 ClusterInfoNotConfigException (com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException)4 ConvertException (com.webank.wedatasphere.qualitis.exception.ConvertException)4 DataQualityTaskException (com.webank.wedatasphere.qualitis.exception.DataQualityTaskException)4 DataSourceMoveException (com.webank.wedatasphere.qualitis.exception.DataSourceMoveException)4 DataSourceOverSizeException (com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException)4 JobKillException (com.webank.wedatasphere.qualitis.exception.JobKillException)4