From 763285fdacc6e7f7e6c6254d28e73cc6e15dee07 Mon Sep 17 00:00:00 2001 From: "ioannis.diplas" Date: Mon, 16 Dec 2019 12:43:08 +0000 Subject: [PATCH] Using RepositorySnippet for getDatasourcesOfUser --- .../manager/domain/RepositorySnippet.java | 18 +++++++++++ .../manager/service/BrokerServiceImpl.java | 31 ++++++++++--------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java b/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java index de3dafa..2d7d17d 100644 --- a/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java +++ b/src/main/java/eu/dnetlib/repo/manager/domain/RepositorySnippet.java @@ -13,6 +13,8 @@ public class RepositorySnippet { private String registeredby; private Organization[] organizations; private String registrationdate; + private String logoUrl; + private String description; private PiwikInfo piwikInfo; @@ -90,4 +92,20 @@ public class RepositorySnippet { public void setPiwikInfo(PiwikInfo piwikInfo) { this.piwikInfo = piwikInfo; } + + public String getLogoUrl() { + return logoUrl; + } + + public void setLogoUrl(String logoUrl) { + this.logoUrl = logoUrl; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } } 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 a60ab1f..6ba8f94 100644 --- a/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java +++ b/src/main/java/eu/dnetlib/repo/manager/service/BrokerServiceImpl.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.domain.data.Repository; import eu.dnetlib.repo.manager.domain.BrokerException; +import eu.dnetlib.repo.manager.domain.RepositorySnippet; import eu.dnetlib.repo.manager.domain.Term; import eu.dnetlib.repo.manager.domain.Tuple; import eu.dnetlib.repo.manager.domain.broker.*; @@ -81,17 +82,17 @@ public class BrokerServiceImpl implements BrokerService { long start = System.currentTimeMillis(); DatasourcesBroker ret = new DatasourcesBroker(); try { - ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user))); + ret.setDatasourcesOfUser(getDatasourcesOfUserType(repoAPI.getRepositoriesSnippetOfUser(user,"0","100"))); //TODO fix bug when values are true - if (Boolean.parseBoolean(includeShared)) { - List sharedDatasourceIds = new ArrayList(); - ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds))); - } +// if (Boolean.parseBoolean(includeShared)) { +// List sharedDatasourceIds = new ArrayList(); +// ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds))); +// } - if (Boolean.parseBoolean(includeByOthers)) { - ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user))); - } - } catch (BrokerException e) { +// if (Boolean.parseBoolean(includeByOthers)) { +// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user))); +// } + } catch (BrokerException | IOException e) { LOGGER.debug("Exception on getDatasourcesOfUser" , e); emailUtils.reportException(e); } @@ -160,14 +161,14 @@ public class BrokerServiceImpl implements BrokerService { } - private List> getDatasourcesOfUserType(List repositories) throws BrokerException { - + private List> getDatasourcesOfUserType(List repositories) throws BrokerException { + long start = System.currentTimeMillis(); List> entries = new ArrayList<>(); - for (Repository repo : repositories) { + for (RepositorySnippet repo : repositories) { BrowseEntry temp = new BrowseEntry(); - temp.setValue(repo.getOfficialName()); + temp.setValue(repo.getOfficialname()); temp.setSize(new Long(0)); - for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) { + for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) { temp.setSize(temp.getSize() + e.getSize()); } Tuple tup = new Tuple<>(temp, repo.getLogoUrl()); @@ -181,6 +182,8 @@ public class BrokerServiceImpl implements BrokerService { return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue()); } }); + long stop = System.currentTimeMillis(); + System.out.println("getDatasourcesOfUserType returned in " + (stop-start) + "ms "); return entries; }