1
|
package eu.dnetlib.repo.manager.controllers;
|
2
|
|
3
|
import eu.dnetlib.repo.manager.domain.BrokerSummary;
|
4
|
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
5
|
import eu.dnetlib.repo.manager.domain.UsageSummary;
|
6
|
import eu.dnetlib.repo.manager.service.BrokerService;
|
7
|
import eu.dnetlib.repo.manager.service.DashboardService;
|
8
|
import eu.dnetlib.repo.manager.service.PiWikService;
|
9
|
import eu.dnetlib.repo.manager.service.RepositoryService;
|
10
|
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
11
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
12
|
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
13
|
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
14
|
import io.swagger.annotations.Api;
|
15
|
import org.json.JSONException;
|
16
|
import org.springframework.beans.factory.annotation.Autowired;
|
17
|
import org.springframework.http.MediaType;
|
18
|
import org.springframework.security.access.prepost.PreAuthorize;
|
19
|
import org.springframework.web.bind.annotation.*;
|
20
|
|
21
|
import java.util.List;
|
22
|
|
23
|
@RestController
|
24
|
@RequestMapping(value = "/dashboard")
|
25
|
@Api(description = "Dashboard API", tags = {"dashboard"})
|
26
|
public class DashboardController {
|
27
|
|
28
|
@Autowired
|
29
|
private DashboardService dashboardService;
|
30
|
|
31
|
@Autowired
|
32
|
private RepositoryService repositoryService;
|
33
|
|
34
|
@Autowired
|
35
|
private BrokerService brokerService;
|
36
|
|
37
|
@Autowired
|
38
|
private PiWikService piWikService;
|
39
|
|
40
|
@RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
|
41
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
42
|
@ResponseBody
|
43
|
@PreAuthorize("hasRole('ROLE_USER')")
|
44
|
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
45
|
@PathVariable("page") String page,
|
46
|
@PathVariable("size") String size) throws JSONException {
|
47
|
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
|
48
|
}
|
49
|
|
50
|
@RequestMapping(value = "/collectionMonitorSummary/{repoId}" , method = RequestMethod.GET,
|
51
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
52
|
@ResponseBody
|
53
|
@PreAuthorize("hasRole('ROLE_USER')")
|
54
|
public List<AggregationDetails> getCollectionMonitorSummary(
|
55
|
@PathVariable("repoId") String repoId,
|
56
|
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
57
|
return repositoryService.getRepositoryAggregations(repoId,size);
|
58
|
}
|
59
|
|
60
|
@RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET,
|
61
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
62
|
@ResponseBody
|
63
|
@PreAuthorize("hasRole('ROLE_USER')")
|
64
|
public UsageSummary getUsageSummary(
|
65
|
@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
66
|
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
|
67
|
}
|
68
|
|
69
|
@RequestMapping(value = "/brokerSummary/{email}/{ds_name}" , method = RequestMethod.GET,
|
70
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
71
|
@ResponseBody
|
72
|
@PreAuthorize("hasRole('ROLE_USER')")
|
73
|
public BrokerSummary getBrokerSummary(
|
74
|
@PathVariable("email") String email,
|
75
|
@PathVariable("ds_name") String datasourceName) throws BrokerException {
|
76
|
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(email), brokerService.getTopicsForDatasource(datasourceName));
|
77
|
}
|
78
|
|
79
|
|
80
|
|
81
|
|
82
|
}
|