Revision 57891
Added by Ioannis Diplas over 4 years ago
BrokerServiceImpl.java | ||
---|---|---|
4 | 4 |
import com.fasterxml.jackson.databind.ObjectMapper; |
5 | 5 |
import eu.dnetlib.domain.data.Repository; |
6 | 6 |
import eu.dnetlib.repo.manager.domain.BrokerException; |
7 |
import eu.dnetlib.repo.manager.domain.RepositorySnippet; |
|
7 | 8 |
import eu.dnetlib.repo.manager.domain.Term; |
8 | 9 |
import eu.dnetlib.repo.manager.domain.Tuple; |
9 | 10 |
import eu.dnetlib.repo.manager.domain.broker.*; |
... | ... | |
81 | 82 |
long start = System.currentTimeMillis(); |
82 | 83 |
DatasourcesBroker ret = new DatasourcesBroker(); |
83 | 84 |
try { |
84 |
ret.setDatasourcesOfUser(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
|
85 |
ret.setDatasourcesOfUser(getDatasourcesOfUserType(repoAPI.getRepositoriesSnippetOfUser(user,"0","100")));
|
|
85 | 86 |
//TODO fix bug when values are true |
86 |
if (Boolean.parseBoolean(includeShared)) { |
|
87 |
List<String> sharedDatasourceIds = new ArrayList<String>(); |
|
88 |
ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds))); |
|
89 |
} |
|
87 |
// if (Boolean.parseBoolean(includeShared)) {
|
|
88 |
// List<String> sharedDatasourceIds = new ArrayList<String>();
|
|
89 |
// ret.setSharedDatasources(getDatasourcesOfUserType(getRepositoriesByIds(sharedDatasourceIds)));
|
|
90 |
// }
|
|
90 | 91 |
|
91 |
if (Boolean.parseBoolean(includeByOthers)) { |
|
92 |
ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user))); |
|
93 |
} |
|
94 |
} catch (BrokerException e) { |
|
92 |
// if (Boolean.parseBoolean(includeByOthers)) {
|
|
93 |
// ret.setDatasourcesOfOthers(getDatasourcesOfUserType(getRepositoriesOfUser(user)));
|
|
94 |
// }
|
|
95 |
} catch (BrokerException | IOException e) {
|
|
95 | 96 |
LOGGER.debug("Exception on getDatasourcesOfUser" , e); |
96 | 97 |
emailUtils.reportException(e); |
97 | 98 |
} |
... | ... | |
160 | 161 |
} |
161 | 162 |
|
162 | 163 |
|
163 |
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<Repository> repositories) throws BrokerException { |
|
164 |
|
|
164 |
private List<Tuple<BrowseEntry, String>> getDatasourcesOfUserType(List<RepositorySnippet> repositories) throws BrokerException {
|
|
165 |
long start = System.currentTimeMillis(); |
|
165 | 166 |
List<Tuple<BrowseEntry, String>> entries = new ArrayList<>(); |
166 |
for (Repository repo : repositories) { |
|
167 |
for (RepositorySnippet repo : repositories) {
|
|
167 | 168 |
BrowseEntry temp = new BrowseEntry(); |
168 |
temp.setValue(repo.getOfficialName());
|
|
169 |
temp.setValue(repo.getOfficialname());
|
|
169 | 170 |
temp.setSize(new Long(0)); |
170 |
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialName())) {
|
|
171 |
for (BrowseEntry e : getTopicsForDatasource(repo.getOfficialname())) {
|
|
171 | 172 |
temp.setSize(temp.getSize() + e.getSize()); |
172 | 173 |
} |
173 | 174 |
Tuple<BrowseEntry, String> tup = new Tuple<>(temp, repo.getLogoUrl()); |
... | ... | |
181 | 182 |
return (int) (e2.getFirst().getSize().longValue() - e1.getFirst().getSize().longValue()); |
182 | 183 |
} |
183 | 184 |
}); |
185 |
long stop = System.currentTimeMillis(); |
|
186 |
System.out.println("getDatasourcesOfUserType returned in " + (stop-start) + "ms "); |
|
184 | 187 |
|
185 | 188 |
return entries; |
186 | 189 |
} |
Also available in: Unified diff
Using RepositorySnippet for getDatasourcesOfUser