Browse Source

[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
pull/3/MERGE
Simon 4 years ago committed by GitHub
parent
commit
cd19507271
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  2. 4
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/PreviousTaskNode.java
  3. 1
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

11
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(); int operator = processDefinitionLog.getOperator();
User user = userMapper.selectById(operator); User user = userMapper.selectById(operator);
pd.setModifyBy(user.getUserName()); pd.setModifyBy(user.getUserName());
pd.setProjectId(project.getId());
} }
processDefinitionIPage.setRecords(records); processDefinitionIPage.setRecords(records);
@ -1397,7 +1398,10 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
} else { } else {
ProcessData processData = processService.genProcessData(processDefinition); ProcessData processData = processService.genProcessData(processDefinition);
List<TaskNode> taskNodeList = processData.getTasks(); List<TaskNode> 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); processData.setTasks(taskNodeList);
String processDefinitionJson = JSONUtils.toJsonString(processData); String processDefinitionJson = JSONUtils.toJsonString(processData);
return createProcessDefinition( return createProcessDefinition(
@ -1579,6 +1583,8 @@ public class ProcessDefinitionServiceImpl extends BaseServiceImpl implements Pro
} }
} catch (Exception e) { } catch (Exception e) {
setFailedProcessList(failedProcessList, processDefinitionId); 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) { } catch (Exception e) {
setFailedProcessList(failedProcessList, processDefinitionId); 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); putMsg(result, Status.SUCCESS);
} }
} }
/** /**
* check has associated process definition * check has associated process definition
* *

4
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/model/PreviousTaskNode.java

@ -34,6 +34,10 @@ public class PreviousTaskNode {
*/ */
private int version; private int version;
public PreviousTaskNode() {
}
public PreviousTaskNode(long code, String name, int version) { public PreviousTaskNode(long code, String name, int version) {
this.code = code; this.code = code;
this.name = name; this.name = name;

1
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) { String desc, String locations, String connects) {
ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog(); ProcessDefinitionLog processDefinitionLog = new ProcessDefinitionLog();
Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinitionCode); Integer version = processDefineLogMapper.queryMaxVersionForDefinition(processDefinitionCode);
processDefinitionLog.setUserId(operator.getId());
processDefinitionLog.setCode(processDefinitionCode); processDefinitionLog.setCode(processDefinitionCode);
processDefinitionLog.setVersion(version == null || version == 0 ? 1 : version); processDefinitionLog.setVersion(version == null || version == 0 ? 1 : version);
processDefinitionLog.setName(processDefinitionName); processDefinitionLog.setName(processDefinitionName);

Loading…
Cancel
Save