|
|
|
@ -118,11 +118,25 @@ public class DatasetProfileManager {
|
|
|
|
|
for (AutoCompleteData.AutoCompleteSingleData singleData: data.getAutoCompleteSingleDataList()) {
|
|
|
|
|
switch (AutoCompleteData.AutocompleteType.fromValue(singleData.getAutocompleteType())) {
|
|
|
|
|
case UNCACHED:
|
|
|
|
|
headers.setAccept(Collections.singletonList(MediaType.valueOf("application/vnd.api+json; charset=utf-8")));
|
|
|
|
|
|
|
|
|
|
String url = singleData.getUrl();
|
|
|
|
|
String mediaType = "";
|
|
|
|
|
if (url.contains("openaire")) {
|
|
|
|
|
mediaType = "application/json; charset=utf-8";
|
|
|
|
|
url = url.replace("{like}", like.equals("") ? "*" : like);
|
|
|
|
|
url = url.replace("%20", " ");
|
|
|
|
|
url = url.replace("%22", "\"");
|
|
|
|
|
url = url.replace("&", "&");
|
|
|
|
|
} else {
|
|
|
|
|
mediaType = "application/vnd.api+json; charset=utf-8";
|
|
|
|
|
url += "?search=" + like;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
headers.setAccept(Collections.singletonList(MediaType.valueOf(mediaType)));
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
entity = new HttpEntity<>("parameters", headers);
|
|
|
|
|
|
|
|
|
|
response = restTemplate.exchange(singleData.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class);
|
|
|
|
|
response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
|
|
|
|
|
jsonContext = JsonPath.parse(response.getBody());
|
|
|
|
|
jsonItems = jsonContext.read(singleData.getOptionsRoot() + "['" + singleData.getAutoCompleteOptions().getLabel() + "','" + singleData.getAutoCompleteOptions().getValue() + "','" + singleData.getAutoCompleteOptions().getSource() + "','" + "uri" + "']");
|
|
|
|
|
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(item.get(singleData.getAutoCompleteOptions().getValue()), item.get(singleData.getAutoCompleteOptions().getLabel()), item.get(singleData.getAutoCompleteOptions().getSource()), item.get("uri"))));
|
|
|
|
|