Search in sources :

Example 1 with ModifyRuleRequest

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();
        }
    }
}
Also used : AddRuleRequest(com.webank.wedatasphere.qualitis.rule.request.AddRuleRequest) HashMap(java.util.HashMap) ModifyRuleRequest(com.webank.wedatasphere.qualitis.rule.request.ModifyRuleRequest) 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 AddRuleRequest (com.webank.wedatasphere.qualitis.rule.request.AddRuleRequest)1 ModifyRuleRequest (com.webank.wedatasphere.qualitis.rule.request.ModifyRuleRequest)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1