Project: springxd
Issue XD-745: Return the list of Jobs from spring-batch-admin
The current XD JobController that returns a list of jobs has quite a different API signature than what is in spring-batch-admin. To simplify the UI development, a new controller JobAdminController, will be created that lives under the request path /jobs/admin. The goal is to return a the current JSON structure of spring-batch-admin /jobs/ request and make only minimal changes to implementations of controllers as found . See #1 in the Doc (link to json output doc for spring batch). *Implementation Suggestions* There will need to be some SpringMVC setup that will enable the current style of spring-batch-admin controller requests to co-exist with the existing XD Controllers, e.g. the use of .json for json marshalling etc. This may in fact be the bulk of time spend in this first story to integration spring-batch-admin style controllers into XD. A new controller named JobAdminController that in the spring-xd-dirt project in the package org.springframework.xd.dirt.rest. The JobAdminController will not need to follow the same HATEOAS style as the other controllers at this time. The current controller in Spring Batch Admin looks like this {code} @RequestMapping(value = "/jobs", method = RequestMethod.GET) public void jobs(ModelMap model, @RequestParam(defaultValue = "0") int startJob, @RequestParam(defaultValue = "20") int pageSize) { int total = jobService.countJobs(); TableUtils.addPagination(model, total, startJob, pageSize, "Job"); Collection names = jobService.listJobs(startJob, pageSize); List jobs = new ArrayList(); for (String name : names) { int count = 0; try { count = jobService.countJobExecutionsForJob(name); } catch (NoSuchJobException e) { // shouldn't happen } boolean launchable = jobService.isLaunchable(name); boolean incrementable = jobService.isIncrementable(name); jobs.add(new JobInfo(name, count, null, launchable, incrementable)); } model.addAttribute("jobs", jobs); } {code} Something like {code} @RequestMapping(value = "/jobs/admin/jobs", method = RequestMethod.GET) public void jobs(ModelMap model, @RequestParam(defaultValue = "0") int startJob, @RequestParam(defaultValue = "20") int pageSize) { // We do *not* have to query the Spring Batch Admin “JobService�? at this time, but // instead use the JobDeployer to get information about jobs launched by Spring XD Iterable jobDefinitions = dobDeployer.findAll() // copy these over to a List as best as possible, copy name over. // not sure how ‘description’ is getting added to the JSON // pari } {code} *How to verify it works* A sample job needs to be in the modules/job directory. JobCommandTests/AbstractJobIntegrationTest seems to have what is need to stage a job for
Story points: 5