diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java index 5732027044..458fedb3d5 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java @@ -76,7 +76,6 @@ public class SchedulerController extends BaseController { @Autowired private SchedulerService schedulerService; - /** * create schedule * @@ -125,7 +124,7 @@ public class SchedulerController extends BaseController { * updateProcessInstance schedule * * @param loginUser login user - * @param projectName project name + * @param projectCode project code * @param id scheduler id * @param schedule scheduler * @param warningType warning type @@ -149,7 +148,7 @@ public class SchedulerController extends BaseController { @ApiException(UPDATE_SCHEDULE_ERROR) @AccessLogAnnotation(ignoreRequestArgs = "loginUser") public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, - @ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName, + @ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode, @RequestParam(value = "id") Integer id, @RequestParam(value = "schedule") String schedule, @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType, @@ -158,8 +157,8 @@ public class SchedulerController extends BaseController { @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) { - Map result = schedulerService.updateSchedule(loginUser, projectName, id, schedule, - warningType, warningGroupId, failureStrategy, null, processInstancePriority, workerGroup); + Map result = schedulerService.updateSchedule(loginUser, projectCode, id, schedule, + warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup); return returnDataList(result); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java index 7b743c4eb5..4e00ae31f0 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java @@ -58,7 +58,7 @@ public interface SchedulerService { * updateProcessInstance schedule * * @param loginUser login user - * @param projectName project name + * @param projectCode project code * @param id scheduler id * @param scheduleExpression scheduler * @param warningType warning type @@ -66,17 +66,15 @@ public interface SchedulerService { * @param failureStrategy failure strategy * @param workerGroup worker group * @param processInstancePriority process instance priority - * @param scheduleStatus schedule status * @return update result code */ Map updateSchedule(User loginUser, - String projectName, + long projectCode, Integer id, String scheduleExpression, WarningType warningType, int warningGroupId, FailureStrategy failureStrategy, - ReleaseState scheduleStatus, Priority processInstancePriority, String workerGroup); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java index ef383e574d..5a111235af 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java @@ -189,7 +189,7 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe * updateProcessInstance schedule * * @param loginUser login user - * @param projectName project name + * @param projectCode project code * @param id scheduler id * @param scheduleExpression scheduler * @param warningType warning type @@ -203,18 +203,17 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe @Override @Transactional(rollbackFor = RuntimeException.class) public Map updateSchedule(User loginUser, - String projectName, + long projectCode, Integer id, String scheduleExpression, WarningType warningType, int warningGroupId, FailureStrategy failureStrategy, - ReleaseState scheduleStatus, Priority processInstancePriority, String workerGroup) { Map result = new HashMap<>(); - Project project = projectMapper.queryByName(projectName); + Project project = projectMapper.queryByCode(projectCode); // check project auth boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result); @@ -273,9 +272,6 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe schedule.setFailureStrategy(failureStrategy); } - if (scheduleStatus != null) { - schedule.setReleaseState(scheduleStatus); - } schedule.setWorkerGroup(workerGroup); schedule.setUpdateTime(now); schedule.setProcessInstancePriority(processInstancePriority); diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java index 83d1ae8b06..c68963cc6a 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java @@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.controller; import static org.mockito.Mockito.doNothing; import java.text.MessageFormat; +import java.util.HashMap; import java.util.Map; import org.apache.dolphinscheduler.api.ApiApplicationServer; @@ -93,6 +94,13 @@ public class AbstractControllerTest { Assert.assertTrue(StringUtils.isNotEmpty(session)); } + public Map successResult() { + Map serviceResult = new HashMap<>(); + putMsg(serviceResult, Status.SUCCESS); + serviceResult.put(Constants.DATA_LIST, "{}"); + return serviceResult; + } + public void putMsg(Map result, Status status, Object... statusParams) { result.put(Constants.STATUS, status); if (statusParams != null && statusParams.length > 0) { diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java index d37f1061cc..9ce254b281 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java @@ -23,13 +23,9 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import java.util.HashMap; -import java.util.Map; - import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.SchedulerService; import org.apache.dolphinscheduler.api.utils.Result; -import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.FailureStrategy; import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.WarningType; @@ -69,13 +65,9 @@ public class SchedulerControllerTest extends AbstractControllerTest { paramsMap.add("workerGroupId","1"); paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH)); - Map serviceResult = new HashMap<>(); - putMsg(serviceResult, Status.SUCCESS); - serviceResult.put(Constants.DATA_LIST, 1); - Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class), isA(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class), - isA(Priority.class), isA(String.class))).thenReturn(serviceResult); + isA(Priority.class), isA(String.class))).thenReturn(successResult()); MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123) .header(SESSION_ID, sessionId) @@ -89,7 +81,6 @@ public class SchedulerControllerTest extends AbstractControllerTest { logger.info(mvcResult.getResponse().getContentAsString()); } - @Test public void testUpdateSchedule() throws Exception { MultiValueMap paramsMap = new LinkedMultiValueMap<>(); @@ -103,7 +94,11 @@ public class SchedulerControllerTest extends AbstractControllerTest { paramsMap.add("workerGroupId","1"); paramsMap.add("processInstancePriority",String.valueOf(Priority.HIGH)); - MvcResult mvcResult = mockMvc.perform(post("/projects/{projectName}/schedule/update","cxc_1113") + Mockito.when(schedulerService.updateSchedule(isA(User.class), isA(Long.class), isA(Integer.class), + isA(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class), + isA(Priority.class), isA(String.class))).thenReturn(successResult()); + + MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123) .header(SESSION_ID, sessionId) .params(paramsMap)) .andExpect(status().isOk()) diff --git a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js index 4166c1d068..fb5acaf32a 100644 --- a/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js +++ b/dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js @@ -616,7 +616,7 @@ export default { */ updateSchedule ({ state }, payload) { return new Promise((resolve, reject) => { - io.post(`projects/${state.projectName}/schedule/update`, payload, res => { + io.post(`projects/${state.projectCode}/schedule/update`, payload, res => { resolve(res) }).catch(e => { reject(e)