use of com.webank.wedatasphere.qualitis.rule.request.ModifyCustomRuleRequest in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method addCustomRule.
private void addCustomRule(Map<String, List<ExcelCustomRuleByProject>> customRulePartitionedByRuleName, Project project, String userName, boolean aomp) throws UnExpectedRequestException, SemanticException, ParseException, TaskNotExistException, ClusterInfoNotConfigException, MetaDataAcquireFailedException, PermissionDeniedRequestException {
Map<String, List<ExcelCustomRuleByProject>> modifyRulePartitionedByRuleName = new HashMap<>(1);
Map<String, List<ExcelCustomRuleByProject>> addRulePartitionedByRuleName = new HashMap<>(1);
String localeStr = httpServletRequest.getHeader("Content-Language");
for (Iterator<String> iterator = customRulePartitionedByRuleName.keySet().iterator(); iterator.hasNext(); ) {
String currentRuleName = iterator.next();
Rule currentRule = ruleDao.findByProjectAndRuleName(project, currentRuleName);
if (currentRule != null) {
modifyRulePartitionedByRuleName.put(currentRuleName, customRulePartitionedByRuleName.get(currentRuleName));
List<AddCustomRuleRequest> addRuleRequestList = constructAddCustomRuleRequest(modifyRulePartitionedByRuleName, project, localeStr);
ModifyCustomRuleRequest modifyRuleRequest = new ModifyCustomRuleRequest();
modifyRuleRequest.setRuleId(currentRule.getId());
AddCustomRuleRequest addRuleRequest = addRuleRequestList.iterator().next();
BeanUtils.copyProperties(addRuleRequest, modifyRuleRequest);
LOGGER.info("Start to modify custom rule. request: {}", modifyRuleRequest);
if (aomp) {
customRuleService.modifyRuleDetailForOuter(modifyRuleRequest, userName);
} else {
customRuleService.modifyCustomRule(modifyRuleRequest);
}
LOGGER.info("Succeed to modify custom rule");
modifyRulePartitionedByRuleName.clear();
} else {
addRulePartitionedByRuleName.put(currentRuleName, customRulePartitionedByRuleName.get(currentRuleName));
List<AddCustomRuleRequest> addRuleRequestList = constructAddCustomRuleRequest(addRulePartitionedByRuleName, project, localeStr);
AddCustomRuleRequest currentAddCustomRuleRequest = addRuleRequestList.iterator().next();
LOGGER.info("Start to add custom rule. request: {}", currentAddCustomRuleRequest);
if (aomp) {
customRuleService.addRuleForOuter(currentAddCustomRuleRequest, userName);
} else {
customRuleService.addCustomRuleForUpload(currentAddCustomRuleRequest);
}
LOGGER.info("Succeed to add custom rule");
addRulePartitionedByRuleName.clear();
}
}
}
Aggregations