Search in sources :

Example 1 with ModifyMultiSourceRequest

use of com.webank.wedatasphere.qualitis.rule.request.multi.ModifyMultiSourceRequest in project Qualitis by WeBankFinTech.

the class RuleBatchServiceImpl method addMultiTemplateRule.

private void addMultiTemplateRule(Map<String, List<ExcelMultiTemplateRuleByProject>> multiRulePartitionedByRuleName, Project project, String userName, boolean aomp) throws UnExpectedRequestException, ClusterInfoNotConfigException, TaskNotExistException, PermissionDeniedRequestException {
    Map<String, List<ExcelMultiTemplateRuleByProject>> modifyRulePartitionedByRuleName = new HashMap<>(1);
    Map<String, List<ExcelMultiTemplateRuleByProject>> addRulePartitionedByRuleName = new HashMap<>(1);
    String localeStr = httpServletRequest.getHeader("Content-Language");
    for (Iterator<String> iterator = multiRulePartitionedByRuleName.keySet().iterator(); iterator.hasNext(); ) {
        String currentRuleName = iterator.next();
        Rule currentRule = ruleDao.findByProjectAndRuleName(project, currentRuleName);
        if (currentRule != null) {
            modifyRulePartitionedByRuleName.put(currentRuleName, multiRulePartitionedByRuleName.get(currentRuleName));
            List<AddMultiSourceRuleRequest> addRuleRequestList = constructAddMultiSourceRuleRequest(modifyRulePartitionedByRuleName, project, localeStr);
            ModifyMultiSourceRequest modifyRuleRequest = new ModifyMultiSourceRequest();
            modifyRuleRequest.setRuleId(currentRule.getId());
            AddMultiSourceRuleRequest addRuleRequest = addRuleRequestList.iterator().next();
            BeanUtils.copyProperties(addRuleRequest, modifyRuleRequest);
            LOGGER.info("Start to modify multi rule. request: {}", modifyRuleRequest);
            if (aomp) {
                multiSourceRuleService.modifyRuleDetailForOuter(modifyRuleRequest, userName);
            } else {
                multiSourceRuleService.modifyMultiSourceRule(modifyRuleRequest);
            }
            LOGGER.info("Success to modify multi rule.");
            modifyRulePartitionedByRuleName.clear();
        } else {
            addRulePartitionedByRuleName.put(currentRuleName, multiRulePartitionedByRuleName.get(currentRuleName));
            List<AddMultiSourceRuleRequest> addRuleRequestList = constructAddMultiSourceRuleRequest(addRulePartitionedByRuleName, project, localeStr);
            AddMultiSourceRuleRequest currentAddMultiSourceRuleRequest = addRuleRequestList.iterator().next();
            LOGGER.info("Start to add multi rule. request: {}", currentAddMultiSourceRuleRequest);
            if (aomp) {
                currentAddMultiSourceRuleRequest.setLoginUser(userName);
                multiSourceRuleService.addRuleForOuter(currentAddMultiSourceRuleRequest, true);
            } else {
                multiSourceRuleService.addMultiSourceRuleForUpload(currentAddMultiSourceRuleRequest, true);
            }
            LOGGER.info("Success to add multi rule.");
            addRulePartitionedByRuleName.clear();
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) ModifyMultiSourceRequest(com.webank.wedatasphere.qualitis.rule.request.multi.ModifyMultiSourceRequest) AddMultiSourceRuleRequest(com.webank.wedatasphere.qualitis.rule.request.multi.AddMultiSourceRuleRequest)

Aggregations

Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)1 AddMultiSourceRuleRequest (com.webank.wedatasphere.qualitis.rule.request.multi.AddMultiSourceRuleRequest)1 ModifyMultiSourceRequest (com.webank.wedatasphere.qualitis.rule.request.multi.ModifyMultiSourceRequest)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1