Search in sources :

Example 1 with RuleMetricValueResponse

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

the class RuleMetricServiceImpl method getResultsByRuleMetric.

@Override
public DataInfo<RuleMetricValueResponse> getResultsByRuleMetric(long ruleMetricId, int page, int size) throws UnExpectedRequestException {
    DataInfo<RuleMetricValueResponse> dataInfo = new DataInfo<>();
    int total = taskResultDao.countValuesByRuleMetric(ruleMetricId);
    List<TaskResult> values = taskResultDao.findValuesByRuleMetric(ruleMetricId, page, size);
    List<RuleMetricValueResponse> responses = new ArrayList<>(values.size());
    for (TaskResult taskResult : values) {
        if (taskResult == null) {
            continue;
        }
        RuleMetricValueResponse ruleMetricValueResponse = new RuleMetricValueResponse();
        ruleMetricValueResponse.setGenerateTime(taskResult.getCreateTime());
        Rule currentRule = ruleDao.findById(taskResult.getRuleId());
        ruleMetricValueResponse.setRelatedRuleName(currentRule == null ? "Deleted" : currentRule.getName());
        ruleMetricValueResponse.setRuleMetricValue(StringUtils.isBlank(taskResult.getValue()) ? "0" : taskResult.getValue());
        responses.add(ruleMetricValueResponse);
    }
    dataInfo.setContent(responses);
    dataInfo.setTotalCount(total);
    return dataInfo;
}
Also used : DataInfo(com.webank.wedatasphere.qualitis.metadata.response.DataInfo) RuleMetricValueResponse(com.webank.wedatasphere.qualitis.response.RuleMetricValueResponse) ArrayList(java.util.ArrayList) TaskResult(com.webank.wedatasphere.qualitis.entity.TaskResult) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Aggregations

TaskResult (com.webank.wedatasphere.qualitis.entity.TaskResult)1 DataInfo (com.webank.wedatasphere.qualitis.metadata.response.DataInfo)1 RuleMetricValueResponse (com.webank.wedatasphere.qualitis.response.RuleMetricValueResponse)1 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)1 ArrayList (java.util.ArrayList)1