Browse Source

[Fix-5510]: the scheduler list-page interface, projectName -> projectCode, processDefinitionId -> processDefinitionCode (#5771)

* fix: createSchedule interface, process definition id -> process definition code

* fix: add junit

* fix junit

* fix: projectName -> projectCode

* fix UT

* Optimize variable type

* fix: the updateSchedule interface, projectName -> projectCode

* fix comment

* fix: The scheduler online/offline interface, projectName -> projectCode

* fix UT

* fix: the scheduler list-page interface, projectName -> projectCode, processDefinitionId -> processDefinitionCode

* add UT

Co-authored-by: wen-hemin <wenhemin@apache.com>
2.0.7-release
wen-hemin 3 years ago committed by GitHub
parent
commit
72535a47e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java
  2. 7
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java
  3. 23
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java
  4. 3
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java
  5. 25
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java
  6. 2
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue
  7. 2
      dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/timing/_source/list.vue
  8. 2
      dolphinscheduler-ui/src/js/conf/home/router/index.js
  9. 2
      dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js
  10. 1
      pom.xml

10
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java

@ -211,8 +211,8 @@ public class SchedulerController extends BaseController {
* query schedule list paging * query schedule list paging
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @param processDefinitionId process definition id * @param processDefinitionCode process definition code
* @param pageNo page number * @param pageNo page number
* @param pageSize page size * @param pageSize page size
* @param searchVal search value * @param searchVal search value
@ -230,8 +230,8 @@ public class SchedulerController extends BaseController {
@ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR) @ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryScheduleListPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser, public Result queryScheduleListPaging(@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 Integer processDefinitionId, @RequestParam long processDefinitionCode,
@RequestParam(value = "searchVal", required = false) String searchVal, @RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageNo") Integer pageNo, @RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) { @RequestParam("pageSize") Integer pageSize) {
@ -241,7 +241,7 @@ public class SchedulerController extends BaseController {
return returnDataListPaging(result); return returnDataListPaging(result);
} }
searchVal = ParameterUtils.handleEscapes(searchVal); searchVal = ParameterUtils.handleEscapes(searchVal);
result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize); result = schedulerService.querySchedule(loginUser, projectCode, processDefinitionCode, searchVal, pageNo, pageSize);
return returnDataListPaging(result); return returnDataListPaging(result);
} }

7
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java

@ -97,14 +97,15 @@ public interface SchedulerService {
* query schedule * query schedule
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @param processDefineId process definition id * @param processDefineCode process definition code
* @param pageNo page number * @param pageNo page number
* @param pageSize page size * @param pageSize page size
* @param searchVal search value * @param searchVal search value
* @return schedule list page * @return schedule list page
*/ */
Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize); Map<String, Object> querySchedule(User loginUser, long projectCode, long processDefineCode, String searchVal,
Integer pageNo, Integer pageSize);
/** /**
* query schedule list * query schedule list

23
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java

@ -197,7 +197,6 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* @param failureStrategy failure strategy * @param failureStrategy failure strategy
* @param workerGroup worker group * @param workerGroup worker group
* @param processInstancePriority process instance priority * @param processInstancePriority process instance priority
* @param scheduleStatus schedule status
* @return update result code * @return update result code
*/ */
@Override @Override
@ -404,19 +403,19 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
* query schedule * query schedule
* *
* @param loginUser login user * @param loginUser login user
* @param projectName project name * @param projectCode project code
* @param processDefineId process definition id * @param processDefineCode process definition code
* @param pageNo page number * @param pageNo page number
* @param pageSize page size * @param pageSize page size
* @param searchVal search value * @param searchVal search value
* @return schedule list page * @return schedule list page
*/ */
@Override @Override
public Map<String, Object> querySchedule(User loginUser, String projectName, Integer processDefineId, String searchVal, Integer pageNo, Integer pageSize) { public Map<String, Object> querySchedule(User loginUser, long projectCode, long processDefineCode, String searchVal,
Integer pageNo, Integer pageSize) {
HashMap<String, Object> result = new HashMap<>(); HashMap<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName); Project project = projectMapper.queryByCode(projectCode);
// check project auth // check project auth
boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result); boolean hasProjectAndPerm = projectService.hasProjectAndPerm(loginUser, project, result);
@ -424,18 +423,18 @@ public class SchedulerServiceImpl extends BaseServiceImpl implements SchedulerSe
return result; return result;
} }
ProcessDefinition processDefinition = processService.findProcessDefineById(processDefineId); ProcessDefinition processDefinition = processDefinitionMapper.queryByCode(processDefineCode);
if (processDefinition == null) { if (processDefinition == null) {
putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineId); putMsg(result, Status.PROCESS_DEFINE_NOT_EXIST, processDefineCode);
return result; return result;
} }
Page<Schedule> page = new Page<>(pageNo, pageSize); Page<Schedule> page = new Page<>(pageNo, pageSize);
IPage<Schedule> scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging( IPage<Schedule> scheduleIPage = scheduleMapper.queryByProcessDefineIdPaging(page, processDefinition.getId(),
page, processDefineId, searchVal searchVal);
);
PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize); PageInfo<Schedule> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int) scheduleIPage.getTotal()); pageInfo.setTotalCount((int)scheduleIPage.getTotal());
pageInfo.setLists(scheduleIPage.getRecords()); pageInfo.setLists(scheduleIPage.getRecords());
result.put(Constants.DATA_LIST, pageInfo); result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);

3
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AbstractControllerTest.java

@ -94,10 +94,9 @@ public class AbstractControllerTest {
Assert.assertTrue(StringUtils.isNotEmpty(session)); Assert.assertTrue(StringUtils.isNotEmpty(session));
} }
public Map<String, Object> successResult() { public Map<String, Object> success() {
Map<String, Object> serviceResult = new HashMap<>(); Map<String, Object> serviceResult = new HashMap<>();
putMsg(serviceResult, Status.SUCCESS); putMsg(serviceResult, Status.SUCCESS);
serviceResult.put(Constants.DATA_LIST, "{}");
return serviceResult; return serviceResult;
} }

25
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/SchedulerControllerTest.java

@ -23,14 +23,19 @@ 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.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Map;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.SchedulerService; import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result; 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.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority; import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -68,7 +73,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
Mockito.when(schedulerService.insertSchedule(isA(User.class), isA(Long.class), isA(Long.class), 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(String.class), isA(WarningType.class), isA(int.class), isA(FailureStrategy.class),
isA(Priority.class), isA(String.class))).thenReturn(successResult()); isA(Priority.class), isA(String.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123) MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/create",123)
.header(SESSION_ID, sessionId) .header(SESSION_ID, sessionId)
@ -97,7 +102,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
Mockito.when(schedulerService.updateSchedule(isA(User.class), isA(Long.class), isA(Integer.class), 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(String.class), isA(WarningType.class), isA(Integer.class), isA(FailureStrategy.class),
isA(Priority.class), isA(String.class))).thenReturn(successResult()); isA(Priority.class), isA(String.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123) MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/update",123)
.header(SESSION_ID, sessionId) .header(SESSION_ID, sessionId)
@ -117,7 +122,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
paramsMap.add("id","37"); paramsMap.add("id","37");
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class),
isA(ReleaseState.class))).thenReturn(successResult()); isA(ReleaseState.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/online",123) MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/online",123)
.header(SESSION_ID, sessionId) .header(SESSION_ID, sessionId)
@ -137,7 +142,7 @@ public class SchedulerControllerTest extends AbstractControllerTest {
paramsMap.add("id","28"); paramsMap.add("id","28");
Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class), Mockito.when(schedulerService.setScheduleState(isA(User.class), isA(Long.class), isA(Integer.class),
isA(ReleaseState.class))).thenReturn(successResult()); isA(ReleaseState.class))).thenReturn(success());
MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/offline",123) MvcResult mvcResult = mockMvc.perform(post("/projects/{projectCode}/schedule/offline",123)
.header(SESSION_ID, sessionId) .header(SESSION_ID, sessionId)
@ -151,16 +156,22 @@ public class SchedulerControllerTest extends AbstractControllerTest {
logger.info(mvcResult.getResponse().getContentAsString()); logger.info(mvcResult.getResponse().getContentAsString());
} }
@Test @Test
public void testQueryScheduleListPaging() throws Exception { public void testQueryScheduleListPaging() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("processDefinitionId","40"); paramsMap.add("processDefinitionCode","40");
paramsMap.add("searchVal","test"); paramsMap.add("searchVal","test");
paramsMap.add("pageNo","1"); paramsMap.add("pageNo","1");
paramsMap.add("pageSize","30"); paramsMap.add("pageSize","30");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/schedule/list-paging","cxc_1113") Map<String, Object> mockResult = success();
PageInfo<Resource> pageInfo = new PageInfo<>(1, 10);
mockResult.put(Constants.DATA_LIST, pageInfo);
Mockito.when(schedulerService.querySchedule(isA(User.class), isA(Long.class), isA(Long.class),
isA(String.class), isA(Integer.class), isA(Integer.class))).thenReturn(mockResult);
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectCode}/schedule/list-paging",123)
.header(SESSION_ID, sessionId) .header(SESSION_ID, sessionId)
.params(paramsMap)) .params(paramsMap))
.andExpect(status().isOk()) .andExpect(status().isOk())

2
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue

@ -243,7 +243,7 @@
* Timing manage * Timing manage
*/ */
_timingManage (item) { _timingManage (item) {
this.$router.push({ path: `/projects/${this.projectId}/definition/list/timing/${item.id}` }) this.$router.push({ path: `/projects/${this.projectId}/definition/list/timing/${item.code}` })
}, },
/** /**
* delete * delete

2
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/timing/_source/list.vue

@ -175,7 +175,7 @@
_getScheduleList (flag) { _getScheduleList (flag) {
this.isLoading = !flag this.isLoading = !flag
this.getScheduleList({ this.getScheduleList({
processDefinitionId: this.$route.params.id, processDefinitionCode: this.$route.params.code,
searchVal: '', searchVal: '',
pageNo: this.pageNo, pageNo: this.pageNo,
pageSize: this.pageSize pageSize: this.pageSize

2
dolphinscheduler-ui/src/js/conf/home/router/index.js

@ -148,7 +148,7 @@ const router = new Router({
} }
}, },
{ {
path: '/projects/:projectId/definition/list/timing/:id', path: '/projects/:projectId/definition/list/timing/:code',
name: 'definition-timing-details', name: 'definition-timing-details',
component: resolve => require(['../pages/projects/pages/definition/timing/index'], resolve), component: resolve => require(['../pages/projects/pages/definition/timing/index'], resolve),
meta: { meta: {

2
dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js

@ -580,7 +580,7 @@ export default {
*/ */
getScheduleList ({ state }, payload) { getScheduleList ({ state }, payload) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
io.get(`projects/${state.projectName}/schedule/list-paging`, payload, res => { io.get(`projects/${state.projectCode}/schedule/list-paging`, payload, res => {
resolve(res) resolve(res)
}).catch(e => { }).catch(e => {
reject(e) reject(e)

1
pom.xml

@ -835,6 +835,7 @@
<include>**/api/configuration/TrafficConfigurationTest.java</include> <include>**/api/configuration/TrafficConfigurationTest.java</include>
<include>**/api/controller/ProcessDefinitionControllerTest.java</include> <include>**/api/controller/ProcessDefinitionControllerTest.java</include>
<include>**/api/controller/TenantControllerTest.java</include> <include>**/api/controller/TenantControllerTest.java</include>
<include>**/api/controller/SchedulerControllerTest.java</include>
<include>**/api/dto/resources/filter/ResourceFilterTest.java</include> <include>**/api/dto/resources/filter/ResourceFilterTest.java</include>
<include>**/api/dto/resources/visitor/ResourceTreeVisitorTest.java</include> <include>**/api/dto/resources/visitor/ResourceTreeVisitorTest.java</include>
<includeDataxTaskTest>**/api/enums/testGetEnum.java</includeDataxTaskTest> <includeDataxTaskTest>**/api/enums/testGetEnum.java</includeDataxTaskTest>

Loading…
Cancel
Save