83 lines
3.5 KiB
Java
83 lines
3.5 KiB
Java
package eu.dnetlib.repo.manager.controllers;
|
|
|
|
import eu.dnetlib.repo.manager.domain.BrokerSummary;
|
|
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
|
|
import eu.dnetlib.repo.manager.domain.UsageSummary;
|
|
import eu.dnetlib.repo.manager.service.BrokerService;
|
|
import eu.dnetlib.repo.manager.service.DashboardService;
|
|
import eu.dnetlib.repo.manager.service.PiWikService;
|
|
import eu.dnetlib.repo.manager.service.RepositoryService;
|
|
import eu.dnetlib.repo.manager.shared.AggregationDetails;
|
|
import eu.dnetlib.repo.manager.shared.BrokerException;
|
|
import eu.dnetlib.repo.manager.shared.MetricsInfo;
|
|
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
|
|
import io.swagger.annotations.Api;
|
|
import org.json.JSONException;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.MediaType;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import java.util.List;
|
|
|
|
@RestController
|
|
@RequestMapping(value = "/dashboard")
|
|
@Api(description = "Dashboard API", tags = {"dashboard"})
|
|
public class DashboardController {
|
|
|
|
@Autowired
|
|
private DashboardService dashboardService;
|
|
|
|
@Autowired
|
|
private RepositoryService repositoryService;
|
|
|
|
@Autowired
|
|
private BrokerService brokerService;
|
|
|
|
@Autowired
|
|
private PiWikService piWikService;
|
|
|
|
@RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
@PreAuthorize("hasRole('ROLE_USER')")
|
|
public List<RepositorySummaryInfo> getRepositoriesSummaryInfo(@PathVariable("userEmail") String userEmail,
|
|
@PathVariable("page") String page,
|
|
@PathVariable("size") String size) throws JSONException {
|
|
return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
|
|
}
|
|
|
|
@RequestMapping(value = "/collectionMonitorSummary/{repoId}" , method = RequestMethod.GET,
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
@PreAuthorize("hasRole('ROLE_USER')")
|
|
public List<AggregationDetails> getCollectionMonitorSummary(
|
|
@PathVariable("repoId") String repoId,
|
|
@RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
|
|
return repositoryService.getRepositoryAggregations(repoId,size);
|
|
}
|
|
|
|
@RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET,
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
@PreAuthorize("hasRole('ROLE_USER')")
|
|
public UsageSummary getUsageSummary(
|
|
@PathVariable("repoId") String repoId) throws RepositoryServiceException {
|
|
return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId));
|
|
}
|
|
|
|
@RequestMapping(value = "/brokerSummary/{email}/{ds_name}" , method = RequestMethod.GET,
|
|
produces = MediaType.APPLICATION_JSON_VALUE)
|
|
@ResponseBody
|
|
@PreAuthorize("hasRole('ROLE_USER')")
|
|
public BrokerSummary getBrokerSummary(
|
|
@PathVariable("email") String email,
|
|
@PathVariable("ds_name") String datasourceName) throws BrokerException {
|
|
return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(email), brokerService.getTopicsForDatasource(datasourceName));
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|