Search in sources :

Example 1 with AlarmConfigRequest

use of com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest in project Qualitis by WeBankFinTech.

the class RuleBatchServiceImpl method getAlarmConfig.

private void getAlarmConfig(List<AlarmConfigRequest> alarmConfigRequests, ExcelTemplateRuleByProject excelTemplateRule, Template template, String localeStr) throws UnExpectedRequestException {
    String templateOutputName = excelTemplateRule.getAlarmCheckName();
    if (!StringUtils.isBlank(templateOutputName)) {
        String checkTemplateName = excelTemplateRule.getCheckTemplateName();
        String compareTypeName = excelTemplateRule.getCompareType();
        String threshold = excelTemplateRule.getThreshold();
        TemplateOutputMeta templateOutputMeta = findTemplateOutputMetaByTemplateAndOutputName(template, templateOutputName);
        if (templateOutputMeta == null) {
            throw new UnExpectedRequestException("{&TEMPLATE_OUTPUT_NAME} {&DOES_NOT_EXIST}");
        }
        AlarmConfigRequest alarmConfigRequest = new AlarmConfigRequest();
        alarmConfigRequest.setCheckTemplate(CheckTemplateEnum.getCheckTemplateCode(checkTemplateName, localeStr));
        alarmConfigRequest.setCompareType(CompareTypeEnum.getCompareTypeCode(compareTypeName));
        alarmConfigRequest.setThreshold(Double.valueOf(threshold));
        alarmConfigRequest.setOutputMetaId(templateOutputMeta.getId());
        // Rule Metric.
        String ruleMetricEnCode = excelTemplateRule.getRuleMetricEnCode();
        if (StringUtils.isNotBlank(ruleMetricEnCode)) {
            // xx_xx_xx_encode, index is 3.
            RuleMetric ruleMetricInDb = ruleMetricDao.findByEnCode(ruleMetricEnCode);
            if (ruleMetricInDb == null) {
                throw new UnExpectedRequestException("Rule metric[Code=" + ruleMetricEnCode + "] " + "{&DOES_NOT_EXIST}");
            }
            String code = ruleMetricInDb.getEnCode();
            alarmConfigRequest.setRuleMetricEnCode(code);
        }
        alarmConfigRequest.setUploadRuleMetricValue(excelTemplateRule.getUploadRuleMetricValue());
        alarmConfigRequest.setUploadAbnormalValue(excelTemplateRule.getUploadAbnormalValue());
        alarmConfigRequests.add(alarmConfigRequest);
    }
}
Also used : RuleMetric(com.webank.wedatasphere.qualitis.entity.RuleMetric) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) FileAlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.FileAlarmConfigRequest) CustomAlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.CustomAlarmConfigRequest) AlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest) TemplateOutputMeta(com.webank.wedatasphere.qualitis.rule.entity.TemplateOutputMeta)

Example 2 with AlarmConfigRequest

use of com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest in project Qualitis by WeBankFinTech.

the class AddMultiRuleRequestBuilder method initAlarm.

private void initAlarm(List<AlarmConfigRequest> alarmVariable, boolean uploadRuleMetricValue, boolean uploadAbnormalValue) {
    if (this.getTemplate().getSaveMidTable()) {
        addMultiSourceRuleRequest.setAlarm(true);
        AlarmConfigRequest alarmConfigRequest = new AlarmConfigRequest();
        alarmConfigRequest.setUploadRuleMetricValue(uploadRuleMetricValue);
        alarmConfigRequest.setUploadAbnormalValue(uploadAbnormalValue);
        alarmConfigRequest.setOutputMetaId(template.getTemplateOutputMetas().iterator().next().getId());
        alarmConfigRequest.setCheckTemplate(CheckTemplateEnum.FIXED_VALUE.getCode());
        alarmConfigRequest.setCompareType(CompareTypeEnum.EQUAL.getCode());
        alarmConfigRequest.setThreshold(0.0);
        alarmVariable.add(alarmConfigRequest);
    } else {
        addMultiSourceRuleRequest.setAlarm(false);
    }
    setUploadAbnormalValue(uploadAbnormalValue);
    setUploadRuleMetricValue(uploadRuleMetricValue);
    addMultiSourceRuleRequest.setAlarmVariable(alarmVariable);
}
Also used : AlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest)

Example 3 with AlarmConfigRequest

use of com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest in project Qualitis by WeBankFinTech.

the class AddRuleRequestBuilder method initAlarm.

private void initAlarm(List<AlarmConfigRequest> alarmVariable, boolean uploadRuleMetricValue, boolean uploadAbnormalValue) {
    addRuleRequest.setAlarm(true);
    AlarmConfigRequest alarmConfigRequest = new AlarmConfigRequest();
    alarmConfigRequest.setUploadRuleMetricValue(uploadRuleMetricValue);
    alarmConfigRequest.setUploadAbnormalValue(uploadAbnormalValue);
    alarmConfigRequest.setOutputMetaId(template.getTemplateOutputMetas().iterator().next().getId());
    alarmConfigRequest.setCheckTemplate(CheckTemplateEnum.FIXED_VALUE.getCode());
    alarmConfigRequest.setCompareType(CompareTypeEnum.EQUAL.getCode());
    alarmConfigRequest.setThreshold(0.0);
    alarmVariable.add(alarmConfigRequest);
    setUploadRuleMetricValue(uploadRuleMetricValue);
    setUploadAbnormalValue(uploadAbnormalValue);
    addRuleRequest.setAlarmVariable(alarmVariable);
}
Also used : AlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest)

Example 4 with AlarmConfigRequest

use of com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest in project Qualitis by WeBankFinTech.

the class AddRuleRequestBuilder method commonAlarmSetting.

public AlarmConfigRequest commonAlarmSetting(Integer checkTemplateEnum, Integer compareType, double value) {
    AlarmConfigRequest newAlarmConfigRequest = new AlarmConfigRequest();
    newAlarmConfigRequest.setUploadAbnormalValue(getUploadAbnormalValue());
    newAlarmConfigRequest.setUploadRuleMetricValue(getUploadRuleMetricValue());
    newAlarmConfigRequest.setOutputMetaId(template.getTemplateOutputMetas().iterator().next().getId());
    newAlarmConfigRequest.setRuleMetricEnCode(getRuleMetricEnCode());
    newAlarmConfigRequest.setThreshold(value);
    switch(checkTemplateEnum) {
        case 1:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.MONTH_FLUCTUATION.getCode());
            break;
        case 2:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.WEEK_FLUCTUATION.getCode());
            break;
        case 3:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.DAY_FLUCTUATION.getCode());
            break;
        case 4:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.FIXED_VALUE.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 5:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.FULL_YEAR_RING_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 6:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.HALF_YEAR_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 7:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.SEASON_RING_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 8:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.MONTH_RING_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 9:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.WEEK_RING_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 10:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.DAY_RING_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 11:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.HOUR_RING_GROWTH.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 12:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.YEAR_ON_YEAR.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        default:
            addRuleRequest.setAlarm(false);
            LOGGER.info("");
    }
    return newAlarmConfigRequest;
}
Also used : AlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest)

Example 5 with AlarmConfigRequest

use of com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest in project Qualitis by WeBankFinTech.

the class AddRuleRequestBuilder method commonAlarmSetting.

public AlarmConfigRequest commonAlarmSetting(Integer checkTemplateEnum, Integer compareType, String value) {
    AlarmConfigRequest newAlarmConfigRequest = new AlarmConfigRequest();
    newAlarmConfigRequest.setUploadAbnormalValue(getUploadAbnormalValue());
    newAlarmConfigRequest.setUploadRuleMetricValue(getUploadRuleMetricValue());
    newAlarmConfigRequest.setOutputMetaId(template.getTemplateOutputMetas().iterator().next().getId());
    newAlarmConfigRequest.setRuleMetricEnCode(getRuleMetricEnCode());
    newAlarmConfigRequest.setThreshold(Double.parseDouble(value));
    switch(checkTemplateEnum) {
        case 1:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.MONTH_FLUCTUATION.getCode());
            break;
        case 2:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.WEEK_FLUCTUATION.getCode());
            break;
        case 3:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.DAY_FLUCTUATION.getCode());
            break;
        case 4:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.FIXED_VALUE.getCode());
            newAlarmConfigRequest.setCompareType(compareType);
            break;
        case 5:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.FULL_YEAR_RING_GROWTH.getCode());
            break;
        case 6:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.HALF_YEAR_GROWTH.getCode());
            break;
        case 7:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.SEASON_RING_GROWTH.getCode());
            break;
        case 8:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.MONTH_RING_GROWTH.getCode());
            break;
        case 9:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.WEEK_RING_GROWTH.getCode());
            break;
        case 10:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.DAY_RING_GROWTH.getCode());
            break;
        case 11:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.HOUR_RING_GROWTH.getCode());
            break;
        case 12:
            newAlarmConfigRequest.setCheckTemplate(CheckTemplateEnum.YEAR_ON_YEAR.getCode());
            break;
        default:
            addRuleRequest.setAlarm(false);
            LOGGER.info("");
    }
    return newAlarmConfigRequest;
}
Also used : AlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest)

Aggregations

AlarmConfigRequest (com.webank.wedatasphere.qualitis.rule.request.AlarmConfigRequest)14 CustomAlarmConfigRequest (com.webank.wedatasphere.qualitis.rule.request.CustomAlarmConfigRequest)7 FileAlarmConfigRequest (com.webank.wedatasphere.qualitis.rule.request.FileAlarmConfigRequest)7 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)6 ArrayList (java.util.ArrayList)6 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)5 TemplateOutputMeta (com.webank.wedatasphere.qualitis.rule.entity.TemplateOutputMeta)4 AddMultiSourceRuleRequest (com.webank.wedatasphere.qualitis.rule.request.multi.AddMultiSourceRuleRequest)3 MultiDataSourceConfigRequest (com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceConfigRequest)3 MultiDataSourceJoinConfigRequest (com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinConfigRequest)3 ExcelMultiTemplateRuleByProject (com.webank.wedatasphere.qualitis.project.excel.ExcelMultiTemplateRuleByProject)2 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)2 RuleGroup (com.webank.wedatasphere.qualitis.rule.entity.RuleGroup)2 Template (com.webank.wedatasphere.qualitis.rule.entity.Template)2 MultiDataSourceJoinColumnRequest (com.webank.wedatasphere.qualitis.rule.request.multi.MultiDataSourceJoinColumnRequest)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 LocalConfig (com.webank.wedatasphere.qualitis.LocalConfig)1 SpecCharEnum (com.webank.wedatasphere.qualitis.constant.SpecCharEnum)1 RuleMetricDao (com.webank.wedatasphere.qualitis.dao.RuleMetricDao)1 RuleMetricDepartmentUserDao (com.webank.wedatasphere.qualitis.dao.RuleMetricDepartmentUserDao)1