From 860021f4467226818ad38488031502a780304cc1 Mon Sep 17 00:00:00 2001 From: Aaron Wang Date: Sat, 22 Apr 2023 23:05:18 +0800 Subject: [PATCH] update processInstance bug --- .../api/controller/ProcessInstanceController.java | 7 ++----- .../api/service/ProcessInstanceService.java | 4 +--- .../api/service/impl/ProcessInstanceServiceImpl.java | 8 +++----- .../api/controller/ProcessInstanceControllerTest.java | 2 +- .../api/service/ProcessInstanceServiceTest.java | 10 +++++----- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java index a3e9cab5852a6..b64f51a70b597 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceController.java @@ -175,7 +175,6 @@ public Result queryTaskListByProcessId(@Parameter(hidden = true) @RequestAttribu @Parameter(name = "globalParams", description = "PROCESS_GLOBAL_PARAMS", schema = @Schema(implementation = String.class, example = "[]")), @Parameter(name = "locations", description = "PROCESS_INSTANCE_LOCATIONS", schema = @Schema(implementation = String.class)), @Parameter(name = "timeout", description = "PROCESS_TIMEOUT", schema = @Schema(implementation = int.class, example = "0")), - @Parameter(name = "tenantCode", description = "TENANT_CODE", schema = @Schema(implementation = String.class, example = "default")) }) @PutMapping(value = "/{id}") @ResponseStatus(HttpStatus.OK) @@ -190,11 +189,9 @@ public Result updateProcessInstance(@Parameter(hidden = true) @RequestAttribute( @RequestParam(value = "syncDefine", required = true) Boolean syncDefine, @RequestParam(value = "globalParams", required = false, defaultValue = "[]") String globalParams, @RequestParam(value = "locations", required = false) String locations, - @RequestParam(value = "timeout", required = false, defaultValue = "0") int timeout, - @RequestParam(value = "tenantCode", required = true) String tenantCode) { + @RequestParam(value = "timeout", required = false, defaultValue = "0") int timeout) { Map result = processInstanceService.updateProcessInstance(loginUser, projectCode, id, - taskRelationJson, taskDefinitionJson, scheduleTime, syncDefine, globalParams, locations, timeout, - tenantCode); + taskRelationJson, taskDefinitionJson, scheduleTime, syncDefine, globalParams, locations, timeout); return returnDataList(result); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java index f866fc9313dd0..304d0139e2a7d 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java @@ -148,7 +148,6 @@ Map querySubProcessInstanceByTaskId(User loginUser, * @param globalParams global params * @param locations locations for nodes * @param timeout timeout - * @param tenantCode tenantCode * @return update result code */ Map updateProcessInstance(User loginUser, @@ -160,8 +159,7 @@ Map updateProcessInstance(User loginUser, Boolean syncDefine, String globalParams, String locations, - int timeout, - String tenantCode); + int timeout); /** * query parent process instance detail info by sub process instance id diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java index 6fb10fd4317f0..5c804241b3cc6 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessInstanceServiceImpl.java @@ -607,7 +607,6 @@ public Map querySubProcessInstanceByTaskId(User loginUser, long * @param globalParams global params * @param locations locations for nodes * @param timeout timeout - * @param tenantCode tenantCode * @return update result code */ @Transactional @@ -616,7 +615,7 @@ public Map updateProcessInstance(User loginUser, long projectCod String taskRelationJson, String taskDefinitionJson, String scheduleTime, Boolean syncDefine, String globalParams, - String locations, int timeout, String tenantCode) { + String locations, int timeout) { Project project = projectMapper.queryByCode(projectCode); // check user access for project Map result = @@ -655,7 +654,7 @@ public Map updateProcessInstance(User loginUser, long projectCod timezoneId = commandParamMap.get(Constants.SCHEDULE_TIMEZONE); } - setProcessInstance(processInstance, tenantCode, scheduleTime, globalParams, timeout, timezoneId); + setProcessInstance(processInstance, scheduleTime, globalParams, timeout, timezoneId); List taskDefinitionLogs = JSONUtils.toList(taskDefinitionJson, TaskDefinitionLog.class); if (taskDefinitionLogs.isEmpty()) { log.warn("Parameter taskDefinitionJson is empty"); @@ -736,7 +735,7 @@ public Map updateProcessInstance(User loginUser, long projectCod /** * update process instance attributes */ - private void setProcessInstance(ProcessInstance processInstance, String tenantCode, String scheduleTime, + private void setProcessInstance(ProcessInstance processInstance, String scheduleTime, String globalParams, int timeout, String timezone) { Date schedule = processInstance.getScheduleTime(); if (scheduleTime != null) { @@ -749,7 +748,6 @@ private void setProcessInstance(ProcessInstance processInstance, String tenantCo globalParams = curingGlobalParamsService.curingGlobalParams(processInstance.getId(), globalParamMap, globalParamList, processInstance.getCmdTypeIfComplement(), schedule, timezone); processInstance.setTimeout(timeout); - processInstance.setTenantCode(tenantCode); processInstance.setGlobalParams(globalParams); } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java index b0f36c9c56d93..9a45627d5cf09 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessInstanceControllerTest.java @@ -108,7 +108,7 @@ public void testUpdateProcessInstance() throws Exception { Mockito.when(processInstanceService .updateProcessInstance(Mockito.any(), Mockito.anyLong(), Mockito.anyInt(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), - Mockito.anyString(), Mockito.anyInt(), Mockito.anyString())) + Mockito.anyString(), Mockito.anyInt())) .thenReturn(mockResult); String json = diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java index b35b9ccf3c145..905b8aabaf8f2 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessInstanceServiceTest.java @@ -555,7 +555,7 @@ public void testUpdateProcessInstance() { when(projectMapper.queryByCode(projectCode)).thenReturn(project); when(projectService.checkProjectAndAuth(loginUser, project, projectCode, INSTANCE_UPDATE)).thenReturn(result); Map projectAuthFailRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1, - shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, ""); + shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0); Assertions.assertEquals(Status.PROJECT_NOT_FOUND, projectAuthFailRes.get(Constants.STATUS)); // process instance null @@ -566,7 +566,7 @@ public void testUpdateProcessInstance() { when(processService.findProcessInstanceDetailById(1)).thenReturn(Optional.empty()); Assertions.assertThrows(ServiceException.class, () -> { processInstanceService.updateProcessInstance(loginUser, projectCode, 1, - shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, ""); + shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0); }); // process instance not finish when(processService.findProcessInstanceDetailById(1)).thenReturn(Optional.ofNullable(processInstance)); @@ -574,7 +574,7 @@ public void testUpdateProcessInstance() { putMsg(result, Status.SUCCESS, projectCode); Map processInstanceNotFinishRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1, - shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0, ""); + shellJson, taskJson, "2020-02-21 00:00:00", true, "", "", 0); Assertions.assertEquals(Status.PROCESS_INSTANCE_STATE_OPERATION_ERROR, processInstanceNotFinishRes.get(Constants.STATUS)); @@ -602,7 +602,7 @@ public void testUpdateProcessInstance() { when(taskPluginManager.checkTaskParameters(Mockito.any())).thenReturn(true); Map processInstanceFinishRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1, - taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", true, "", "", 0, "root"); + taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", true, "", "", 0); Assertions.assertEquals(Status.SUCCESS, processInstanceFinishRes.get(Constants.STATUS)); // success @@ -612,7 +612,7 @@ public void testUpdateProcessInstance() { when(processService.saveProcessDefine(loginUser, processDefinition, Boolean.FALSE, Boolean.FALSE)) .thenReturn(1); Map successRes = processInstanceService.updateProcessInstance(loginUser, projectCode, 1, - taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", Boolean.FALSE, "", "", 0, "root"); + taskRelationJson, taskDefinitionJson, "2020-02-21 00:00:00", Boolean.FALSE, "", "", 0); Assertions.assertEquals(Status.SUCCESS, successRes.get(Constants.STATUS)); }