Browse Source

[Fix-16567] Unable to delete copied nodes in unsaved workflow (#16576)

1. Fix the handling logic for when the backend API returns an empty array
2. If the dependent Lineage Task List is empty, no further query is required
dev
xxt 1 month ago committed by GitHub
parent
commit
f56a311849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowLineageServiceImpl.java
  2. 114
      dolphinscheduler-ui/src/views/projects/components/dependencies/use-dependencies.ts

5
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowLineageServiceImpl.java

@ -260,16 +260,19 @@ public class WorkflowLineageServiceImpl extends BaseServiceImpl implements Workf
if (project == null) { if (project == null) {
throw new ServiceException(Status.PROJECT_NOT_FOUND, projectCode); throw new ServiceException(Status.PROJECT_NOT_FOUND, projectCode);
} }
List<DependentLineageTask> dependentLineageTaskList = new ArrayList<>();
List<WorkflowTaskLineage> workflowTaskLineageList = List<WorkflowTaskLineage> workflowTaskLineageList =
workflowTaskLineageDao.queryWorkFlowLineageByDept(projectCode, workflowTaskLineageDao.queryWorkFlowLineageByDept(projectCode,
workflowDefinitionCode, taskCode == null ? 0 : taskCode); workflowDefinitionCode, taskCode == null ? 0 : taskCode);
if (workflowTaskLineageList.isEmpty()) {
return dependentLineageTaskList;
}
List<WorkflowDefinition> workflowDefinitionList = List<WorkflowDefinition> workflowDefinitionList =
workflowDefinitionMapper.queryByCodes(workflowTaskLineageList.stream() workflowDefinitionMapper.queryByCodes(workflowTaskLineageList.stream()
.map(WorkflowTaskLineage::getWorkflowDefinitionCode).distinct().collect(Collectors.toList())); .map(WorkflowTaskLineage::getWorkflowDefinitionCode).distinct().collect(Collectors.toList()));
List<TaskDefinition> taskDefinitionList = taskDefinitionMapper.queryByCodeList(workflowTaskLineageList.stream() List<TaskDefinition> taskDefinitionList = taskDefinitionMapper.queryByCodeList(workflowTaskLineageList.stream()
.map(WorkflowTaskLineage::getTaskDefinitionCode).filter(code -> code != 0).distinct() .map(WorkflowTaskLineage::getTaskDefinitionCode).filter(code -> code != 0).distinct()
.collect(Collectors.toList())); .collect(Collectors.toList()));
List<DependentLineageTask> dependentLineageTaskList = new ArrayList<>();
for (WorkflowTaskLineage workflowTaskLineage : workflowTaskLineageList) { for (WorkflowTaskLineage workflowTaskLineage : workflowTaskLineageList) {
DependentLineageTask dependentLineageTask = new DependentLineageTask(); DependentLineageTask dependentLineageTask = new DependentLineageTask();
taskDefinitionList.stream() taskDefinitionList.stream()

114
dolphinscheduler-ui/src/views/projects/components/dependencies/use-dependencies.ts

@ -30,14 +30,21 @@ export function useDependencies() {
workFlowCode: workflowCode, workFlowCode: workflowCode,
taskCode: taskCode taskCode: taskCode
} as DependentTaskReq } as DependentTaskReq
const res = await queryDependentTasks(projectCode, dependentTaskReq) await queryDependentTasks(projectCode, dependentTaskReq).then(
res (res: any) => {
.filter((item: any) => item.workflowDefinitionCode !== workflowCode) if (res?.data?.length > 0) {
.forEach((item: any) => { res.data
tasks.push( .filter(
item.workflowDefinitionName + '->' + item.taskDefinitionName (item: any) => item.workflowDefinitionCode !== workflowCode
) )
}) .forEach((item: any) => {
tasks.push(
item.workflowDefinitionName + '->' + item.taskDefinitionName
)
})
}
}
)
} }
return tasks return tasks
} }
@ -51,14 +58,21 @@ export function useDependencies() {
const dependentTaskReq = { const dependentTaskReq = {
workFlowCode: workflowCode workFlowCode: workflowCode
} as DependentTaskReq } as DependentTaskReq
const res = await queryDependentTasks(projectCode, dependentTaskReq) await queryDependentTasks(projectCode, dependentTaskReq).then(
res (res: any) => {
.filter((item: any) => item.workflowDefinitionCode !== workflowCode) if (res?.data?.length > 0) {
.forEach((item: any) => { res.data
tasks.push( .filter(
item.workflowDefinitionName + '->' + item.taskDefinitionName (item: any) => item.workflowDefinitionCode !== workflowCode
) )
}) .forEach((item: any) => {
tasks.push(
item.workflowDefinitionName + '->' + item.taskDefinitionName
)
})
}
}
)
} }
return tasks return tasks
} }
@ -110,25 +124,29 @@ export function useDependencies() {
if (workflowCode && projectCode) { if (workflowCode && projectCode) {
await queryDependentTasks(projectCode, dependentTaskReq).then( await queryDependentTasks(projectCode, dependentTaskReq).then(
(res: any) => { (res: any) => {
res.data if (res?.data?.length > 0) {
.filter((item: any) => { res.data
if (item.workflowDefinitionCode) { .filter((item: any) => {
return item.workflowDefinitionCode !== workflowCode if (item.workflowDefinitionCode) {
} else { return item.workflowDefinitionCode !== workflowCode
return false } else {
} return false
})
.forEach((item: any) => {
dependentTaskLinks.push({
text:
item.workflowDefinitionName + '->' + item.taskDefinitionName,
show: true,
action: () => {
const url = `/projects/${item.projectCode}/workflow/definitions/${item.workflowDefinitionCode}`
window.open(url, '_blank')
} }
}) })
}) .forEach((item: any) => {
dependentTaskLinks.push({
text:
item.workflowDefinitionName +
'->' +
item.taskDefinitionName,
show: true,
action: () => {
const url = `/projects/${item.projectCode}/workflow/definitions/${item.workflowDefinitionCode}`
window.open(url, '_blank')
}
})
})
}
} }
) )
} }
@ -148,19 +166,25 @@ export function useDependencies() {
if (workflowCode && projectCode) { if (workflowCode && projectCode) {
await queryDependentTasks(projectCode, dependentTaskReq).then( await queryDependentTasks(projectCode, dependentTaskReq).then(
(res: any) => { (res: any) => {
res if (res?.data?.length > 0) {
.filter((item: any) => item.workflowDefinitionCode !== workflowCode) res.data
.forEach((item: any) => { .filter(
dependentTaskLinks.push({ (item: any) => item.workflowDefinitionCode !== workflowCode
text: )
item.workflowDefinitionName + '->' + item.taskDefinitionName, .forEach((item: any) => {
show: true, dependentTaskLinks.push({
action: () => { text:
const url = `/projects/${item.projectCode}/workflow/definitions/${item.workflowDefinitionCode}` item.workflowDefinitionName +
window.open(url, '_blank') '->' +
} item.taskDefinitionName,
show: true,
action: () => {
const url = `/projects/${item.projectCode}/workflow/definitions/${item.workflowDefinitionCode}`
window.open(url, '_blank')
}
})
}) })
}) }
} }
) )
} }

Loading…
Cancel
Save