1
|
package eu.dnetlib.usagestats.controllers;
|
2
|
|
3
|
import eu.dnetlib.usagestats.portal.TotalStats;
|
4
|
import eu.dnetlib.usagestats.portal.UsageStats;
|
5
|
|
6
|
import eu.dnetlib.usagestats.services.UsageStatsService;
|
7
|
import org.apache.log4j.Logger;
|
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 UsageStatsController {
|
18
|
|
19
|
private final UsageStatsService usageStatsService;
|
20
|
|
21
|
private final Logger log = Logger.getLogger(this.getClass());
|
22
|
|
23
|
public UsageStatsController(UsageStatsService usageStatsService) {
|
24
|
this.usageStatsService = usageStatsService;
|
25
|
}
|
26
|
|
27
|
@RequestMapping(value = "/datasources/{datasourceId}/clicks")
|
28
|
public UsageStats getDatasourceClicks(@PathVariable(value = "datasourceId") String datasourceId) {
|
29
|
log.info("stats request for datasource: " + datasourceId);
|
30
|
return usageStatsService.getDatasourceClicks(datasourceId);
|
31
|
}
|
32
|
|
33
|
@RequestMapping(value = "/projects/{projectId}/clicks")
|
34
|
public UsageStats getProjectClicks(@PathVariable(value = "projectId") String projectId) {
|
35
|
log.info("stats request for project: " + projectId);
|
36
|
return usageStatsService.getProjectClicks(projectId);
|
37
|
}
|
38
|
|
39
|
/*
|
40
|
@RequestMapping(value = "/organizations/{organizationId}/clicks")
|
41
|
public UsageStats getOrganizationClicks(@PathVariable(value = "organizationId") String organizationId) {
|
42
|
log.info("stats request for organization: " + organizationId);
|
43
|
return usageStatsService.getOrganizationClicks(organizationId);
|
44
|
}
|
45
|
*/
|
46
|
|
47
|
@RequestMapping(value = "/results/{resultId}/clicks")
|
48
|
public UsageStats getResultClicks(@PathVariable(value = "resultId") String resultId) {
|
49
|
log.info("stats request for result: " + resultId);
|
50
|
return usageStatsService.getResultClicks(resultId);
|
51
|
}
|
52
|
@RequestMapping(value = "/totals")
|
53
|
public TotalStats getTotalStats() {
|
54
|
log.info("total stats request");
|
55
|
return usageStatsService.getTotalStats();
|
56
|
}
|
57
|
}
|