Revision 49813
Added by Panagiotis Kanakakis over 6 years ago
RepositoryApiImpl.java | ||
---|---|---|
115 | 115 |
int page = 1; |
116 | 116 |
int size = 10; |
117 | 117 |
String countryCode = getCountryCode(country); |
118 |
String filterKey = "UNKNOWN"; |
|
119 |
if(mode.equalsIgnoreCase("opendoar")) { |
|
120 |
filterKey = "openaire____::opendoar"; |
|
121 |
} else if(mode.equalsIgnoreCase("re3data")) { |
|
122 |
filterKey = "openaire____::re3data"; |
|
123 |
} else if(mode.equalsIgnoreCase("jour_aggr")) { |
|
124 |
filterKey = "infrastruct_::openaire"; |
|
125 |
} |
|
118 | 126 |
|
119 |
|
|
120 | 127 |
LOGGER.debug("Country code equals : " + countryCode); |
128 |
LOGGER.debug("Filter mode equals : " + filterKey); |
|
121 | 129 |
UriComponents uriComponents = UriComponentsBuilder |
122 | 130 |
.fromHttpUrl(baseAddress + "/ds/search/country/") |
123 | 131 |
.path("/{page}/{size}/") |
124 |
.queryParam("country",country) |
|
132 |
.queryParam("country",countryCode)
|
|
125 | 133 |
.build().expand(page,size).encode(); |
126 | 134 |
|
127 | 135 |
String rs = restTemplate.getForObject(uriComponents.toUri(), String.class); |
... | ... | |
129 | 137 |
while(!rs.equals("[]")){ |
130 | 138 |
List<Repository> rep = Converter.jsonToRepositoryList(new JSONArray(rs)); |
131 | 139 |
|
132 |
Collection<Repository> repos = this.getRepositoriesByMode(mode,rep);
|
|
133 |
//this.addRepos(repIDs,repos);
|
|
134 |
resultSet.addAll(repos); |
|
140 |
Collection<Repository> repos = this.getRepositoriesByMode(filterKey,rep);
|
|
141 |
this.addRepos(resultSet,repos);
|
|
142 |
//resultSet.addAll(repos);
|
|
135 | 143 |
|
136 | 144 |
page+=1; |
137 | 145 |
uriComponents = UriComponentsBuilder |
... | ... | |
153 | 161 |
return country; |
154 | 162 |
} |
155 | 163 |
|
156 |
private void addRepos(Set<String> resultSet, Collection<String> repos) {
|
|
157 |
for(String s : repos)
|
|
158 |
if(!resultSet.contains(s))
|
|
159 |
resultSet.add(s);
|
|
164 |
private void addRepos(List<Repository> resultSet, Collection<Repository> repos) {
|
|
165 |
for(Repository r : repos)
|
|
166 |
if(!resultSet.contains(r))
|
|
167 |
resultSet.add(r);
|
|
160 | 168 |
} |
161 | 169 |
|
162 | 170 |
private Collection<Repository> getRepositoriesByMode(String mode, List<Repository> rs) { |
163 | 171 |
|
164 | 172 |
List<Repository> reps = new ArrayList<>(); |
165 |
|
|
166 |
for(Repository r : rs) |
|
173 |
for(Repository r : rs){ |
|
167 | 174 |
if(r.getCollectedFrom().equals(mode)) |
168 | 175 |
reps.add(r); |
169 |
|
|
176 |
} |
|
170 | 177 |
return reps; |
171 | 178 |
} |
172 | 179 |
|
... | ... | |
235 | 242 |
public RepositoryInterface getRepositoyInterface(@PathVariable("id") String id) throws JSONException { |
236 | 243 |
|
237 | 244 |
UriComponents uriComponents = UriComponentsBuilder |
238 |
.fromHttpUrl(baseAddress + "/ds/service/")
|
|
245 |
.fromHttpUrl(baseAddress + "/ds/api/")
|
|
239 | 246 |
.path("/{id}/") |
240 | 247 |
.build().expand(id).encode(); |
241 | 248 |
|
... | ... | |
253 | 260 |
} |
254 | 261 |
|
255 | 262 |
@Override |
256 |
public String addRepositoryInterface(RepositoryInterface repositoryInterface) throws JSONException {
|
|
263 |
public void deleteRepositoryInterface(@PathVariable("id") String id){
|
|
257 | 264 |
UriComponents uriComponents = UriComponentsBuilder |
258 |
.fromHttpUrl(baseAddress + "/ds/service/add/") |
|
265 |
.fromHttpUrl(baseAddress + "/ds/api/") |
|
266 |
.path("/{id}/") |
|
267 |
.build().expand(id).encode(); |
|
268 |
restTemplate.delete(uriComponents.toUri()); |
|
269 |
} |
|
270 |
|
|
271 |
@Override |
|
272 |
public RepositoryInterface addRepositoryInterface(RepositoryInterface iFace) throws JSONException { |
|
273 |
|
|
274 |
UriComponents uriComponents = UriComponentsBuilder |
|
275 |
.fromHttpUrl(baseAddress + "/ds/api/add/") |
|
259 | 276 |
.build() |
260 | 277 |
.encode(); |
261 |
return restTemplate.postForObject(uriComponents.toUri(), Converter.repositoryInterfaceObjectToJson(repositoryInterface),String.class); |
|
278 |
String rs = restTemplate.postForObject(uriComponents.toUri(), Converter.repositoryInterfaceObjectToJson(iFace),String.class); |
|
279 |
return Converter.jsonToRepositoryInterfaceObject(new JSONArray(rs).getJSONObject(0)); |
|
262 | 280 |
} |
263 | 281 |
|
264 | 282 |
@Override |
Also available in: Unified diff
1. New method ( delete repository interface ) on repo api.
2. New method ( get ruleset with acronym ) on validator api.
3. Log messages in every api.