From cd1950727112c75a9c5cd7d2ea4e4338e37eb9b7 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 25 Mar 2021 18:27:47 +0800 Subject: [PATCH] [feature][jsonsplit]fix copy/export/import processDefinition bugs (#5146) * Modify Project and ProjectUser Mapper * Modify Project and ProjectUser Mapper * project_code is bigint(20) * modify ERROR name * modify saveProcessDefine, remove the duplicate code with createTaskAndRelation * modify import/export processdefinition, add genProcessData * fix ut and bug * code style * repalce project_id with code * conflicts solve * conflicts solve * conflicts solve * bugfix * modify listResources mothod and remove getResourceIds mothod * 1 * conflicts solve * modify listResources mothod and remove getResourceIds mothod * modify listResources mothod and remove getResourceIds mothod * replace processDefinitionVersion with processDefinitionLog * codestyle * codestyle * add mapper module ut * codestyle * fix ProcessInstanceMapperTest * codestyle * conflicts solve * conflicts solve * conflicts solve * conflicts solve * conflicts solve * fix ProcessInstanceMapperTest * fix ProjectMapperTest/ProjectUserMapperTest/ScheduleMapperTest * fix ProjectMapperTest/ProjectUserMapperTest/ScheduleMapperTest * fix TaskInstanceMapperTest * add TaskDefinitionLogMapperTest/TaskDefinitionMapperTest and bugfix * codestyle * codestyle * Refactor process lineage * Refactor process lineage * codestyle * codestyle * Refactor process lineage * Refactor process lineage * add WorkFlowLineageMapperTest/WorkFlowLineageServiceTest * add WorkFlowLineageMapperTest/WorkFlowLineageServiceTest * add ProcessServiceTest * 1 * 1 * fix copy/export/import processDefinition bugs * 1 * codestyle --- .../service/impl/ProcessDefinitionServiceImpl.java | 11 ++++++++++- .../common/model/PreviousTaskNode.java | 4 ++++ .../service/process/ProcessService.java | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) 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 dec3d19547..96a7372781 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 @@ -281,6 +281,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro int operator = processDefinitionLog.getOperator(); User user = userMapper.selectById(operator); pd.setModifyBy(user.getUserName()); + pd.setProjectId(project.getId()); } processDefinitionIPage.setRecords(records); @@ -1397,7 +1398,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro } else { ProcessData processData = processService.genProcessData(processDefinition); List taskNodeList = processData.getTasks(); - taskNodeList.forEach(taskNode -> taskNode.setCode(0L)); + taskNodeList.forEach(taskNode -> { + taskNode.setName(taskNode.getName() + "_copy_" + DateUtils.getCurrentTimeStamp()); + taskNode.setCode(0L); + }); processData.setTasks(taskNodeList); String processDefinitionJson = JSONUtils.toJsonString(processData); return createProcessDefinition( @@ -1579,6 +1583,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro } } catch (Exception e) { setFailedProcessList(failedProcessList, processDefinitionId); + logger.error("move processDefinition error: {}", e.getMessage(), e); + } } } @@ -1602,6 +1608,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro } } catch (Exception e) { setFailedProcessList(failedProcessList, processDefinitionId); + logger.error("copy processDefinition error: {}", e.getMessage(), e); + } } } @@ -1689,6 +1697,7 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro putMsg(result, Status.SUCCESS); } } + /** * check has associated process definition * diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/PreviousTaskNode.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/PreviousTaskNode.java index c0ac665d19..020357578e 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/PreviousTaskNode.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/PreviousTaskNode.java @@ -34,6 +34,10 @@ public class PreviousTaskNode { */ private int version; + public PreviousTaskNode() { + + } + public PreviousTaskNode(long code, String name, int version) { this.code = code; this.name = name; diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java index 4dbb60ae0a..9c9a4e7fbc 100644 --- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java +++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java @@ -2298,6 +2298,7 @@ public class ProcessService { String desc, String locations, String connects) { ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(); Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinitionCode); + processDefinitionLog.setUserId(operator.getId()); processDefinitionLog.setCode(processDefinitionCode); processDefinitionLog.setVersion(version == null || version == 0 ? 1 : version); processDefinitionLog.setName(processDefinitionName);