From 0963640ea7a96b3fb4274ad702332fe50f1b3a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E5=B9=B4?= <1043706593@qq.com> Date: Tue, 19 Jan 2021 23:03:13 +0800 Subject: [PATCH 1/2] [Improvement-#4481][API] ProcessDefinitionController save API optimization Co-authored-by: lei.zou --- .../impl/ProcessDefinitionServiceImpl.java | 42 ++----------------- .../ProcessDefinitionControllerTest.java | 2 +- 2 files changed, 4 insertions(+), 40 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 245d33bb19..52385dd00f 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 @@ -221,9 +221,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements processDefineMapper.updateVersionByProcessDefinitionId(processDefine.getId(), version); // return processDefinition object with ID - result.put(Constants.DATA_LIST, processDefineMapper.selectById(processDefine.getId())); + result.put(Constants.DATA_LIST, processDefine.getId()); putMsg(result, Status.SUCCESS); - result.put(PROCESSDEFINITIONID, processDefine.getId()); return result; } @@ -888,8 +887,8 @@ public class ProcessDefinitionServiceImpl extends BaseService implements //create process definition Integer processDefinitionId = - Objects.isNull(createProcessResult.get(PROCESSDEFINITIONID)) - ? null : Integer.parseInt(createProcessResult.get(PROCESSDEFINITIONID).toString()); + Objects.isNull(createProcessResult.get(Constants.DATA_LIST)) + ? null : Integer.parseInt(createProcessResult.get(Constants.DATA_LIST).toString()); //scheduler param return getImportProcessScheduleResult(loginUser, @@ -1516,41 +1515,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements } } - /** - * copy process definition - * - * @param loginUser login user - * @param projectName project name - * @param processId process definition id - * @return copy result code - */ - public Map copyProcessDefinition(User loginUser, String projectName, Integer processId) { - - Map result = new HashMap<>(5); - Project project = projectMapper.queryByName(projectName); - - Map checkResult = projectService.checkProjectAndAuth(loginUser, project, projectName); - Status resultStatus = (Status) checkResult.get(Constants.STATUS); - if (resultStatus != Status.SUCCESS) { - return checkResult; - } - - ProcessDefinition processDefinition = processDefineMapper.selectById(processId); - if (processDefinition == null) { - putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processId); - return result; - } else { - return createProcessDefinition( - loginUser, - projectName, - processDefinition.getName() + "_copy_" + System.currentTimeMillis(), - processDefinition.getProcessDefinitionJson(), - processDefinition.getDescription(), - processDefinition.getLocations(), - processDefinition.getConnects()); - } - } - /** * batch copy process definition * diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java index a13afecb0d..662c45d7ac 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java @@ -94,7 +94,7 @@ public class ProcessDefinitionControllerTest { String connects = "[]"; Map result = new HashMap<>(); putMsg(result, Status.SUCCESS); - result.put("processDefinitionId", 1); + result.put(Constants.DATA_LIST, 1); Mockito.when(processDefinitionService.createProcessDefinition(user, projectName, name, json, description, locations, connects)).thenReturn(result); From 17c06ce966fc5c6a6136ee142e4698312fe6532f Mon Sep 17 00:00:00 2001 From: Dean Wong Date: Wed, 20 Jan 2021 10:28:00 +0800 Subject: [PATCH 2/2] [Feature-4423][UI] When the process definition is running, the pop-up box can manually set the global parameters. (#4433) * [DS-130][feat] pass global param values when starting new process instance add optional param for start-process-instance api reuse command_param in command table for persistence overload curingGlobalParams function in ParameterUtils not adapt the UI code yet * change import order * support datetime expression * print start params * (fix) avoid npe when cmdParam is null Change-Id: I3b4c4b5fa1df316ff221e27146e45d7d4d3a404e * [Feature-4423][UI] When the process definition is running, the pop-up box can manually set the global parameters (frontend) adapt the UI code (backend-fix) add empty string check for param Change-Id: I710db55f5059f8bd324c79f4494f2798d58e7b19 * add Startup parameters label Change-Id: I5ac82031ea1b64abec330ee8cf2991477a28fcaa * reuse i18n label Change-Id: I5f322cb1dd8e2cade0c679bd025fc984e31bf3ae --- .../formModel/tasks/_source/localParams.vue | 12 +++-- .../definition/pages/list/_source/start.vue | 52 +++++++++++++++++-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/localParams.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/localParams.vue index c001a20176..3f8c6e889c 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/localParams.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/localParams.vue @@ -59,7 +59,7 @@ - + - + - + @@ -112,6 +112,10 @@ hide: { type: Boolean, default: true + }, + isStartProcess: { + type: Boolean, + default: false } }, methods: { diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/start.vue b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/start.vue index cb6cc67e57..0cf2391981 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/start.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/start.vue @@ -125,6 +125,22 @@ +
+
+ {{$t('Startup parameter')}} +
+
+
+ + +
+
+