@Test public void getJobSubListByPage() { List<JobConfig> configs = Lists .newArrayList(buildJobConfig("job1"), buildJobConfig("job2"), buildJobConfig("job3")); List<JobConfig> result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(1, 2)); assertEquals(2, result.size()); assertEquals("job1", result.get(0).getJobName()); assertEquals("job2", result.get(1).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(2, 2)); assertEquals(1, result.size()); assertEquals("job3", result.get(0).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(3, 2)); assertEquals(0, result.size()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(0, 2)); assertEquals(2, result.size()); assertEquals("job1", result.get(0).getJobName()); assertEquals("job2", result.get(1).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(-1, 2)); assertEquals(2, result.size()); assertEquals("job1", result.get(0).getJobName()); assertEquals("job2", result.get(1).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(1, 5)); assertEquals(3, result.size()); assertEquals("job1", result.get(0).getJobName()); assertEquals("job2", result.get(1).getJobName()); assertEquals("job3", result.get(2).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(1, 1)); assertEquals(1, result.size()); assertEquals("job1", result.get(0).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(2, 1)); assertEquals(1, result.size()); assertEquals("job2", result.get(0).getJobName()); result = controller.getJobSubListByPage(configs, PageableUtil.generatePageble(1, -1)); assertEquals(3, result.size()); }
protected List getJobSubListByPage(List unSystemJobs, Pageable pageable) { int totalCount = unSystemJobs.size(); int offset = pageable.getOffset(); int end = offset + pageable.getPageSize(); int fromIndex = totalCount >= offset ? offset : -1; int toIndex = totalCount >= end ? end : totalCount; if (fromIndex == -1 || fromIndex > toIndex) { return Lists.newArrayList(); } return unSystemJobs.subList(fromIndex, toIndex); }
JobOverviewController extends AbstractGUIController { protected List getJobSubListByPage(List unSystemJobs, Pageable pageable) { int totalCount = unSystemJobs.size(); int offset = pageable.getOffset(); int end = offset + pageable.getPageSize(); int fromIndex = totalCount >= offset ? offset : -1; int toIndex = totalCount >= end ? end : totalCount; if (fromIndex == -1 || fromIndex > toIndex) { return Lists.newArrayList(); } return unSystemJobs.subList(fromIndex, toIndex); } }
JobOverviewController extends AbstractGUIController { protected List getJobSubListByPage(List unSystemJobs, Pageable pageable) { int totalCount = unSystemJobs.size(); int offset = pageable.getOffset(); int end = offset + pageable.getPageSize(); int fromIndex = totalCount >= offset ? offset : -1; int toIndex = totalCount >= end ? end : totalCount; if (fromIndex == -1 || fromIndex > toIndex) { return Lists.newArrayList(); } return unSystemJobs.subList(fromIndex, toIndex); }  }
JobOverviewController extends AbstractGUIController { protected List getJobSubListByPage(List unSystemJobs, Pageable pageable) { int totalCount = unSystemJobs.size(); int offset = pageable.getOffset(); int end = offset + pageable.getPageSize(); int fromIndex = totalCount >= offset ? offset : -1; int toIndex = totalCount >= end ? end : totalCount; if (fromIndex == -1 || fromIndex > toIndex) { return Lists.newArrayList(); } return unSystemJobs.subList(fromIndex, toIndex); }  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping SuccessResponseEntity getJobsWithCondition(final HttpServletRequest request, @PathVariable String namespace,
			@RequestParam Map<String, Object> condition, @RequestParam(required = false, defaultValue = "1") int page,
			@RequestParam(required = false, defaultValue = "25") int size); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/counts") SuccessResponseEntity countJobsStatus(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/names") SuccessResponseEntity getJobNames(@PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/sharding/status") SuccessResponseEntity getJobsShardingStatus(@PathVariable String namespace,
			@RequestParam(required = false) List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/groups") SuccessResponseEntity getGroups(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/{jobName}/enable") SuccessResponseEntity enableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobName") @PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/enable") SuccessResponseEntity batchEnableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/{jobName}/disable") SuccessResponseEntity disableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobName") @PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/disable") SuccessResponseEntity batchDisableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @DeleteMapping(value = "/{jobName}") SuccessResponseEntity removeJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobName") @PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @DeleteMapping SuccessResponseEntity batchRemoveJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/preferExecutors") SuccessResponseEntity batchSetPreferExecutors(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames,
			@AuditParam("preferList") @RequestParam String preferList); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/candidateDownStream") SuccessResponseEntity getCandidateDownStream(final HttpServletRequest request,
			@PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/candidateUpStream") SuccessResponseEntity getCandidateUpStream(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/jobs") SuccessResponseEntity createJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace, JobConfig jobConfig); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/{jobNameCopied}/copy") SuccessResponseEntity copyJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNameCopied") @PathVariable String jobNameCopied, JobConfig jobConfig); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/import") SuccessResponseEntity importJobs(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace, @RequestParam("file") MultipartFile file); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @GetMapping(value = "/export") void exportJobs(final HttpServletRequest request, @AuditParam("namespace") @PathVariable String namespace,
			final HttpServletResponse response); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @GetMapping(value = "/exportSelected") void exportSelectedJobs(final HttpServletRequest request, @AuditParam("namespace") @PathVariable String namespace,
			@RequestParam(required = false) List<String> jobList, final HttpServletResponse response); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/arrangeLayout") SuccessResponseEntity getArrangeLayout(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/{jobName}/executors") SuccessResponseEntity getExecutors(final HttpServletRequest request, @PathVariable String namespace,
			@PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/batchSetGroups") SuccessResponseEntity batchSetGroups(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames,
			@AuditParam("oldGroupNames") @RequestParam List<String> oldGroupNames,
			@AuditParam("newGroupNames") @RequestParam List<String> newGroupNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping("/batchRunAtOnce") SuccessResponseEntity batchRunAtOnce(@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); }
JobOverviewController extends AbstractGUIController { protected List getJobSubListByPage(List unSystemJobs, Pageable pageable) { int totalCount = unSystemJobs.size(); int offset = pageable.getOffset(); int end = offset + pageable.getPageSize(); int fromIndex = totalCount >= offset ? offset : -1; int toIndex = totalCount >= end ? end : totalCount; if (fromIndex == -1 || fromIndex > toIndex) { return Lists.newArrayList(); } return unSystemJobs.subList(fromIndex, toIndex); }  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping SuccessResponseEntity getJobsWithCondition(final HttpServletRequest request, @PathVariable String namespace,
			@RequestParam Map<String, Object> condition, @RequestParam(required = false, defaultValue = "1") int page,
			@RequestParam(required = false, defaultValue = "25") int size); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/counts") SuccessResponseEntity countJobsStatus(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/names") SuccessResponseEntity getJobNames(@PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/sharding/status") SuccessResponseEntity getJobsShardingStatus(@PathVariable String namespace,
			@RequestParam(required = false) List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/groups") SuccessResponseEntity getGroups(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/{jobName}/enable") SuccessResponseEntity enableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobName") @PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/enable") SuccessResponseEntity batchEnableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/{jobName}/disable") SuccessResponseEntity disableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobName") @PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/disable") SuccessResponseEntity batchDisableJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @DeleteMapping(value = "/{jobName}") SuccessResponseEntity removeJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobName") @PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @DeleteMapping SuccessResponseEntity batchRemoveJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/preferExecutors") SuccessResponseEntity batchSetPreferExecutors(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames,
			@AuditParam("preferList") @RequestParam String preferList); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/candidateDownStream") SuccessResponseEntity getCandidateDownStream(final HttpServletRequest request,
			@PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/candidateUpStream") SuccessResponseEntity getCandidateUpStream(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/jobs") SuccessResponseEntity createJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace, JobConfig jobConfig); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/{jobNameCopied}/copy") SuccessResponseEntity copyJob(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNameCopied") @PathVariable String jobNameCopied, JobConfig jobConfig); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/import") SuccessResponseEntity importJobs(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace, @RequestParam("file") MultipartFile file); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @GetMapping(value = "/export") void exportJobs(final HttpServletRequest request, @AuditParam("namespace") @PathVariable String namespace,
			final HttpServletResponse response); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @GetMapping(value = "/exportSelected") void exportSelectedJobs(final HttpServletRequest request, @AuditParam("namespace") @PathVariable String namespace,
			@RequestParam(required = false) List<String> jobList, final HttpServletResponse response); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/arrangeLayout") SuccessResponseEntity getArrangeLayout(final HttpServletRequest request, @PathVariable String namespace); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @GetMapping(value = "/{jobName}/executors") SuccessResponseEntity getExecutors(final HttpServletRequest request, @PathVariable String namespace,
			@PathVariable String jobName); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping(value = "/batchSetGroups") SuccessResponseEntity batchSetGroups(final HttpServletRequest request,
			@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames,
			@AuditParam("oldGroupNames") @RequestParam List<String> oldGroupNames,
			@AuditParam("newGroupNames") @RequestParam List<String> newGroupNames); @ApiResponses(value = {@ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class)}) @Audit @PostMapping("/batchRunAtOnce") SuccessResponseEntity batchRunAtOnce(@AuditParam("namespace") @PathVariable String namespace,
			@AuditParam("jobNames") @RequestParam List<String> jobNames);  }