use of com.webank.wedatasphere.qualitis.rule.request.ModifyRuleRequest in project Qualitis by WeBankFinTech.
the class RuleBatchServiceImpl method addTemplateRule.
private void addTemplateRule(Map<String, List<ExcelTemplateRuleByProject>> rulePartitionedByRuleName, Project project, String userName, boolean aomp) throws UnExpectedRequestException, TaskNotExistException, ClusterInfoNotConfigException, PermissionDeniedRequestException {
Map<String, List<ExcelTemplateRuleByProject>> modifyRulePartitionedByRuleName = new HashMap<>(1);
Map<String, List<ExcelTemplateRuleByProject>> addRulePartitionedByRuleName = new HashMap<>(1);
String localeStr = httpServletRequest.getHeader("Content-Language");
for (Iterator<String> iterator = rulePartitionedByRuleName.keySet().iterator(); iterator.hasNext(); ) {
String currentRuleName = iterator.next();
Rule currentRule = ruleDao.findByProjectAndRuleName(project, currentRuleName);
if (currentRule != null) {
modifyRulePartitionedByRuleName.put(currentRuleName, rulePartitionedByRuleName.get(currentRuleName));
List<AddRuleRequest> addRuleRequestList = constructAddRuleRequest(modifyRulePartitionedByRuleName, project, localeStr);
ModifyRuleRequest modifyRuleRequest = new ModifyRuleRequest();
modifyRuleRequest.setRuleId(currentRule.getId());
AddRuleRequest addRuleRequest = addRuleRequestList.iterator().next();
BeanUtils.copyProperties(addRuleRequest, modifyRuleRequest);
LOGGER.info("Start to modify template rule. request: {}", modifyRuleRequest);
if (aomp) {
ruleService.modifyRuleDetailForOuter(modifyRuleRequest, userName);
} else {
ruleService.modifyRuleDetail(modifyRuleRequest);
}
LOGGER.info("Succeed to modify template rule.");
modifyRulePartitionedByRuleName.clear();
} else {
addRulePartitionedByRuleName.put(currentRuleName, rulePartitionedByRuleName.get(currentRuleName));
List<AddRuleRequest> addRuleRequestList = constructAddRuleRequest(addRulePartitionedByRuleName, project, localeStr);
AddRuleRequest currentAddRuleRequest = addRuleRequestList.iterator().next();
LOGGER.info("Start to add template rule. request: {}", currentAddRuleRequest);
if (aomp) {
ruleService.addRuleForOuter(currentAddRuleRequest, userName);
} else {
ruleService.addRuleForUpload(currentAddRuleRequest);
}
LOGGER.info("Succeed to add template rule.");
addRulePartitionedByRuleName.clear();
}
}
}
Aggregations