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);
}
}
}
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());
}
}
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;
}
Aggregations