From ca5651e6303e1e3b6e129bf48aeb9c3ab8b0b6f9 Mon Sep 17 00:00:00 2001 From: "ioannis.diplas" Date: Fri, 27 Sep 2019 11:29:40 +0000 Subject: [PATCH] Pushing fixes on summaries --- .../controllers/DashboardController.java | 24 ++++++++++-- .../controllers/RepositoryController.java | 2 +- .../domain/CollectionMonitorSummary.java | 37 +++++++++++++++++++ .../repo/manager/service/BrokerService.java | 2 + .../manager/service/BrokerServiceImpl.java | 7 ++++ .../manager/service/DashboardServiceImpl.java | 2 +- .../manager/service/RepositoryService.java | 2 +- .../service/RepositoryServiceImpl.java | 4 +- 8 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java diff --git a/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java b/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java index 2a948b6..8ba1032 100644 --- a/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java +++ b/src/main/java/eu/dnetlib/repo/manager/controllers/DashboardController.java @@ -1,6 +1,7 @@ package eu.dnetlib.repo.manager.controllers; import eu.dnetlib.repo.manager.domain.BrokerSummary; +import eu.dnetlib.repo.manager.domain.CollectionMonitorSummary; import eu.dnetlib.repo.manager.domain.RepositorySummaryInfo; import eu.dnetlib.repo.manager.domain.UsageSummary; import eu.dnetlib.repo.manager.service.BrokerService; @@ -51,10 +52,26 @@ public class DashboardController { produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody @PreAuthorize("hasRole('ROLE_USER')") - public List getCollectionMonitorSummary( + public CollectionMonitorSummary getCollectionMonitorSummary( @PathVariable("repoId") String repoId, @RequestParam(name = "size", required = false, defaultValue = "20") int size) throws JSONException { - return repositoryService.getRepositoryAggregations(repoId,size); + + List aggregationDetails = repositoryService.getRepositoryAggregations(repoId,0,size); + CollectionMonitorSummary collectionMonitorSummary = new CollectionMonitorSummary(); + collectionMonitorSummary.setAggregationDetails(aggregationDetails); + size=0; + do { + aggregationDetails = repositoryService.getRepositoryAggregations(repoId,size,size+50); + for(AggregationDetails aggregationDetail : aggregationDetails){ + if(aggregationDetail.getIndexedVersion()){ + collectionMonitorSummary.setLastIndexedVersion(aggregationDetail); + break; + } + } + size+=30; + }while (aggregationDetails.size() != 0 && collectionMonitorSummary.getLastIndexedVersion()==null); + + return collectionMonitorSummary; } @RequestMapping(value = "/usageSummary/{repoId}" , method = RequestMethod.GET, @@ -62,7 +79,8 @@ public class DashboardController { @ResponseBody @PreAuthorize("hasRole('ROLE_USER')") public UsageSummary getUsageSummary( - @PathVariable("repoId") String repoId) throws RepositoryServiceException { + @PathVariable("repoId") String repoId + ) throws RepositoryServiceException { return new UsageSummary(repositoryService.getMetricsInfoForRepository(repoId), piWikService.getPiwikSiteForRepo(repoId)); } diff --git a/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java b/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java index 41568f0..0312992 100644 --- a/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java +++ b/src/main/java/eu/dnetlib/repo/manager/controllers/RepositoryController.java @@ -80,7 +80,7 @@ public class RepositoryController { produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public List getRepositoryAggregations(@PathVariable("id") String id) throws JSONException { - return repositoryService.getRepositoryAggregations(id,20); + return repositoryService.getRepositoryAggregations(id,0,20); } @RequestMapping(value = "/getRepositoryAggregationsByYear/{id}", method = RequestMethod.GET, diff --git a/src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java b/src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java new file mode 100644 index 0000000..7dffb8e --- /dev/null +++ b/src/main/java/eu/dnetlib/repo/manager/domain/CollectionMonitorSummary.java @@ -0,0 +1,37 @@ +package eu.dnetlib.repo.manager.domain; + +import eu.dnetlib.repo.manager.shared.AggregationDetails; +import eu.dnetlib.repo.manager.shared.broker.BrowseEntry; +import eu.dnetlib.repo.manager.shared.broker.SimpleSubscriptionDesc; + +import java.util.List; +import java.util.Map; + +public class CollectionMonitorSummary { + private List aggregationDetails; + + private AggregationDetails lastIndexedVersion; + + public CollectionMonitorSummary(){} + + public CollectionMonitorSummary(List aggregationDetails, AggregationDetails lastIndexedVersion) { + this.aggregationDetails = aggregationDetails; + this.lastIndexedVersion = lastIndexedVersion; + } + + public List getAggregationDetails() { + return aggregationDetails; + } + + public void setAggregationDetails(List aggregationDetails) { + this.aggregationDetails = aggregationDetails; + } + + public AggregationDetails getLastIndexedVersion() { + return lastIndexedVersion; + } + + public void setLastIndexedVersion(AggregationDetails lastIndexedVersion) { + this.lastIndexedVersion = lastIndexedVersion; + } +} diff --git a/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java b/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java index 3a8c236..c8e149c 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/BrokerService.java @@ -34,6 +34,8 @@ public interface BrokerService { Map> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException; + Map> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException; + Subscription subscribe(OpenaireSubscription obj) throws BrokerException; ResponseEntity unsubscribe(String subscriptionId) throws BrokerException; diff --git a/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java index 5a82b3c..4b92d3f 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java @@ -259,6 +259,13 @@ public class BrokerServiceImpl implements BrokerService { return resp.getBody(); } + @Override + public Map> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException { + Map> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail); + + return null; + } + @Override public Subscription subscribe(OpenaireSubscription obj) throws BrokerException { final String service = "/subscribe"; diff --git a/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java index 07cdf14..4307f6f 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/DashboardServiceImpl.java @@ -49,7 +49,7 @@ public class DashboardServiceImpl implements DashboardService { repositorySummaryInfo.setLogoURL(repository.getLogoUrl()); //TODO getRepositoryAggregations returns only the 20 more recent items. Is it positive that we will find an indexed version there? - List aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),20); + List aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),0,20); for(AggregationDetails aggregationDetails: aggregationDetailsList) { if(aggregationDetails.getIndexedVersion()) { repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords()); diff --git a/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java b/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java index ee3c107..c57fcd6 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/RepositoryService.java @@ -25,7 +25,7 @@ public interface RepositoryService { Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException; - List getRepositoryAggregations(String id, int size) throws JSONException; + List getRepositoryAggregations(String id, int from, int size) throws JSONException; Map> getRepositoryAggregationsByYear(String id) throws JSONException; diff --git a/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java b/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java index e62aa77..12544d7 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/RepositoryServiceImpl.java @@ -290,10 +290,10 @@ public class RepositoryServiceImpl implements RepositoryService { @Override - public List getRepositoryAggregations(String id, int size) throws JSONException { + public List getRepositoryAggregations(String id, int from, int size) throws JSONException { LOGGER.debug("Retreiving aggregations for repository with id : " + id ); - UriComponents uriComponents = searchDatasource("0","100"); + UriComponents uriComponents = searchDatasource(from+"",size+""); RequestFilter requestFilter = new RequestFilter(); requestFilter.setId(id);