Skip to content

Commit

Permalink
[fix-16900][api] fix when the copied workflow, the logical node switc…
Browse files Browse the repository at this point in the history
…h loses the flow relationship
  • Loading branch information
liwenxin committed Dec 24, 2024
1 parent 1318a22 commit 61c146a
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<SwitchResultVo> 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);
Expand Down

0 comments on commit 61c146a

Please sign in to comment.