Search in sources :

Example 6 with FileAlarmConfigRequest

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

the class AlarmConfigServiceImpl method checkAndSaveFileAlarmVariable.

@Override
@Transactional(rollbackFor = { RuntimeException.class, UnExpectedRequestException.class })
public List<AlarmConfig> checkAndSaveFileAlarmVariable(List<FileAlarmConfigRequest> requests, Rule rule) {
    List<AlarmConfig> alarmConfigs = new ArrayList<>();
    for (FileAlarmConfigRequest request : requests) {
        // Generate alarmConfig and save
        AlarmConfig newAlarmConfig = new AlarmConfig();
        newAlarmConfig.setFileOutputName(request.getFileOutputName());
        newAlarmConfig.setFileOutputUnit(request.getFileOutputUnit());
        newAlarmConfig.setRule(rule);
        newAlarmConfig.setCheckTemplate(request.getCheckTemplate());
        newAlarmConfig.setThreshold(request.getThreshold());
        Integer checkTemplateCode = request.getCheckTemplate();
        if (checkTemplateCode.equals(CheckTemplateEnum.FIXED_VALUE.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.FULL_YEAR_RING_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.HALF_YEAR_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.SEASON_RING_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.MONTH_RING_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.WEEK_RING_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.DAY_RING_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.HOUR_RING_GROWTH.getCode()) || checkTemplateCode.equals(CheckTemplateEnum.YEAR_ON_YEAR.getCode())) {
            newAlarmConfig.setCompareType(request.getCompareType());
        }
        if (StringUtils.isNotBlank(request.getRuleMetricEnCode())) {
            RuleMetric ruleMetric = ruleMetricDao.findByEnCode(request.getRuleMetricEnCode());
            newAlarmConfig.setRuleMetric(ruleMetric);
        }
        newAlarmConfig.setUploadAbnormalValue(request.getUploadAbnormalValue());
        newAlarmConfig.setUploadRuleMetricValue(request.getUploadRuleMetricValue());
        newAlarmConfig.setDeleteFailCheckResult(request.getDeleteFailCheckResult());
        alarmConfigs.add(newAlarmConfig);
    }
    return alarmConfigDao.saveAllAlarmConfig(alarmConfigs);
}
Also used : RuleMetric(com.webank.wedatasphere.qualitis.entity.RuleMetric) ArrayList(java.util.ArrayList) FileAlarmConfigRequest(com.webank.wedatasphere.qualitis.rule.request.FileAlarmConfigRequest) AlarmConfig(com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

FileAlarmConfigRequest (com.webank.wedatasphere.qualitis.rule.request.FileAlarmConfigRequest)6 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)3 ArrayList (java.util.ArrayList)3 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)2 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)2 AddFileRuleRequest (com.webank.wedatasphere.qualitis.rule.request.AddFileRuleRequest)2 DataSourceRequest (com.webank.wedatasphere.qualitis.rule.request.DataSourceRequest)2 ExcelTemplateFileRuleByProject (com.webank.wedatasphere.qualitis.project.excel.ExcelTemplateFileRuleByProject)1 RuleDataSource (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource)1 RuleGroup (com.webank.wedatasphere.qualitis.rule.entity.RuleGroup)1 Transactional (org.springframework.transaction.annotation.Transactional)1