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