Search in sources :

Example 1 with TaskRule

use of com.webank.wedatasphere.qualitis.bean.TaskRule in project Qualitis by WeBankFinTech.

the class ExecutionManagerImpl method saveJobRuleSimpleAndJobDataSource.

/**
 * Save task rule simple and rule datasource
 * @param ruleList
 * @param task
 */
private void saveJobRuleSimpleAndJobDataSource(List<TaskRule> ruleList, Task task) {
    for (TaskRule rule : ruleList) {
        if (rule.getChildRuleId() != null) {
            // Save parent task rule simple
            TaskRuleSimple parentRuleSimple = taskRuleSimpleRepository.save(new TaskRuleSimple(rule, task, true, null));
            // Save child task rule simple
            TaskRuleSimple childRuleSimple = taskRuleSimpleRepository.save(new TaskRuleSimple(rule, task, false, parentRuleSimple));
            task.getTaskRuleSimples().add(parentRuleSimple);
        } else {
            TaskRuleSimple taskRuleSimple = taskRuleSimpleRepository.save(new TaskRuleSimple(rule, task));
            LOGGER.info("Succeed to save task_rule: task_rule_id: {}, rule_name: {}", taskRuleSimple.getId(), taskRuleSimple.getRuleName());
            task.getTaskRuleSimples().add(taskRuleSimple);
        }
        for (TaskRuleDataSource ruleDataSource : rule.getTaskRuleDataSourceList()) {
            TaskDataSource taskDataSource = taskDataSourceRepository.save(new TaskDataSource(ruleDataSource, task));
            LOGGER.info("Succeed to save task_datasource: task_datasource_id: {}, cluster: {}, database: {}, table: {}", taskDataSource.getId(), taskDataSource.getClusterName(), taskDataSource.getDatabaseName(), taskDataSource.getTableName());
            task.getTaskDataSources().add(taskDataSource);
        }
    }
}
Also used : TaskDataSource(com.webank.wedatasphere.qualitis.entity.TaskDataSource) TaskRule(com.webank.wedatasphere.qualitis.bean.TaskRule) TaskRuleDataSource(com.webank.wedatasphere.qualitis.bean.TaskRuleDataSource) TaskRuleSimple(com.webank.wedatasphere.qualitis.entity.TaskRuleSimple)

Example 2 with TaskRule

use of com.webank.wedatasphere.qualitis.bean.TaskRule in project Qualitis by WeBankFinTech.

the class ExecutionManagerImpl method saveDividedTask.

private void saveDividedTask(List<DataQualityTask> dataQualityTasks, ClusterInfo clusterInfo, List<Rule> rules, Application application, String createTime) {
    for (DataQualityTask dataQualityTask : dataQualityTasks) {
        List<TaskRule> ruleList = getRule(rules, dataQualityTask);
        Task task = new Task(application, createTime, TaskStatusEnum.SUBMITTED.getCode(), Double.parseDouble("0"), clusterInfo.getClusterName(), clusterInfo.getLinkisAddress());
        Boolean abortOnFailure = false;
        for (Rule rule : rules) {
            if (rule.getAbortOnFailure()) {
                abortOnFailure = true;
                break;
            }
        }
        task.setAbortOnFailure(abortOnFailure);
        task.setTaskProxyUser(dataQualityTask.getUser());
        Task taskInDb = taskDao.save(task);
        LOGGER.info("Succeed to save task. task_id: {}", taskInDb.getId());
        saveJobRuleSimpleAndJobDataSource(ruleList, taskInDb);
        dataQualityTask.setTaskId(taskInDb.getId());
    }
}
Also used : DataQualityTask(com.webank.wedatasphere.qualitis.bean.DataQualityTask) Task(com.webank.wedatasphere.qualitis.entity.Task) DataQualityTask(com.webank.wedatasphere.qualitis.bean.DataQualityTask) TaskRule(com.webank.wedatasphere.qualitis.bean.TaskRule) TaskRule(com.webank.wedatasphere.qualitis.bean.TaskRule) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Example 3 with TaskRule

use of com.webank.wedatasphere.qualitis.bean.TaskRule in project Qualitis by WeBankFinTech.

the class ExecutionManagerImpl method getRule.

/**
 * Get task rule
 * @param source
 * @param dataQualityTask
 * @return
 */
private List<TaskRule> getRule(List<Rule> source, DataQualityTask dataQualityTask) {
    List<TaskRule> result = new ArrayList<>();
    for (RuleTaskDetail ruleTaskDetail : dataQualityTask.getRuleTaskDetails()) {
        TaskRule taskRule = new TaskRule();
        Rule rule = source.stream().filter(r -> r.getId().equals(ruleTaskDetail.getRule().getId())).collect(Collectors.toList()).get(0);
        taskRule.setRuleId(rule.getId());
        taskRule.setRuleGroupName(rule.getRuleGroup().getRuleGroupName());
        taskRule.setRuleType(rule.getRuleType());
        taskRule.setRuleName(rule.getName());
        taskRule.setCnName(rule.getCnName());
        taskRule.setRuleDetail(rule.getDetail());
        taskRule.setTemplateName(rule.getTemplate().getName());
        taskRule.setMidTableName(ruleTaskDetail.getMidTableName());
        taskRule.setProjectId(ruleTaskDetail.getRule().getProject().getId());
        taskRule.setProjectName(ruleTaskDetail.getRule().getProject().getName());
        taskRule.setProjectCnName(ruleTaskDetail.getRule().getProject().getCnName());
        taskRule.setProjectCreator(ruleTaskDetail.getRule().getProject().getCreateUser());
        if (rule.getChildRule() != null) {
            taskRule.setChildRuleId(rule.getChildRule().getId());
            taskRule.setChildRuleType(rule.getChildRule().getRuleType());
            taskRule.setChildTaskRuleDataSourceList(getTaskRuleDataSourceBean(rule.getChildRule()));
            taskRule.setChildTaskRuleAlarmConfigsBeans(getTaskRuleAlarmConfigBean(rule.getChildRule()));
        }
        taskRule.setTaskRuleDataSourceList(getTaskRuleDataSourceBean(rule));
        taskRule.setTaskRuleAlarmConfigBeans(getTaskRuleAlarmConfigBean(rule));
        taskRule.setDeleteFailCheckResult(rule.getDeleteFailCheckResult());
        result.add(taskRule);
    }
    return result;
}
Also used : RuleTaskDetail(com.webank.wedatasphere.qualitis.bean.RuleTaskDetail) TaskRule(com.webank.wedatasphere.qualitis.bean.TaskRule) ArrayList(java.util.ArrayList) TaskRule(com.webank.wedatasphere.qualitis.bean.TaskRule) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Aggregations

TaskRule (com.webank.wedatasphere.qualitis.bean.TaskRule)3 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)2 DataQualityTask (com.webank.wedatasphere.qualitis.bean.DataQualityTask)1 RuleTaskDetail (com.webank.wedatasphere.qualitis.bean.RuleTaskDetail)1 TaskRuleDataSource (com.webank.wedatasphere.qualitis.bean.TaskRuleDataSource)1 Task (com.webank.wedatasphere.qualitis.entity.Task)1 TaskDataSource (com.webank.wedatasphere.qualitis.entity.TaskDataSource)1 TaskRuleSimple (com.webank.wedatasphere.qualitis.entity.TaskRuleSimple)1 ArrayList (java.util.ArrayList)1