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