Search in sources :

Example 1 with ModifyCustomRuleRequest

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

the class RuleBatchServiceImpl method addCustomRule.

private void addCustomRule(Map<String, List<ExcelCustomRuleByProject>> customRulePartitionedByRuleName, Project project, String userName, boolean aomp) throws UnExpectedRequestException, SemanticException, ParseException, TaskNotExistException, ClusterInfoNotConfigException, MetaDataAcquireFailedException, PermissionDeniedRequestException {
    Map<String, List<ExcelCustomRuleByProject>> modifyRulePartitionedByRuleName = new HashMap<>(1);
    Map<String, List<ExcelCustomRuleByProject>> addRulePartitionedByRuleName = new HashMap<>(1);
    String localeStr = httpServletRequest.getHeader("Content-Language");
    for (Iterator<String> iterator = customRulePartitionedByRuleName.keySet().iterator(); iterator.hasNext(); ) {
        String currentRuleName = iterator.next();
        Rule currentRule = ruleDao.findByProjectAndRuleName(project, currentRuleName);
        if (currentRule != null) {
            modifyRulePartitionedByRuleName.put(currentRuleName, customRulePartitionedByRuleName.get(currentRuleName));
            List<AddCustomRuleRequest> addRuleRequestList = constructAddCustomRuleRequest(modifyRulePartitionedByRuleName, project, localeStr);
            ModifyCustomRuleRequest modifyRuleRequest = new ModifyCustomRuleRequest();
            modifyRuleRequest.setRuleId(currentRule.getId());
            AddCustomRuleRequest addRuleRequest = addRuleRequestList.iterator().next();
            BeanUtils.copyProperties(addRuleRequest, modifyRuleRequest);
            LOGGER.info("Start to modify custom rule. request: {}", modifyRuleRequest);
            if (aomp) {
                customRuleService.modifyRuleDetailForOuter(modifyRuleRequest, userName);
            } else {
                customRuleService.modifyCustomRule(modifyRuleRequest);
            }
            LOGGER.info("Succeed to modify custom rule");
            modifyRulePartitionedByRuleName.clear();
        } else {
            addRulePartitionedByRuleName.put(currentRuleName, customRulePartitionedByRuleName.get(currentRuleName));
            List<AddCustomRuleRequest> addRuleRequestList = constructAddCustomRuleRequest(addRulePartitionedByRuleName, project, localeStr);
            AddCustomRuleRequest currentAddCustomRuleRequest = addRuleRequestList.iterator().next();
            LOGGER.info("Start to add custom rule. request: {}", currentAddCustomRuleRequest);
            if (aomp) {
                customRuleService.addRuleForOuter(currentAddCustomRuleRequest, userName);
            } else {
                customRuleService.addCustomRuleForUpload(currentAddCustomRuleRequest);
            }
            LOGGER.info("Succeed to add custom rule");
            addRulePartitionedByRuleName.clear();
        }
    }
}
Also used : AddCustomRuleRequest(com.webank.wedatasphere.qualitis.rule.request.AddCustomRuleRequest) HashMap(java.util.HashMap) ModifyCustomRuleRequest(com.webank.wedatasphere.qualitis.rule.request.ModifyCustomRuleRequest) 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 AddCustomRuleRequest (com.webank.wedatasphere.qualitis.rule.request.AddCustomRuleRequest)1 ModifyCustomRuleRequest (com.webank.wedatasphere.qualitis.rule.request.ModifyCustomRuleRequest)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1