From 0d26724455316da665c0c8501b19531ada663779 Mon Sep 17 00:00:00 2001 From: wind Date: Tue, 26 Oct 2021 17:35:06 +0800 Subject: [PATCH] [DS-6591][API] fix process definition import (#6592) Co-authored-by: caishunfeng <534328519@qq.com> --- .../api/service/impl/ProcessDefinitionServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java index a138451bfe..d4aa93ec92 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java @@ -849,6 +849,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro } String processDefinitionName = recursionProcessDefinitionName(projectCode, processDefinition.getName(), 1); processDefinition.setName(processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp()); + processDefinition.setId(0); + processDefinition.setProjectCode(projectCode); processDefinition.setUserId(loginUser.getId()); try { processDefinition.setCode(SnowFlakeUtils.getInstance().nextId()); @@ -892,8 +894,12 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro List taskRelationLogList = new ArrayList<>(); for (ProcessTaskRelation processTaskRelation : taskRelationList) { ProcessTaskRelationLog processTaskRelationLog = new ProcessTaskRelationLog(processTaskRelation); - processTaskRelationLog.setPreTaskCode(taskCodeMap.get(processTaskRelationLog.getPreTaskCode())); - processTaskRelationLog.setPostTaskCode(taskCodeMap.get(processTaskRelationLog.getPostTaskCode())); + if (taskCodeMap.containsKey(processTaskRelationLog.getPreTaskCode())) { + processTaskRelationLog.setPreTaskCode(taskCodeMap.get(processTaskRelationLog.getPreTaskCode())); + } + if (taskCodeMap.containsKey(processTaskRelationLog.getPostTaskCode())) { + processTaskRelationLog.setPostTaskCode(taskCodeMap.get(processTaskRelationLog.getPostTaskCode())); + } processTaskRelationLog.setPreTaskVersion(Constants.VERSION_FIRST); processTaskRelationLog.setPostTaskVersion(Constants.VERSION_FIRST); taskRelationLogList.add(processTaskRelationLog);