From 03dcb0671cdf95108c11948fef88e6b3aac1c96b Mon Sep 17 00:00:00 2001 From: liwenxin Date: Tue, 24 Dec 2024 10:22:24 +0800 Subject: [PATCH 1/5] [fix-16900][api] fix when the copied workflow, the logical node switch loses the flow relationship --- .../impl/WorkflowDefinitionServiceImpl.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java index 2bae5e12b97f..c961be76dea1 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java @@ -115,8 +115,10 @@ import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; import org.apache.dolphinscheduler.plugin.task.api.model.Property; +import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters; +import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters; import org.apache.dolphinscheduler.plugin.task.api.utils.TaskTypeUtils; import org.apache.dolphinscheduler.service.model.TaskNode; import org.apache.dolphinscheduler.service.process.ProcessService; @@ -2122,6 +2124,25 @@ protected void doBatchOperateWorkflowDefinition(User loginUser, long taskCode = CodeGenerateUtils.genCode(); taskCodeMap.put(taskDefinitionLog.getCode(), taskCode); taskDefinitionLog.setCode(taskCode); + if (TaskTypeUtils.isSwitchTask(taskDefinitionLog.getTaskType())){ + final String taskParams = taskDefinitionLog.getTaskParams(); + final SwitchParameters switchParameters = JSONUtils.parseObject(taskParams, SwitchParameters.class); + if (switchParameters == null) { + throw new IllegalArgumentException("Switch task params: " + taskParams + " is invalid."); + } + SwitchParameters.SwitchResult switchResult = switchParameters.getSwitchResult(); + List dependTaskList = switchResult.getDependTaskList(); + dependTaskList.forEach(switchResultVo -> { + switchResultVo.setNextNode(taskCodeMap.get(switchResultVo.getNextNode())); + }); + switchResult.setDependTaskList(dependTaskList); + if (switchResult.getNextNode() != null) { + switchResult.setNextNode( + taskCodeMap.get(switchResult.getNextNode()) + ); + } + taskDefinitionLog.setTaskParams(JSONUtils.toJsonString(switchParameters)); + } } catch (CodeGenerateException e) { log.error("Generate task definition code error, projectCode:{}.", targetProjectCode, e); putMsg(result, Status.INTERNAL_SERVER_ERROR_ARGS); From cc8caea9815908d8864e34688c6d761fa3f70018 Mon Sep 17 00:00:00 2001 From: liwenxin Date: Wed, 25 Dec 2024 07:29:51 +0800 Subject: [PATCH 2/5] add unit test --- .../WorkflowDefinitionServiceTest.java | 96 +++++++++++++++++-- 1 file changed, 86 insertions(+), 10 deletions(-) diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java index 5fc60f9561b6..10b4b9e69a99 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java @@ -50,16 +50,7 @@ import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.dao.entity.DagData; -import org.apache.dolphinscheduler.dao.entity.DataSource; -import org.apache.dolphinscheduler.dao.entity.Project; -import org.apache.dolphinscheduler.dao.entity.Schedule; -import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; -import org.apache.dolphinscheduler.dao.entity.TaskMainInfo; -import org.apache.dolphinscheduler.dao.entity.User; -import org.apache.dolphinscheduler.dao.entity.UserWithWorkflowDefinitionCode; -import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition; -import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelation; +import org.apache.dolphinscheduler.dao.entity.*; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; @@ -207,6 +198,76 @@ public void before() { user = loginUser; } + @Test() + public void testCopyworkflowLogicalNodeSwitch() { + long projectCode = 128645169571296L; + String codes = "128645230604768"; + long targetProjectCode = 128645169571296L; + long shellTaskDefinitionCode = 128645175846368L; + long switchTaskDefinitionCode = 128645191546336L; + + Map result = new HashMap<>(); + putMsg(result, Status.SUCCESS); + + Set definitionCodes = new HashSet<>(); + for (String code : String.valueOf(codes).split(Constants.COMMA)) { + try { + long parse = Long.parseLong(code); + definitionCodes.add(parse); + } catch (NumberFormatException e) { + Assertions.fail(); + } + } + + WorkflowDefinition workflowDefinition = new WorkflowDefinition(); + workflowDefinition.setId(1); + workflowDefinition.setCode(Long.parseLong(codes)); + workflowDefinition.setName("workflow_switch"); + workflowDefinition.setDescription(""); + workflowDefinition.setVersion(1); + workflowDefinition.setReleaseState(ReleaseState.OFFLINE); + workflowDefinition.setProjectCode(projectCode); + workflowDefinition.setUserId(user.getId()); + List workflowDefinitionList = new ArrayList<>(); + workflowDefinitionList.add(workflowDefinition); + + Project project = new Project(); + project.setCode(projectCode); + project.setId(1); + project.setName("project_switch"); + project.setUserId(user.getId()); + + List workflowTaskRelations = new ArrayList<>(); + WorkflowTaskRelation workflowTaskRelationShell = getWorkflowTaskRelation + (1, 1, projectCode, workflowDefinition.getCode(), 0L, 1, switchTaskDefinitionCode, 1); + WorkflowTaskRelation workflowTaskRelationSwitch = getWorkflowTaskRelation + (2, 1, projectCode, workflowDefinition.getCode(), switchTaskDefinitionCode, 1, shellTaskDefinitionCode, 1); + + workflowTaskRelations.add(workflowTaskRelationShell); + workflowTaskRelations.add(workflowTaskRelationSwitch); + + String taskDefinitionLogJson = "[{\"id\":1,\"code\":128645175846368,\"name\":\"shellA\",\"version\":1,\"description\":\"\",\"projectCode\":128645169571296,\"userId\":1,\"taskType\":\"SHELL\"," + + "\"taskParams\":{\"localParams\":[],\"rawScript\":\"echo 'A'\",\"resourceList\":[]},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"environmentCode\":-1," + + "\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeout\":0,\"delayTime\":0,\"createTime\":\"2024-12-25 01:15:08\",\"updateTime\":\"2024-12-25 01:15:08\"," + + "\"taskGroupId\":0,\"taskGroupPriority\":0,\"cpuQuota\":-1,\"memoryMax\":-1,\"taskExecuteType\":\"BATCH\"},{\"id\":2,\"code\":128645191546336,\"name\":\"switchA\",\"version\":1," + + "\"description\":\"\",\"projectCode\":128645169571296,\"userId\":1,\"taskType\":\"SWITCH\"," + + "\"taskParams\":{\"localParams\":[],\"rawScript\":\"\",\"resourceList\":[],\"switchResult\":{\"dependTaskList\":[{\"condition\":\"${value} == 'A'\",\"nextNode\":128645175846368}]," + + "\"nextNode\":128645175846368}},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"environmentCode\":-1,\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\"," + + "\"timeout\":0,\"delayTime\":0,\"createTime\":\"2024-12-25 01:15:08\",\"updateTime\":\"2024-12-25 01:15:08\",\"taskGroupId\":0,\"taskGroupPriority\":0,\"cpuQuota\":-1,\"memoryMax\":-1,\"taskExecuteType\":\"BATCH\"}]"; + + List taskDefinitionLogs = JSONUtils.toList(taskDefinitionLogJson, TaskDefinitionLog.class); + + when(projectMapper.queryByCode(projectCode)).thenReturn(project); + when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_BATCH_COPY)).thenReturn(result); + when(workflowDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(workflowDefinitionList); + when(workflowTaskRelationMapper.queryByWorkflowDefinitionCode(Long.parseLong(codes))).thenReturn(workflowTaskRelations); + when(taskDefinitionLogDao.queryTaskDefineLogList(workflowTaskRelations)).thenReturn(taskDefinitionLogs); + when(processService.saveTaskDefine(user,projectCode,taskDefinitionLogs,true)).thenReturn(1); + when(processService.saveWorkflowDefine(user,workflowDefinition,true,true)).thenReturn(1); + Map successRes = processDefinitionService.batchCopyWorkflowDefinition(user, projectCode, codes, targetProjectCode); + Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); + + } @Test public void testQueryWorkflowDefinitionList() { when(projectMapper.queryByCode(projectCode)).thenReturn(getProject(projectCode)); @@ -1122,6 +1183,21 @@ private List getProcessTaskRelation() { return workflowTaskRelations; } + private WorkflowTaskRelation getWorkflowTaskRelation(int id, int workflowDefinitionVersion, long projectCode, + long workflowDefinitionCode, long preTaskCode, int preTaskVersion, + long postTaskCode, int postTaskVersion) { + WorkflowTaskRelation workflowTaskRelation = new WorkflowTaskRelation(); + workflowTaskRelation.setId(id); + workflowTaskRelation.setWorkflowDefinitionVersion(workflowDefinitionVersion); + workflowTaskRelation.setProjectCode(projectCode); + workflowTaskRelation.setWorkflowDefinitionCode(workflowDefinitionCode); + workflowTaskRelation.setPreTaskCode(preTaskCode); + workflowTaskRelation.setPreTaskVersion(preTaskVersion); + workflowTaskRelation.setPostTaskCode(postTaskCode); + workflowTaskRelation.setPostTaskVersion(postTaskVersion); + return workflowTaskRelation; + } + /** * get mock schedule * From 63e9ed417c008829e51d6754bc38257e04313bb3 Mon Sep 17 00:00:00 2001 From: liwenxin Date: Thu, 26 Dec 2024 14:44:15 +0800 Subject: [PATCH 3/5] fix for code style --- .../impl/WorkflowDefinitionServiceImpl.java | 11 ++-- .../WorkflowDefinitionServiceTest.java | 55 +++++++++++++------ 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java index c961be76dea1..92cc50006b8c 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java @@ -2124,11 +2124,13 @@ protected void doBatchOperateWorkflowDefinition(User loginUser, long taskCode = CodeGenerateUtils.genCode(); taskCodeMap.put(taskDefinitionLog.getCode(), taskCode); taskDefinitionLog.setCode(taskCode); - if (TaskTypeUtils.isSwitchTask(taskDefinitionLog.getTaskType())){ + if (TaskTypeUtils.isSwitchTask(taskDefinitionLog.getTaskType())) { final String taskParams = taskDefinitionLog.getTaskParams(); - final SwitchParameters switchParameters = JSONUtils.parseObject(taskParams, SwitchParameters.class); + final SwitchParameters switchParameters = + JSONUtils.parseObject(taskParams, SwitchParameters.class); if (switchParameters == null) { - throw new IllegalArgumentException("Switch task params: " + taskParams + " is invalid."); + throw new IllegalArgumentException( + "Switch task params: " + taskParams + " is invalid."); } SwitchParameters.SwitchResult switchResult = switchParameters.getSwitchResult(); List dependTaskList = switchResult.getDependTaskList(); @@ -2138,8 +2140,7 @@ protected void doBatchOperateWorkflowDefinition(User loginUser, switchResult.setDependTaskList(dependTaskList); if (switchResult.getNextNode() != null) { switchResult.setNextNode( - taskCodeMap.get(switchResult.getNextNode()) - ); + taskCodeMap.get(switchResult.getNextNode())); } taskDefinitionLog.setTaskParams(JSONUtils.toJsonString(switchParameters)); } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java index 10b4b9e69a99..15064f738543 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowDefinitionServiceTest.java @@ -50,7 +50,16 @@ import org.apache.dolphinscheduler.common.graph.DAG; import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; -import org.apache.dolphinscheduler.dao.entity.*; +import org.apache.dolphinscheduler.dao.entity.DagData; +import org.apache.dolphinscheduler.dao.entity.DataSource; +import org.apache.dolphinscheduler.dao.entity.Project; +import org.apache.dolphinscheduler.dao.entity.Schedule; +import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog; +import org.apache.dolphinscheduler.dao.entity.TaskMainInfo; +import org.apache.dolphinscheduler.dao.entity.User; +import org.apache.dolphinscheduler.dao.entity.UserWithWorkflowDefinitionCode; +import org.apache.dolphinscheduler.dao.entity.WorkflowDefinition; +import org.apache.dolphinscheduler.dao.entity.WorkflowTaskRelation; import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper; @@ -238,33 +247,42 @@ public void testCopyworkflowLogicalNodeSwitch() { project.setUserId(user.getId()); List workflowTaskRelations = new ArrayList<>(); - WorkflowTaskRelation workflowTaskRelationShell = getWorkflowTaskRelation - (1, 1, projectCode, workflowDefinition.getCode(), 0L, 1, switchTaskDefinitionCode, 1); - WorkflowTaskRelation workflowTaskRelationSwitch = getWorkflowTaskRelation - (2, 1, projectCode, workflowDefinition.getCode(), switchTaskDefinitionCode, 1, shellTaskDefinitionCode, 1); + WorkflowTaskRelation workflowTaskRelationShell = getWorkflowTaskRelation(1, 1, projectCode, + workflowDefinition.getCode(), 0L, 1, switchTaskDefinitionCode, 1); + WorkflowTaskRelation workflowTaskRelationSwitch = getWorkflowTaskRelation(2, 1, projectCode, + workflowDefinition.getCode(), switchTaskDefinitionCode, 1, shellTaskDefinitionCode, 1); workflowTaskRelations.add(workflowTaskRelationShell); workflowTaskRelations.add(workflowTaskRelationSwitch); - String taskDefinitionLogJson = "[{\"id\":1,\"code\":128645175846368,\"name\":\"shellA\",\"version\":1,\"description\":\"\",\"projectCode\":128645169571296,\"userId\":1,\"taskType\":\"SHELL\"," + - "\"taskParams\":{\"localParams\":[],\"rawScript\":\"echo 'A'\",\"resourceList\":[]},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"environmentCode\":-1," + - "\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeout\":0,\"delayTime\":0,\"createTime\":\"2024-12-25 01:15:08\",\"updateTime\":\"2024-12-25 01:15:08\"," + - "\"taskGroupId\":0,\"taskGroupPriority\":0,\"cpuQuota\":-1,\"memoryMax\":-1,\"taskExecuteType\":\"BATCH\"},{\"id\":2,\"code\":128645191546336,\"name\":\"switchA\",\"version\":1," + - "\"description\":\"\",\"projectCode\":128645169571296,\"userId\":1,\"taskType\":\"SWITCH\"," + - "\"taskParams\":{\"localParams\":[],\"rawScript\":\"\",\"resourceList\":[],\"switchResult\":{\"dependTaskList\":[{\"condition\":\"${value} == 'A'\",\"nextNode\":128645175846368}]," + - "\"nextNode\":128645175846368}},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"environmentCode\":-1,\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\"," + - "\"timeout\":0,\"delayTime\":0,\"createTime\":\"2024-12-25 01:15:08\",\"updateTime\":\"2024-12-25 01:15:08\",\"taskGroupId\":0,\"taskGroupPriority\":0,\"cpuQuota\":-1,\"memoryMax\":-1,\"taskExecuteType\":\"BATCH\"}]"; + String taskDefinitionLogJson = + "[{\"id\":1,\"code\":128645175846368,\"name\":\"shellA\",\"version\":1,\"description\":\"\",\"projectCode\":128645169571296,\"userId\":1,\"taskType\":\"SHELL\"," + + + "\"taskParams\":{\"localParams\":[],\"rawScript\":\"echo 'A'\",\"resourceList\":[]},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"environmentCode\":-1," + + + "\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\",\"timeout\":0,\"delayTime\":0,\"createTime\":\"2024-12-25 01:15:08\",\"updateTime\":\"2024-12-25 01:15:08\"," + + + "\"taskGroupId\":0,\"taskGroupPriority\":0,\"cpuQuota\":-1,\"memoryMax\":-1,\"taskExecuteType\":\"BATCH\"},{\"id\":2,\"code\":128645191546336,\"name\":\"switchA\",\"version\":1," + + + "\"description\":\"\",\"projectCode\":128645169571296,\"userId\":1,\"taskType\":\"SWITCH\"," + + "\"taskParams\":{\"localParams\":[],\"rawScript\":\"\",\"resourceList\":[],\"switchResult\":{\"dependTaskList\":[{\"condition\":\"${value} == 'A'\",\"nextNode\":128645175846368}]," + + + "\"nextNode\":128645175846368}},\"flag\":\"YES\",\"taskPriority\":\"MEDIUM\",\"workerGroup\":\"default\",\"environmentCode\":-1,\"failRetryTimes\":0,\"failRetryInterval\":1,\"timeoutFlag\":\"CLOSE\"," + + + "\"timeout\":0,\"delayTime\":0,\"createTime\":\"2024-12-25 01:15:08\",\"updateTime\":\"2024-12-25 01:15:08\",\"taskGroupId\":0,\"taskGroupPriority\":0,\"cpuQuota\":-1,\"memoryMax\":-1,\"taskExecuteType\":\"BATCH\"}]"; List taskDefinitionLogs = JSONUtils.toList(taskDefinitionLogJson, TaskDefinitionLog.class); when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(user, project, projectCode, WORKFLOW_BATCH_COPY)).thenReturn(result); when(workflowDefinitionMapper.queryByCodes(definitionCodes)).thenReturn(workflowDefinitionList); - when(workflowTaskRelationMapper.queryByWorkflowDefinitionCode(Long.parseLong(codes))).thenReturn(workflowTaskRelations); + when(workflowTaskRelationMapper.queryByWorkflowDefinitionCode(Long.parseLong(codes))) + .thenReturn(workflowTaskRelations); when(taskDefinitionLogDao.queryTaskDefineLogList(workflowTaskRelations)).thenReturn(taskDefinitionLogs); - when(processService.saveTaskDefine(user,projectCode,taskDefinitionLogs,true)).thenReturn(1); - when(processService.saveWorkflowDefine(user,workflowDefinition,true,true)).thenReturn(1); - Map successRes = processDefinitionService.batchCopyWorkflowDefinition(user, projectCode, codes, targetProjectCode); + when(processService.saveTaskDefine(user, projectCode, taskDefinitionLogs, true)).thenReturn(1); + when(processService.saveWorkflowDefine(user, workflowDefinition, true, true)).thenReturn(1); + Map successRes = + processDefinitionService.batchCopyWorkflowDefinition(user, projectCode, codes, targetProjectCode); Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); } @@ -1184,7 +1202,8 @@ private List getProcessTaskRelation() { } private WorkflowTaskRelation getWorkflowTaskRelation(int id, int workflowDefinitionVersion, long projectCode, - long workflowDefinitionCode, long preTaskCode, int preTaskVersion, + long workflowDefinitionCode, long preTaskCode, + int preTaskVersion, long postTaskCode, int postTaskVersion) { WorkflowTaskRelation workflowTaskRelation = new WorkflowTaskRelation(); workflowTaskRelation.setId(id); From d335f78a247ef88144dbf7c07bbeb59832fb3888 Mon Sep 17 00:00:00 2001 From: LiWenXin Date: Fri, 27 Dec 2024 18:30:47 +0800 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: Wenjun Ruan --- .../api/service/impl/WorkflowDefinitionServiceImpl.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java index 92cc50006b8c..c350733a8d8b 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java @@ -2133,11 +2133,9 @@ protected void doBatchOperateWorkflowDefinition(User loginUser, "Switch task params: " + taskParams + " is invalid."); } SwitchParameters.SwitchResult switchResult = switchParameters.getSwitchResult(); - List dependTaskList = switchResult.getDependTaskList(); - dependTaskList.forEach(switchResultVo -> { + switchResult.getDependTaskList().forEach(switchResultVo -> { switchResultVo.setNextNode(taskCodeMap.get(switchResultVo.getNextNode())); }); - switchResult.setDependTaskList(dependTaskList); if (switchResult.getNextNode() != null) { switchResult.setNextNode( taskCodeMap.get(switchResult.getNextNode())); From 1468cbc299d3318253fd67a757dd7b672f3d29e8 Mon Sep 17 00:00:00 2001 From: liwenxin Date: Sat, 28 Dec 2024 13:34:59 +0800 Subject: [PATCH 5/5] fix for code style --- .../api/service/impl/WorkflowDefinitionServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java index c350733a8d8b..f9432da84f6d 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java @@ -115,7 +115,6 @@ import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem; import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel; import org.apache.dolphinscheduler.plugin.task.api.model.Property; -import org.apache.dolphinscheduler.plugin.task.api.model.SwitchResultVo; import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.SqlParameters; import org.apache.dolphinscheduler.plugin.task.api.parameters.SwitchParameters;