openaire-usage-stats-api-r5/src/main/java/eu/dnetlib/usagestats/controllers/SushiLiteController.java

76 lines
3.9 KiB
Java
Raw Normal View History

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)
2021-01-06 15:27:29 +01:00
public String getReport(
@RequestParam(value = "Report", defaultValue = "") String reportP,
@RequestParam(value = "Release", defaultValue = "4") String release,
@RequestParam(value = "RequestorID", defaultValue = "anonymous") String requestorId,
@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() {
2021-01-06 15:27:29 +01:00
log.info("COUNTER Report status request ");
2021-01-05 13:22:12 +01:00
return sushiLiteService.displayReportStatus();
}
2020-12-30 14:56:37 +01:00
2021-01-06 15:27:29 +01:00
@RequestMapping(value = "/sushilite/r5/reports", method = RequestMethod.GET)
2021-01-05 13:22:12 +01:00
public String getReportSupported() {
2021-01-06 15:27:29 +01:00
log.info("COUNTER Supported Reports request ");
2021-01-05 13:22:12 +01:00
return sushiLiteService.displayReportsSupported();
2020-12-30 14:56:37 +01:00
}
2021-01-06 15:27:29 +01:00
@RequestMapping(value = "/sushilite/r5/reports/pr", method = RequestMethod.GET)
public String getReportPR(
@RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
2021-01-06 11:34:30 +01:00
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
2021-01-06 15:27:29 +01:00
log.info("COUNTER 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
}
2021-01-06 15:27:29 +01:00
@RequestMapping(value = "/sushilite/r5/reports/pr_p1", method = RequestMethod.GET)
public String getReportPR_P1(
@RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
@RequestParam(value = "EndDate", defaultValue = "") String endDate) {
log.info("COUNTER PR_P1 Report request for repository " + repositoryIdentifier);
return sushiLiteService.displayReportPR_P1(repositoryIdentifier, beginDate, endDate);
}
2020-12-30 14:56:37 +01:00
}