Search in sources :

Example 6 with ExcelCustomRuleByProject

use of com.webank.wedatasphere.qualitis.project.excel.ExcelCustomRuleByProject in project Qualitis by WeBankFinTech.

the class RuleBatchServiceImpl method getCustomRule.

@Override
public List<ExcelCustomRuleByProject> getCustomRule(Iterable<Rule> rules, String localeStr) {
    List<ExcelCustomRuleByProject> lines = new ArrayList<>();
    for (Rule rule : rules) {
        if (!rule.getRuleType().equals(RuleTypeEnum.CUSTOM_RULE.getCode())) {
            continue;
        }
        ExcelCustomRuleByProject ruleLinePrefix = new ExcelCustomRuleByProject();
        basicInfoToExcel(ruleLinePrefix, rule);
        lines.add(ruleLinePrefix);
        for (AlarmConfig alarmConfig : rule.getAlarmConfigs()) {
            Double threshold = alarmConfig.getThreshold();
            String alarmOutputName = alarmConfig.getTemplateOutputMeta().getOutputName();
            String alarmCompareType = CompareTypeEnum.getCompareTypeName(alarmConfig.getCompareType());
            String checkTemplateName = CheckTemplateEnum.getCheckTemplateName(alarmConfig.getCheckTemplate(), localeStr);
            ExcelCustomRuleByProject tmp = new ExcelCustomRuleByProject(rule.getName());
            tmp.setCompareType(alarmCompareType);
            tmp.setAlarmCheckName(alarmOutputName);
            tmp.setThreshold(String.valueOf(threshold));
            tmp.setCheckTemplateName(checkTemplateName);
            RuleMetric ruleMetric = alarmConfig.getRuleMetric();
            // Recod rule metric info (unique code).
            if (ruleMetric != null) {
                String enCode = ruleMetric.getEnCode();
                tmp.setRuleMetricEnCode(enCode);
                tmp.setRuleMetricName(ruleMetric.getName());
            }
            tmp.setUploadRuleMetricValue(alarmConfig.getUploadRuleMetricValue());
            tmp.setUploadAbnormalValue(alarmConfig.getUploadAbnormalValue());
            lines.add(tmp);
        }
    }
    return lines;
}
Also used : RuleMetric(com.webank.wedatasphere.qualitis.entity.RuleMetric) ExcelCustomRuleByProject(com.webank.wedatasphere.qualitis.project.excel.ExcelCustomRuleByProject) ArrayList(java.util.ArrayList) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) AlarmConfig(com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)

Example 7 with ExcelCustomRuleByProject

use of com.webank.wedatasphere.qualitis.project.excel.ExcelCustomRuleByProject in project Qualitis by WeBankFinTech.

the class ExcelRuleListener method invoke.

@Override
public void invoke(Object object, AnalysisContext context) {
    if (context.getCurrentSheet().getSheetName().equals(ExcelSheetName.TEMPLATE_RULE_NAME)) {
        ExcelTemplateRuleByProject excelTemplateRuleByProject = (ExcelTemplateRuleByProject) object;
        String key = excelTemplateRuleByProject.getRuleName();
        if (templateExcelContent.containsKey(key)) {
            templateExcelContent.get(key).add(excelTemplateRuleByProject);
        } else {
            List<ExcelTemplateRuleByProject> tmp = new ArrayList<>();
            tmp.add(excelTemplateRuleByProject);
            templateExcelContent.put(key, tmp);
        }
    } else if (context.getCurrentSheet().getSheetName().equals(ExcelSheetName.CUSTOM_RULE_NAME)) {
        ExcelCustomRuleByProject excelCustomRule = (ExcelCustomRuleByProject) object;
        String key = excelCustomRule.getRuleName();
        if (customExcelContent.containsKey(key)) {
            customExcelContent.get(key).add(excelCustomRule);
        } else {
            List<ExcelCustomRuleByProject> tmp = new ArrayList<>();
            tmp.add(excelCustomRule);
            customExcelContent.put(key, tmp);
        }
    } else if (context.getCurrentSheet().getSheetName().equals(ExcelSheetName.MULTI_TEMPLATE_RULE_NAME)) {
        ExcelMultiTemplateRuleByProject excelMultiTemplateRule = (ExcelMultiTemplateRuleByProject) object;
        String key = excelMultiTemplateRule.getRuleName();
        if (multiTemplateExcelContent.containsKey(key)) {
            multiTemplateExcelContent.get(key).add(excelMultiTemplateRule);
        } else {
            List<ExcelMultiTemplateRuleByProject> tmp = new ArrayList<>();
            tmp.add(excelMultiTemplateRule);
            multiTemplateExcelContent.put(key, tmp);
        }
    } else if (context.getCurrentSheet().getSheetName().equals(ExcelSheetName.TEMPLATE_FILE_RULE_NAME)) {
        ExcelTemplateFileRuleByProject excelTemplateFileRule = (ExcelTemplateFileRuleByProject) object;
        String key = excelTemplateFileRule.getRuleName();
        if (templateFileExcelContent.containsKey(key)) {
            templateFileExcelContent.get(key).add(excelTemplateFileRule);
        } else {
            List<ExcelTemplateFileRuleByProject> tmp = new ArrayList<>();
            tmp.add(excelTemplateFileRule);
            templateFileExcelContent.put(key, tmp);
        }
    }
}
Also used : ExcelMultiTemplateRuleByProject(com.webank.wedatasphere.qualitis.project.excel.ExcelMultiTemplateRuleByProject) ExcelCustomRuleByProject(com.webank.wedatasphere.qualitis.project.excel.ExcelCustomRuleByProject) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ExcelTemplateFileRuleByProject(com.webank.wedatasphere.qualitis.project.excel.ExcelTemplateFileRuleByProject) ExcelTemplateRuleByProject(com.webank.wedatasphere.qualitis.project.excel.ExcelTemplateRuleByProject)

Aggregations

ExcelCustomRuleByProject (com.webank.wedatasphere.qualitis.project.excel.ExcelCustomRuleByProject)7 ExcelMultiTemplateRuleByProject (com.webank.wedatasphere.qualitis.project.excel.ExcelMultiTemplateRuleByProject)5 ExcelTemplateRuleByProject (com.webank.wedatasphere.qualitis.project.excel.ExcelTemplateRuleByProject)5 ArrayList (java.util.ArrayList)3 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)2 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)2 Project (com.webank.wedatasphere.qualitis.project.entity.Project)2 ExcelTemplateFileRuleByProject (com.webank.wedatasphere.qualitis.project.excel.ExcelTemplateFileRuleByProject)2 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)2 OutputStream (java.io.OutputStream)2 RuleMetricDepartmentUser (com.webank.wedatasphere.qualitis.entity.RuleMetricDepartmentUser)1 User (com.webank.wedatasphere.qualitis.entity.User)1 PermissionDeniedRequestException (com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException)1 ExcelProjectListener (com.webank.wedatasphere.qualitis.project.excel.ExcelProjectListener)1 AddProjectRequest (com.webank.wedatasphere.qualitis.project.request.AddProjectRequest)1 ModifyProjectDetailRequest (com.webank.wedatasphere.qualitis.project.request.ModifyProjectDetailRequest)1 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)1 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)1 RuleGroup (com.webank.wedatasphere.qualitis.rule.entity.RuleGroup)1 WriteExcelException (com.webank.wedatasphere.qualitis.rule.exception.WriteExcelException)1