Fix issue with parsing some custom auto complete sources
This commit is contained in:
parent
b7d622e330
commit
b2825c8369
|
@ -176,7 +176,7 @@ public class DatasetProfileManager {
|
|||
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()) != null ? item.get(singleData.getAutoCompleteOptions().getSource()) : singleData.getAutoCompleteOptions().getSource(), item.get("uri"))));
|
||||
jsonItems.forEach(item -> result.add(new ExternalAutocompleteFieldModel(parseItem(item.get(singleData.getAutoCompleteOptions().getValue())), parseItem(item.get(singleData.getAutoCompleteOptions().getLabel())), item.get(singleData.getAutoCompleteOptions().getSource()) != null ? parseItem(item.get(singleData.getAutoCompleteOptions().getSource())) : singleData.getAutoCompleteOptions().getSource(), parseItem(item.get("uri")))));
|
||||
break;
|
||||
case CACHED:
|
||||
headers.setAccept(Collections.singletonList(MediaType.valueOf("text/plain; charset=utf-8")));
|
||||
|
@ -202,6 +202,20 @@ public class DatasetProfileManager {
|
|||
//return result;
|
||||
}
|
||||
|
||||
private String parseItem(Object item) {
|
||||
if (item instanceof String) {
|
||||
return (String) item;
|
||||
}
|
||||
if (item instanceof List) {
|
||||
List listedItems = (List) item;
|
||||
return parseItem(listedItems.get(0));
|
||||
}
|
||||
if (item instanceof Map) {
|
||||
return (String) ((Map)item).get("$");
|
||||
}
|
||||
return item.toString();
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
|
||||
FileEnvelope envelope = getXmlDocument(datasetProfile, label);
|
||||
InputStream resource = new FileInputStream(envelope.getFile());
|
||||
|
|
Loading…
Reference in New Issue