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; /** * Created by dpie on 30/12/2020. */ @RestController class SushiLiteController { private final Logger log = Logger.getLogger(this.getClass()); private final SushiLiteService sushiLiteService; public SushiLiteController(SushiLiteService sushiLiteService) { this.sushiLiteService = sushiLiteService; } @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); } @RequestMapping(value = "/sushilite/r5/status", method = RequestMethod.GET) public String getReportStatus() { log.info("COUNTER Report status request "); return sushiLiteService.displayReportStatus(); } @RequestMapping(value = "/sushilite/r5/reports", method = RequestMethod.GET) public String getReportSupported() { log.info("COUNTER Supported Reports request "); return sushiLiteService.displayReportsSupported(); } @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, @RequestParam(value = "Granularity", defaultValue = "Monthly") String granularity) { log.info("COUNTER PR Report request for repository " + repositoryIdentifier); return sushiLiteService.displayReportPR(repositoryIdentifier, beginDate, endDate, granularity); } @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); } }