Pushing fixes on summaries

This commit is contained in:
Ioannis Diplas 2019-09-27 11:29:40 +00:00
parent 9bc44f8f97
commit ca5651e630
8 changed files with 72 additions and 8 deletions

View File

@ -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<AggregationDetails> 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> 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));
}

View File

@ -80,7 +80,7 @@ public class RepositoryController {
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<AggregationDetails> 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,

View File

@ -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> aggregationDetails;
private AggregationDetails lastIndexedVersion;
public CollectionMonitorSummary(){}
public CollectionMonitorSummary(List<AggregationDetails> aggregationDetails, AggregationDetails lastIndexedVersion) {
this.aggregationDetails = aggregationDetails;
this.lastIndexedVersion = lastIndexedVersion;
}
public List<AggregationDetails> getAggregationDetails() {
return aggregationDetails;
}
public void setAggregationDetails(List<AggregationDetails> aggregationDetails) {
this.aggregationDetails = aggregationDetails;
}
public AggregationDetails getLastIndexedVersion() {
return lastIndexedVersion;
}
public void setLastIndexedVersion(AggregationDetails lastIndexedVersion) {
this.lastIndexedVersion = lastIndexedVersion;
}
}

View File

@ -34,6 +34,8 @@ public interface BrokerService {
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUser(String userEmail) throws BrokerException;
Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException;
Subscription subscribe(OpenaireSubscription obj) throws BrokerException;
ResponseEntity<Object> unsubscribe(String subscriptionId) throws BrokerException;

View File

@ -259,6 +259,13 @@ public class BrokerServiceImpl implements BrokerService {
return resp.getBody();
}
@Override
public Map<String, List<SimpleSubscriptionDesc>> getSimpleSubscriptionsOfUserByRepoId(String userEmail, String repoId) throws BrokerException {
Map<String, List<SimpleSubscriptionDesc>> subscriptionsOfUser = getSimpleSubscriptionsOfUser(userEmail);
return null;
}
@Override
public Subscription subscribe(OpenaireSubscription obj) throws BrokerException {
final String service = "/subscribe";

View File

@ -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<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),20);
List<AggregationDetails> aggregationDetailsList = repositoryService.getRepositoryAggregations(repository.getId(),0,20);
for(AggregationDetails aggregationDetails: aggregationDetailsList) {
if(aggregationDetails.getIndexedVersion()) {
repositorySummaryInfo.setRecordsCollected(aggregationDetails.getNumberOfRecords());

View File

@ -25,7 +25,7 @@ public interface RepositoryService {
Repository getRepositoryById(String id) throws JSONException, ResourceNotFoundException;
List<AggregationDetails> getRepositoryAggregations(String id, int size) throws JSONException;
List<AggregationDetails> getRepositoryAggregations(String id, int from, int size) throws JSONException;
Map<String,List<AggregationDetails>> getRepositoryAggregationsByYear(String id) throws JSONException;

View File

@ -290,10 +290,10 @@ public class RepositoryServiceImpl implements RepositoryService {
@Override
public List<AggregationDetails> getRepositoryAggregations(String id, int size) throws JSONException {
public List<AggregationDetails> 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);