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

94 lines
5.5 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;
2021-02-25 09:10:47 +01:00
import java.util.List;
2020-12-30 14:56:37 +01:00
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-02-22 18:39:27 +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,
// @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,
// @RequestParam(value = "Pretty", defaultValue = "") String pretty) {
// log.info("Sushi Report request: " + reportP + " from " + requestorId);
// log.info("repository identifier: " + repositoryIdentifier + " - item identifier: " + itemIdentifier);
//
// 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,
2021-02-22 18:39:27 +01:00
@RequestParam(value = "RequestorID", defaultValue = "anonymous") String requestorId,
2021-01-06 15:27:29 +01:00
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
2021-01-13 12:01:47 +01:00
@RequestParam(value = "MetricType", defaultValue = "") String metricType,
2021-01-25 09:44:27 +01:00
@RequestParam(value = "DataType", defaultValue = "") String dataType,
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-02-22 18:39:27 +01:00
return sushiLiteService.displayReportPR(requestorId,repositoryIdentifier, beginDate, endDate, metricType, dataType, 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,
2021-02-22 18:39:27 +01:00
@RequestParam(value = "RequestorID", defaultValue = "anonymous") String requestorId,
2021-01-06 15:27:29 +01:00
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
@RequestParam(value = "EndDate", defaultValue = "") String endDate) {
log.info("COUNTER PR_P1 Report request for repository " + repositoryIdentifier);
2021-02-22 18:39:27 +01:00
return sushiLiteService.displayReportPR_P1(requestorId, repositoryIdentifier, beginDate, endDate);
2021-01-06 15:27:29 +01:00
}
2021-02-22 18:39:27 +01:00
@RequestMapping(value = "/sushilite/r5/reports/ir", method = RequestMethod.GET)
public String getReportTR(
2021-01-25 09:44:27 +01:00
@RequestParam(value = "RepositoryIdentifier", defaultValue = "") String repositoryIdentifier,
@RequestParam(value = "ItemIdentifier", defaultValue = "") String itemIdentifier,
2021-02-22 18:39:27 +01:00
@RequestParam(value = "RequestorID", defaultValue = "anonymous") String requestorId,
2021-01-25 09:44:27 +01:00
@RequestParam(value = "BeginDate", defaultValue = "") String beginDate,
@RequestParam(value = "EndDate", defaultValue = "") String endDate,
2021-02-25 09:10:47 +01:00
@RequestParam(value = "MetricType", defaultValue = "") List<String> metricType,
2021-01-25 09:44:27 +01:00
@RequestParam(value = "DataType", defaultValue = "") String dataType,
@RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) {
2021-02-22 18:39:27 +01:00
log.info("COUNTER TR Report request for repository " + repositoryIdentifier +" and for item "+ itemIdentifier);
return sushiLiteService.displayReportIR(requestorId, repositoryIdentifier, itemIdentifier, beginDate, endDate, metricType, dataType, granularity);
2021-01-25 09:44:27 +01:00
}
2020-12-30 14:56:37 +01:00
}