61 lines
3.3 KiB
Java
61 lines
3.3 KiB
Java
package eu.dnetlib.repo.manager.controllers;
|
|
|
|
import eu.dnetlib.api.functionality.ValidatorServiceException;
|
|
import eu.dnetlib.domain.functionality.validator.StoredJob;
|
|
import eu.dnetlib.repo.manager.service.MonitorServiceImpl;
|
|
import eu.dnetlib.repo.manager.shared.JobsOfUser;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiParam;
|
|
import org.apache.log4j.Logger;
|
|
import org.json.JSONException;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@RestController
|
|
@RequestMapping(value = "/monitor")
|
|
@Api(description = "Monitor API", tags = {"monitor"})
|
|
public class MonitorController {
|
|
|
|
private static final Logger LOGGER = Logger
|
|
.getLogger(MonitorController.class);
|
|
|
|
@Autowired
|
|
MonitorServiceImpl monitorService;
|
|
|
|
@RequestMapping(value = "/getJobsOfUser" , method = RequestMethod.GET,
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
@PreAuthorize("hasRole('ROLE_USER')")
|
|
public JobsOfUser getJobsOfUser(@RequestParam("user") @ApiParam(value = "User email", required = true) String user,
|
|
@RequestParam(value = "jobType", required = false)
|
|
@ApiParam(value = "Equals to filter job type on validation history page") String jobType,
|
|
@RequestParam("offset") @ApiParam(value = "Page number", required = true) String offset,
|
|
@RequestParam(value = "limit", required = false,defaultValue = "10") @ApiParam(value = "Null value") String limit,
|
|
@RequestParam(value = "dateFrom", required = false) @ApiParam(value = "Null value") String dateFrom,
|
|
@RequestParam(value = "dateTo", required = false) @ApiParam(value = "Null value") String dateTo,
|
|
@RequestParam("validationStatus") @ApiParam(value = "Equals to filter validation jobs", required = false) String validationStatus,
|
|
@RequestParam("includeJobsTotal") @ApiParam(value = "Always true", required = true) String includeJobsTotal) throws JSONException, ValidatorServiceException {
|
|
|
|
return monitorService.getJobsOfUser(user, jobType, offset, limit, dateFrom, dateTo, validationStatus, includeJobsTotal);
|
|
}
|
|
|
|
@RequestMapping(value = "/getJobsOfUserPerValidationStatus" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
@PreAuthorize("hasRole('ROLE_USER')")
|
|
public int getJobsOfUserPerValidationStatus(@RequestBody String user,
|
|
@RequestBody String jobType,
|
|
@RequestBody String validationStatus) throws JSONException {
|
|
return monitorService.getJobsOfUserPerValidationStatus(user, jobType, validationStatus);
|
|
}
|
|
|
|
@RequestMapping(value = "/getJobSummary" , method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
public StoredJob getJobSummary(@RequestParam String jobId,
|
|
@RequestParam String groupBy) throws JSONException {
|
|
return monitorService.getJobSummary(jobId, groupBy);
|
|
}
|
|
|
|
}
|