Project

General

Profile

« Previous | Next » 

Revision 57155

Implementing summaries for collection, usage and broker

View differences:

modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java
25 25

  
26 26
    Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
27 27

  
28
    List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException;
28
    List<AggregationDetails> getRepositoryAggregations(String id, int size) throws JSONException;
29 29

  
30 30
    Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;
31 31

  
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java
290 290

  
291 291

  
292 292
    @Override
293
    public List<AggregationDetails> getRepositoryAggregations(String id) throws JSONException {
293
    public List<AggregationDetails> getRepositoryAggregations(String id, int size) throws JSONException {
294 294

  
295 295
        LOGGER.debug("Retreiving aggregations for repository with id : " + id );
296 296
        UriComponents uriComponents = searchDatasource("0","100");
......
308 308
            aggregationHistory.addAll(Converter.getAggregationHistoryFromJson(repository.getJSONArray("datasourceInfo").getJSONObject(0)));
309 309
            return aggregationHistory.size() == 0? aggregationHistory : aggregationHistory.stream()
310 310
                                                    .sorted(Comparator.comparing(AggregationDetails::getDate).reversed())
311
                                                    .limit(20)
311
                                                    .limit(size)
312 312
                                                    .collect(Collectors.toList());
313 313
        } catch (JSONException e) {
314 314
            LOGGER.debug("Exception on getRepositoryAggregations" , e);
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/EmailUtilsImpl.java
238 238
                    repository.getDatasourceType() + "[" + repository.getEnglishName() + "]";
239 239

  
240 240
//            String message = "Dear " + ((OIDCAuthenticationToken) authentication).getUserInfo().getName() + ",\n" +
241
            String message = "Dear user,\n" +
241
            String message = "Dear "+SecurityContextHolder.getContext().getAuthentication().getName()+",\n" +
242 242
                    "\n" +
243 243
                    "We received a request to register the " + repository.getDatasourceType() + "[" + repository.getEnglishName() + "]" +
244 244
                    " to the OpenAIRE compliant list of content providers. " +
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java
49 49
                    repositorySummaryInfo.setLogoURL(repository.getLogoUrl());
50 50

  
51 51
                    //TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there?
52
                    List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId());
52
                    List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),20);
53 53
                    for(AggregationDetails aggregationDetails: aggregationDetailsList) {
54 54
                        if(aggregationDetails.getIndexedVersion()) {
55 55
                            repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java
80 80
            produces = MediaType.APPLICATION_JSON_VALUE)
81 81
    @ResponseBody
82 82
    public List<AggregationDetails> getRepositoryAggregations(@PathVariable("id") String id) throws JSONException {
83
        return repositoryService.getRepositoryAggregations(id);
83
        return repositoryService.getRepositoryAggregations(id,20);
84 84
    }
85 85

  
86 86
    @RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET,
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java
1 1
package eu.dnetlib.repo.manager.controllers;
2 2

  
3
import eu.dnetlib.repo.manager.domain.BrokerSummary;
3 4
import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo;
5
import eu.dnetlib.repo.manager.service.BrokerService;
4 6
import eu.dnetlib.repo.manager.service.DashboardService;
7
import eu.dnetlib.repo.manager.service.PiWikService;
8
import eu.dnetlib.repo.manager.service.RepositoryService;
9
import eu.dnetlib.repo.manager.shared.AggregationDetails;
10
import eu.dnetlib.repo.manager.shared.BrokerException;
11
import eu.dnetlib.repo.manager.shared.MetricsInfo;
12
import eu.dnetlib.repo.manager.shared.RepositoryServiceException;
5 13
import io.swagger.annotations.Api;
6 14
import org.json.JSONException;
7 15
import org.springframework.beans.factory.annotation.Autowired;
......
19 27
    @Autowired
20 28
    private DashboardService dashboardService;
21 29

  
30
    @Autowired
31
    private RepositoryService repositoryService;
32

  
33
    @Autowired
34
    private BrokerService brokerService;
35

  
22 36
    @RequestMapping(value = "/getRepositoriesSummary/{userEmail}/{page}/{size}" , method = RequestMethod.GET,
23 37
            produces = MediaType.APPLICATION_JSON_VALUE)
24 38
    @ResponseBody
......
28 42
                                                                  @PathVariable("size") String size) throws JSONException {
29 43
        return dashboardService.getRepositoriesSummaryInfo(userEmail, page, size);
30 44
    }
45

  
46
    @RequestMapping(value = "/collectionMonitorSummary/{repoId}" , method = RequestMethod.GET,
47
            produces = MediaType.APPLICATION_JSON_VALUE)
48
    @ResponseBody
49
    @PreAuthorize("hasRole('ROLE_USER')")
50
    public List<AggregationDetails> getCollectionMonitorSummary(
51
            @PathVariable("repoId") String repoId,
52
            @RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException {
53
        return repositoryService.getRepositoryAggregations(repoId,size);
54
    }
55

  
56
    @RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET,
57
            produces = MediaType.APPLICATION_JSON_VALUE)
58
    @ResponseBody
59
    @PreAuthorize("hasRole('ROLE_USER')")
60
    public MetricsInfo getUsageSummary(
61
            @PathVariable("repoId") String repoId) throws RepositoryServiceException {
62
        return repositoryService.getMetricsInfoForRepository(repoId);
63
    }
64

  
65
    @RequestMapping(value = "/brokerSummary/{email}/{ds_name}" , method = RequestMethod.GET,
66
            produces = MediaType.APPLICATION_JSON_VALUE)
67
    @ResponseBody
68
    @PreAuthorize("hasRole('ROLE_USER')")
69
    public BrokerSummary getBrokerSummary(
70
            @PathVariable("email") String email,
71
            @PathVariable("ds_name") String datasourceName) throws BrokerException {
72
        return new BrokerSummary(brokerService.getSimpleSubscriptionsOfUser(email), brokerService.getTopicsForDatasource(datasourceName));
73
    }
74

  
75

  
76

  
77

  
31 78
}
modules/uoa-repository-manager-service/trunk/src/main/java/eu/dnetlib/repo/manager/domain/BrokerSummary.java
1
package eu.dnetlib.repo.manager.domain;
2

  
3
import eu.dnetlib.repo.manager.shared.broker.BrowseEntry;
4
import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc;
5

  
6
import java.util.List;
7
import java.util.Map;
8

  
9
public class BrokerSummary {
10
    private Map<String, List<SimpleSubscriptionDesc>> userSubs;
11

  
12
    private List<BrowseEntry> topicsForDatasource;
13

  
14
    public BrokerSummary(){}
15

  
16
    public BrokerSummary(Map<String, List<SimpleSubscriptionDesc>> userSubs, List<BrowseEntry> topicsForDatasource) {
17
        this.userSubs = userSubs;
18
        this.topicsForDatasource = topicsForDatasource;
19
    }
20

  
21
    public Map<String, List<SimpleSubscriptionDesc>> getUserSubs() {
22
        return userSubs;
23
    }
24

  
25
    public void setUserSubs(Map<String, List<SimpleSubscriptionDesc>> userSubs) {
26
        this.userSubs = userSubs;
27
    }
28

  
29
    public List<BrowseEntry> getTopicsForDatasource() {
30
        return topicsForDatasource;
31
    }
32

  
33
    public void setTopicsForDatasource(List<BrowseEntry> topicsForDatasource) {
34
        this.topicsForDatasource = topicsForDatasource;
35
    }
36
}

Also available in: Unified diff