1 |
51837
|
tsampikos.
|
package eu.dnetlib.statsapi.controllers;
|
2 |
|
|
|
3 |
|
|
import eu.dnetlib.statsapi.domain.Result;
|
4 |
|
|
import eu.dnetlib.statsapi.repositories.CommunityRepository;
|
5 |
|
|
|
6 |
|
|
import org.apache.log4j.Logger;
|
7 |
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
8 |
53590
|
tsampikos.
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
9 |
51837
|
tsampikos.
|
import org.springframework.web.bind.annotation.PathVariable;
|
10 |
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
11 |
53590
|
tsampikos.
|
import org.springframework.web.bind.annotation.RequestMethod;
|
12 |
51837
|
tsampikos.
|
import org.springframework.web.bind.annotation.RestController;
|
13 |
|
|
|
14 |
|
|
@RestController
|
15 |
53590
|
tsampikos.
|
@CrossOrigin(methods = RequestMethod.GET, origins = "*")
|
16 |
51837
|
tsampikos.
|
public class CommunityController {
|
17 |
|
|
@Autowired
|
18 |
|
|
private CommunityRepository communityRepository;
|
19 |
|
|
|
20 |
|
|
private final Logger log = Logger.getLogger(this.getClass());
|
21 |
|
|
|
22 |
|
|
@RequestMapping(value = "/communities/{community}")
|
23 |
|
|
public Result getCommunity(@PathVariable(value = "community") String community) {
|
24 |
|
|
log.info("request for community: " + community);
|
25 |
|
|
return communityRepository.getCommunity(community);
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
@RequestMapping(value = "/communities/refresh")
|
29 |
|
|
public Result refreshCommunities() {
|
30 |
|
|
log.info("refreshing communities");
|
31 |
|
|
return communityRepository.refreshCommunities();
|
32 |
|
|
}
|
33 |
|
|
}
|