1
|
package eu.dnetlib.repo.manager.controllers;
|
2
|
|
3
|
import eu.dnetlib.repo.manager.service.SushiliteApiImpl;
|
4
|
import eu.dnetlib.usagestats.sushilite.domain.ReportItem;
|
5
|
import eu.dnetlib.usagestats.sushilite.domain.ReportResponseWrapper;
|
6
|
import io.swagger.annotations.Api;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
import org.springframework.beans.factory.annotation.Value;
|
9
|
import org.springframework.core.ParameterizedTypeReference;
|
10
|
import org.springframework.http.HttpMethod;
|
11
|
import org.springframework.http.MediaType;
|
12
|
import org.springframework.http.ResponseEntity;
|
13
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
14
|
import org.springframework.security.access.prepost.PreAuthorize;
|
15
|
import org.springframework.stereotype.Component;
|
16
|
import org.springframework.web.bind.annotation.*;
|
17
|
import org.springframework.web.client.RestClientException;
|
18
|
import org.springframework.web.client.RestTemplate;
|
19
|
import org.springframework.web.util.UriComponentsBuilder;
|
20
|
|
21
|
import java.util.ArrayList;
|
22
|
import java.util.List;
|
23
|
|
24
|
@RestController
|
25
|
@RequestMapping(value = "/sushilite")
|
26
|
@Api(description = "Sushi-Lite API", tags = {"sushilite"})
|
27
|
public class SushiliteController {
|
28
|
|
29
|
|
30
|
@Autowired
|
31
|
SushiliteApiImpl sushiliteApi;
|
32
|
|
33
|
@RequestMapping(value = "/getReportResults/{page}/{pageSize}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
|
34
|
@ResponseBody
|
35
|
@PreAuthorize("hasRole('ROLE_USER')")
|
36
|
public ReportResponseWrapper getReportResults(@PathVariable("page") String page,
|
37
|
@PathVariable("pageSize") String pageSize,
|
38
|
@RequestParam(value = "Report") String Report,
|
39
|
@RequestParam(value = "Release",defaultValue="4") String Release,
|
40
|
@RequestParam(value = "RequestorID",required=false,defaultValue="anonymous") String RequestorID,
|
41
|
@RequestParam(value = "BeginDate",required=false,defaultValue="") String BeginDate,
|
42
|
@RequestParam(value = "EndDate",required=false,defaultValue="") String EndDate,
|
43
|
@RequestParam(value = "RepositoryIdentifier") String RepositoryIdentifier,
|
44
|
@RequestParam(value = "ItemIdentifier",required=false,defaultValue="") String ItemIdentifier,
|
45
|
@RequestParam(value = "ItemDataType",required=false,defaultValue="") String ItemDataType,
|
46
|
@RequestParam(value = "Granularity") String Granularity,
|
47
|
@RequestParam(value = "Pretty",required=false,defaultValue="") String Pretty) {
|
48
|
|
49
|
return sushiliteApi.getReportResults(page, pageSize, Report, Release, RequestorID, BeginDate, EndDate, RepositoryIdentifier, ItemIdentifier, ItemDataType, Granularity, Pretty);
|
50
|
}
|
51
|
|
52
|
}
|