Search in sources :

Example 1 with ModifyFileRuleRequest

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();
        }
    }
}
Also used : AddFileRuleRequest(com.webank.wedatasphere.qualitis.rule.request.AddFileRuleRequest) HashMap(java.util.HashMap) ModifyFileRuleRequest(com.webank.wedatasphere.qualitis.rule.request.ModifyFileRuleRequest) ArrayList(java.util.ArrayList) List(java.util.List) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Aggregations

Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)1 AddFileRuleRequest (com.webank.wedatasphere.qualitis.rule.request.AddFileRuleRequest)1 ModifyFileRuleRequest (com.webank.wedatasphere.qualitis.rule.request.ModifyFileRuleRequest)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1