1 |
54525
|
panagiotis
|
package eu.dnetlib.repo.manager.controllers;
|
2 |
49236
|
panagiotis
|
|
3 |
|
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
4 |
|
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
5 |
57890
|
ioannis.di
|
import eu.dnetlib.repo.manager.domain.JobsOfUser;
|
6 |
54690
|
panagiotis
|
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
7 |
54525
|
panagiotis
|
import io.swagger.annotations.Api;
|
8 |
50570
|
panagiotis
|
import io.swagger.annotations.ApiParam;
|
9 |
49410
|
panagiotis
|
import org.apache.log4j.Logger;
|
10 |
49362
|
panagiotis
|
import org.json.JSONException;
|
11 |
54525
|
panagiotis
|
import org.springframework.beans.factory.annotation.Autowired;
|
12 |
|
|
import org.springframework.http.MediaType;
|
13 |
51656
|
panagiotis
|
import org.springframework.security.access.prepost.PreAuthorize;
|
14 |
54525
|
panagiotis
|
import org.springframework.web.bind.annotation.*;
|
15 |
50631
|
panagiotis
|
|
16 |
54525
|
panagiotis
|
@RestController
|
17 |
|
|
@RequestMapping(value = "/monitor")
|
18 |
|
|
@Api(description = "Monitor API", tags = {"monitor"})
|
19 |
|
|
public class MonitorController {
|
20 |
49236
|
panagiotis
|
|
21 |
54525
|
panagiotis
|
private static final Logger LOGGER = Logger
|
22 |
|
|
.getLogger(MonitorController.class);
|
23 |
49236
|
panagiotis
|
|
24 |
54525
|
panagiotis
|
@Autowired
|
25 |
56661
|
ioannis.di
|
private MonitorServiceImpl monitorService;
|
26 |
49236
|
panagiotis
|
|
27 |
54525
|
panagiotis
|
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
|
28 |
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
29 |
|
|
@ResponseBody
|
30 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
31 |
50631
|
panagiotis
|
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
32 |
50686
|
panagiotis
|
@RequestParam(value = "jobType", required = false)
|
33 |
|
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
34 |
50631
|
panagiotis
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
35 |
50686
|
panagiotis
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
36 |
50680
|
panagiotis
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
37 |
|
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
38 |
51330
|
panagiotis
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus,
|
39 |
50631
|
panagiotis
|
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
40 |
49236
|
panagiotis
|
|
41 |
54690
|
panagiotis
|
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
42 |
49236
|
panagiotis
|
}
|
43 |
|
|
|
44 |
54525
|
panagiotis
|
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
45 |
|
|
@ResponseBody
|
46 |
51656
|
panagiotis
|
@PreAuthorize("hasRole('ROLE_USER')")
|
47 |
54525
|
panagiotis
|
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
|
48 |
|
|
@RequestBody String jobType,
|
49 |
|
|
@RequestBody String validationStatus) throws JSONException {
|
50 |
54690
|
panagiotis
|
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus);
|
51 |
49236
|
panagiotis
|
}
|
52 |
|
|
|
53 |
54525
|
panagiotis
|
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
54 |
|
|
@ResponseBody
|
55 |
54745
|
panagiotis
|
public StoredJob getJobSummary(@RequestParam String jobId,
|
56 |
|
|
@RequestParam String groupBy) throws JSONException {
|
57 |
54690
|
panagiotis
|
return monitorService.getJobSummary(jobId, groupBy);
|
58 |
49236
|
panagiotis
|
}
|
59 |
|
|
|
60 |
|
|
}
|