use of com.webank.wedatasphere.qualitis.project.excel.ExcelMultiTemplateRuleByProject in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method getMappingInfoAndAlarm.
private void getMappingInfoAndAlarm(Set<RuleDataSourceMapping> ruleDataSourceMappings, Set<AlarmConfig> alarmConfigs, List<ExcelMultiTemplateRuleByProject> lines, ExcelMultiTemplateRuleByProject ruleLinePrefix, String localeStr) {
for (RuleDataSourceMapping mapping : ruleDataSourceMappings) {
ExcelMultiTemplateRuleByProject tmp = new ExcelMultiTemplateRuleByProject(ruleLinePrefix.getRuleName());
tmp.setLeftMappingStatement(mapping.getLeftStatement());
tmp.setLeftMappingNames(mapping.getLeftColumnNames());
tmp.setLeftMappingTypes(mapping.getLeftColumnTypes());
tmp.setMappingOperation(MappingOperationEnum.getByCode(mapping.getOperation()).getSymbol());
tmp.setRightMappingStatement(mapping.getRightStatement());
tmp.setRightMappingNames(mapping.getRightColumnNames());
tmp.setRightMappingTypes(mapping.getRightColumnTypes());
LOGGER.info("Collect excel line: {}", tmp);
lines.add(tmp);
}
for (AlarmConfig alarmConfig : alarmConfigs) {
Double threshold = alarmConfig.getThreshold();
String alarmOutputName = alarmConfig.getTemplateOutputMeta().getOutputName();
String alarmCompareType = CompareTypeEnum.getCompareTypeName(alarmConfig.getCompareType());
String checkTemplateName = CheckTemplateEnum.getCheckTemplateName(alarmConfig.getCheckTemplate(), localeStr);
ExcelMultiTemplateRuleByProject tmp = new ExcelMultiTemplateRuleByProject(ruleLinePrefix.getRuleName());
tmp.setCompareType(alarmCompareType);
tmp.setAlarmCheckName(alarmOutputName);
tmp.setCheckTemplateName(checkTemplateName);
tmp.setThreshold(String.valueOf(threshold));
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());
LOGGER.info("Collect excel line: {}", tmp);
lines.add(tmp);
}
}
use of com.webank.wedatasphere.qualitis.project.excel.ExcelMultiTemplateRuleByProject in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method constructAddMultiSourceRuleRequest.
private List<AddMultiSourceRuleRequest> constructAddMultiSourceRuleRequest(Map<String, List<ExcelMultiTemplateRuleByProject>> multiRulePartitionedByRuleName, Project project, String localeStr) throws UnExpectedRequestException {
List<AddMultiSourceRuleRequest> addMultiSourceRuleRequests = new ArrayList<>();
for (String ruleName : multiRulePartitionedByRuleName.keySet()) {
List<ExcelMultiTemplateRuleByProject> ruleInfos = multiRulePartitionedByRuleName.get(ruleName);
ExcelMultiTemplateRuleByProject firstCommonInfo = ruleInfos.get(0);
AddMultiSourceRuleRequest addMultiSourceRuleRequest = new AddMultiSourceRuleRequest();
String ruleTemplateName = firstCommonInfo.getTemplateName();
String ruleGroupName = firstCommonInfo.getRuleGroupName();
addMultiSourceRuleRequest.setSpecifyStaticStartupParam(firstCommonInfo.getSpecifyStaticStartupParam());
addMultiSourceRuleRequest.setDeleteFailCheckResult(firstCommonInfo.getDeleteFailCheckResult());
addMultiSourceRuleRequest.setStaticStartupParam(firstCommonInfo.getStaticStartupParam());
addMultiSourceRuleRequest.setAbortOnFailure(firstCommonInfo.getAbortOnFailure());
if (StringUtils.isBlank(ruleGroupName)) {
throw new UnExpectedRequestException("RuleGroupName {&CAN_NOT_BE_NULL_OR_EMPTY}");
}
Template template = findTemplateByName(ruleTemplateName);
if (template == null) {
throw new UnExpectedRequestException("{&TEMPLATE_NAME}: [" + ruleTemplateName + "] {&DOES_NOT_EXIST}");
}
String filter = null;
boolean alarm = false;
String clusterName = firstCommonInfo.getClusterName();
MultiDataSourceConfigRequest sourceConfigRequest = new MultiDataSourceConfigRequest();
MultiDataSourceConfigRequest targetConfigRequest = new MultiDataSourceConfigRequest();
List<MultiDataSourceJoinConfigRequest> mappings = new ArrayList<>();
List<AlarmConfigRequest> alarmConfigRequests = new ArrayList<>();
for (ExcelMultiTemplateRuleByProject excelMultiTemplateRule : ruleInfos) {
if (StringUtils.isNotBlank(excelMultiTemplateRule.getWhereFilter())) {
filter = excelMultiTemplateRule.getWhereFilter();
}
getAlarmConfig(alarmConfigRequests, excelMultiTemplateRule, template, localeStr);
getMultiDataSourceRequest(sourceConfigRequest, excelMultiTemplateRule, 0);
getMultiDataSourceRequest(targetConfigRequest, excelMultiTemplateRule, 1);
getMultiDataSourceJoinRequest(mappings, excelMultiTemplateRule);
}
if (alarmConfigRequests.size() != 0) {
alarm = true;
}
RuleGroup ruleGroupInDb = ruleGroupDao.findByRuleGroupNameAndProjectId(ruleGroupName, project.getId());
if (ruleGroupInDb != null) {
addMultiSourceRuleRequest.setRuleGroupId(ruleGroupInDb.getId());
} else {
RuleGroup ruleGroup = ruleGroupDao.saveRuleGroup(new RuleGroup(ruleGroupName, project.getId()));
addMultiSourceRuleRequest.setRuleGroupId(ruleGroup.getId());
}
addMultiSourceRuleRequest.setRuleName(ruleName);
addMultiSourceRuleRequest.setClusterName(clusterName);
addMultiSourceRuleRequest.setProjectId(project.getId());
addMultiSourceRuleRequest.setRuleDetail(firstCommonInfo.getRuleDetail());
addMultiSourceRuleRequest.setMultiSourceRuleTemplateId(template.getId());
addMultiSourceRuleRequest.setAlarmVariable(alarmConfigRequests);
addMultiSourceRuleRequests.add(addMultiSourceRuleRequest);
addMultiSourceRuleRequest.setSource(sourceConfigRequest);
addMultiSourceRuleRequest.setTarget(targetConfigRequest);
addMultiSourceRuleRequest.setMappings(mappings);
addMultiSourceRuleRequest.setFilter(filter);
addMultiSourceRuleRequest.setAlarm(alarm);
}
return addMultiSourceRuleRequests;
}
use of com.webank.wedatasphere.qualitis.project.excel.ExcelMultiTemplateRuleByProject 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);
}
}
}
Aggregations