Improve compatibility for openAire sources
This commit is contained in:
parent
f0502b94df
commit
13ac3634d6
|
@ -278,11 +278,28 @@ public class RemoteFetcher {
|
|||
+ "," + jsonDataPath.getFieldsUrlConfiguration().getId() + "]"),
|
||||
new HashMap<>(1, 1));
|
||||
List<Map<String, String>> fixedResults = results.getResults().stream().map(item -> {
|
||||
String id = jsonDataPath.getFieldsUrlConfiguration().getId().replace("'", "");
|
||||
if (! (item.get(id) instanceof String)) {
|
||||
Object obj = item.get(id);
|
||||
JSONArray jarr = (JSONArray) obj;
|
||||
item.put(id, jarr.get(0).toString());
|
||||
for (int i = 0; i < 2; i++) {
|
||||
String id;
|
||||
if (i == 0) {
|
||||
id = jsonDataPath.getFieldsUrlConfiguration().getId().replace("'", "");
|
||||
} else {
|
||||
id = jsonDataPath.getFieldsUrlConfiguration().getName().replace("'", "");
|
||||
}
|
||||
if (!(item.get(id) instanceof String)) {
|
||||
Object obj = item.get(id);
|
||||
if (obj instanceof JSONArray) {
|
||||
JSONArray jarr = (JSONArray) obj;
|
||||
if (jarr.get(0) instanceof String) {
|
||||
item.put(id, jarr.get(0).toString());
|
||||
} else {
|
||||
for (int j = 0; j < jarr.size(); j++) {
|
||||
mapToMap(id, (Map<String, String>)jarr.get(j), item, i == 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mapToMap(id, (Map<String, String>)obj, item, i == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}).collect(Collectors.toList());
|
||||
|
@ -472,4 +489,16 @@ public class RemoteFetcher {
|
|||
this.pagination = pagination;
|
||||
}
|
||||
}
|
||||
|
||||
private void mapToMap(String key, Map<String, String> source, Map<String, String> destination, boolean isTitle) {
|
||||
String content = source.get("content");
|
||||
if (isTitle) {
|
||||
String classId = source.get("classid");
|
||||
if (classId.equals("main title")) {
|
||||
destination.put(key, content);
|
||||
}
|
||||
} else {
|
||||
destination.put(key, content);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue