1
|
package eu.dnetlib.statsapi.controllers;
|
2
|
|
3
|
import eu.dnetlib.statsapi.entity.Result;
|
4
|
import eu.dnetlib.statsapi.repos.BaseRepository;
|
5
|
|
6
|
import org.apache.log4j.Logger;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
9
|
import org.springframework.web.bind.annotation.PathVariable;
|
10
|
import org.springframework.web.bind.annotation.RequestMapping;
|
11
|
import org.springframework.web.bind.annotation.RequestMethod;
|
12
|
import org.springframework.web.bind.annotation.RestController;
|
13
|
|
14
|
|
15
|
@RestController
|
16
|
@CrossOrigin(methods = RequestMethod.GET, origins = "*")
|
17
|
public class StatsController {
|
18
|
@Autowired
|
19
|
private BaseRepository repository;
|
20
|
|
21
|
private final Logger log = Logger.getLogger(this.getClass());
|
22
|
|
23
|
@RequestMapping(value = "/numbers/{number}")
|
24
|
public Result getNumber(@PathVariable(value="number") String number) {
|
25
|
log.info("request for number: " + number);
|
26
|
return repository.getNumber(number);
|
27
|
}
|
28
|
|
29
|
@RequestMapping(value = "/funders/{funder}")
|
30
|
public Result getFunder(@PathVariable(value="funder") String funder) {
|
31
|
log.info("request for funder: " + funder);
|
32
|
return repository.getFunder(funder);
|
33
|
}
|
34
|
|
35
|
@RequestMapping(value = "/communities/{community}")
|
36
|
public Result getCommunity(@PathVariable(value="community") String community) {
|
37
|
log.info("request for community: " + community);
|
38
|
return repository.getCommunity(community);
|
39
|
}
|
40
|
|
41
|
@RequestMapping(value = "/communities/refresh")
|
42
|
public Result refreshCommunities() {
|
43
|
log.info("refreshing communities");
|
44
|
return repository.refreshCommunities();
|
45
|
}
|
46
|
|
47
|
}
|