2020-12-30 14:56:37 +01:00
|
|
|
package eu.dnetlib.usagestats.controllers;
|
|
|
|
|
|
|
|
import eu.dnetlib.usagestats.services.SushiLiteService;
|
|
|
|
|
|
|
|
import org.apache.log4j.Logger;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
/**
|
2021-01-05 13:22:12 +01:00
|
|
|
* Created by dpie on 30/12/2020.
|
2020-12-30 14:56:37 +01:00
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
class SushiLiteController {
|
|
|
|
|
|
|
|
private final Logger log = Logger.getLogger(this.getClass());
|
|
|
|
|
|
|
|
private final SushiLiteService sushiLiteService;
|
|
|
|
|
|
|
|
public SushiLiteController(SushiLiteService sushiLiteService) {
|
|
|
|
this.sushiLiteService = sushiLiteService;
|
|
|
|
}
|
|
|
|
|
2021-01-05 13:22:12 +01:00
|
|
|
@RequestMapping(value = "/sushilite/r5/GetReport/", method = RequestMethod.GET)
|
|
|
|
public String getReport(@RequestParam(value = "Report", defaultValue = "") String reportP, @RequestParam(value = "Release", defaultValue = "4") String release, @RequestParam(value = "RequestorID", defaultValue = "anonymous") String requestorId,
|
2020-12-30 14:56:37 +01:00
|
|
|
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate, @RequestParam(value = "EndDate", defaultValue = "") String endDate, @RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
|
|
|
|
@RequestParam(value = "ItemIdentifier", defaultValue = "") String itemIdentifier, @RequestParam(value = "ItemDataType", defaultValue = "") String itemDataType,
|
|
|
|
@RequestParam(value = "hasDOI", defaultValue = "") String hasDoi, @RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity, @RequestParam(value = "Callback", defaultValue = "") String callback,
|
2021-01-05 13:22:12 +01:00
|
|
|
@RequestParam(value = "Pretty", defaultValue = "") String pretty) {
|
2020-12-30 14:56:37 +01:00
|
|
|
log.info("Sushi Report request: " + reportP + " from " + requestorId);
|
|
|
|
log.info("repository identifier: " + repositoryIdentifier + " - item identifier: " + itemIdentifier);
|
|
|
|
|
2021-01-05 13:22:12 +01:00
|
|
|
return sushiLiteService.displayReport(reportP, release, requestorId, beginDate, endDate, repositoryIdentifier, itemIdentifier, itemDataType, hasDoi, granularity, callback, pretty);
|
2020-12-30 14:56:37 +01:00
|
|
|
}
|
|
|
|
|
2021-01-05 13:22:12 +01:00
|
|
|
@RequestMapping(value = "/sushilite/r5/status", method = RequestMethod.GET)
|
|
|
|
public String getReportStatus() {
|
|
|
|
log.info("Sushi Report status request ");
|
|
|
|
return sushiLiteService.displayReportStatus();
|
|
|
|
}
|
2020-12-30 14:56:37 +01:00
|
|
|
|
2021-01-05 13:22:12 +01:00
|
|
|
@RequestMapping(value = "/sushilite/r5/reports", method = RequestMethod.GET)
|
|
|
|
public String getReportSupported() {
|
|
|
|
log.info("Sushi Supported Reports request ");
|
|
|
|
return sushiLiteService.displayReportsSupported();
|
2020-12-30 14:56:37 +01:00
|
|
|
}
|
2021-01-05 13:22:12 +01:00
|
|
|
@RequestMapping(value = "/sushilite/r5/reports/pr", method = RequestMethod.GET)
|
|
|
|
public String getReportPR(@RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
|
2021-01-06 11:34:30 +01:00
|
|
|
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate, @RequestParam(value = "EndDate", defaultValue = "") String endDate,
|
|
|
|
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
|
2021-01-05 13:22:12 +01:00
|
|
|
log.info("Sushi PR Report request for repository "+repositoryIdentifier);
|
2021-01-06 11:34:30 +01:00
|
|
|
return sushiLiteService.displayReportPR(repositoryIdentifier, beginDate, endDate, granularity);
|
2021-01-05 13:22:12 +01:00
|
|
|
}
|
|
|
|
|
2020-12-30 14:56:37 +01:00
|
|
|
}
|