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 2 months 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. 44
      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) {
throw new ServiceException(Status.PROJECT_NOT_FOUND, projectCode);
}
List<DependentLineageTask> dependentLineageTaskList = new ArrayList<>();
List<WorkflowTaskLineage> workflowTaskLineageList =
workflowTaskLineageDao.queryWorkFlowLineageByDept(projectCode,
workflowDefinitionCode, taskCode == null ? 0 : taskCode);
if (workflowTaskLineageList.isEmpty()) {
return dependentLineageTaskList;
}
List<WorkflowDefinition> workflowDefinitionList =
workflowDefinitionMapper.queryByCodes(workflowTaskLineageList.stream()
.map(WorkflowTaskLineage::getWorkflowDefinitionCode).distinct().collect(Collectors.toList()));
List<TaskDefinition> taskDefinitionList = taskDefinitionMapper.queryByCodeList(workflowTaskLineageList.stream()
.map(WorkflowTaskLineage::getTaskDefinitionCode).filter(code -> code != 0).distinct()
.collect(Collectors.toList()));
List<DependentLineageTask> dependentLineageTaskList = new ArrayList<>();
for (WorkflowTaskLineage workflowTaskLineage : workflowTaskLineageList) {
DependentLineageTask dependentLineageTask = new DependentLineageTask();
taskDefinitionList.stream()

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

@ -30,15 +30,22 @@ export function useDependencies() {
workFlowCode: workflowCode,
taskCode: taskCode
} as DependentTaskReq
const res = await queryDependentTasks(projectCode, dependentTaskReq)
res
.filter((item: any) => item.workflowDefinitionCode !== workflowCode)
await queryDependentTasks(projectCode, dependentTaskReq).then(
(res: any) => {
if (res?.data?.length > 0) {
res.data
.filter(
(item: any) => item.workflowDefinitionCode !== workflowCode
)
.forEach((item: any) => {
tasks.push(
item.workflowDefinitionName + '->' + item.taskDefinitionName
)
})
}
}
)
}
return tasks
}
@ -51,15 +58,22 @@ export function useDependencies() {
const dependentTaskReq = {
workFlowCode: workflowCode
} as DependentTaskReq
const res = await queryDependentTasks(projectCode, dependentTaskReq)
res
.filter((item: any) => item.workflowDefinitionCode !== workflowCode)
await queryDependentTasks(projectCode, dependentTaskReq).then(
(res: any) => {
if (res?.data?.length > 0) {
res.data
.filter(
(item: any) => item.workflowDefinitionCode !== workflowCode
)
.forEach((item: any) => {
tasks.push(
item.workflowDefinitionName + '->' + item.taskDefinitionName
)
})
}
}
)
}
return tasks
}
@ -110,6 +124,7 @@ export function useDependencies() {
if (workflowCode && projectCode) {
await queryDependentTasks(projectCode, dependentTaskReq).then(
(res: any) => {
if (res?.data?.length > 0) {
res.data
.filter((item: any) => {
if (item.workflowDefinitionCode) {
@ -121,7 +136,9 @@ export function useDependencies() {
.forEach((item: any) => {
dependentTaskLinks.push({
text:
item.workflowDefinitionName + '->' + item.taskDefinitionName,
item.workflowDefinitionName +
'->' +
item.taskDefinitionName,
show: true,
action: () => {
const url = `/projects/${item.projectCode}/workflow/definitions/${item.workflowDefinitionCode}`
@ -130,6 +147,7 @@ export function useDependencies() {
})
})
}
}
)
}
return dependentTaskLinks
@ -148,12 +166,17 @@ export function useDependencies() {
if (workflowCode && projectCode) {
await queryDependentTasks(projectCode, dependentTaskReq).then(
(res: any) => {
res
.filter((item: any) => item.workflowDefinitionCode !== workflowCode)
if (res?.data?.length > 0) {
res.data
.filter(
(item: any) => item.workflowDefinitionCode !== workflowCode
)
.forEach((item: any) => {
dependentTaskLinks.push({
text:
item.workflowDefinitionName + '->' + item.taskDefinitionName,
item.workflowDefinitionName +
'->' +
item.taskDefinitionName,
show: true,
action: () => {
const url = `/projects/${item.projectCode}/workflow/definitions/${item.workflowDefinitionCode}`
@ -162,6 +185,7 @@ export function useDependencies() {
})
})
}
}
)
}
return dependentTaskLinks

Loading…
Cancel
Save