Source:
private void requestAuthors(Model model, String doi) throws IOException { Map<?,?> allAuthorsData = soaService.requestObject(String.format("articles/%s?authors", doi), Map.class); List<?> authors = (List<?>) allAuthorsData.get("authors"); model.addAttribute("authors", authors); List<String> correspondingAuthors = new ArrayList<>(); List<String> equalContributors = new ArrayList<>(); ListMultimap<String, String> authorAffiliationsMap = LinkedListMultimap.create(); for (Object o : authors) { Map<String, Object> author = (Map<String, Object>) o; String fullName = (String) author.get("fullName"); List<String> affiliations = (List<String>) author.get("affiliations"); for (String affiliation : affiliations) { authorAffiliationsMap.put(affiliation, fullName); } if (author.containsKey("corresponding")) { correspondingAuthors.add((String) author.get("corresponding")); } Object obj = author.get("equalContrib"); if (obj != null && (boolean) obj) { equalContributors.add(fullName); } List<String> currentAddresses = (List<String>) author.get("currentAddresses"); for (ListIterator<String> iterator = currentAddresses.listIterator(); iterator.hasNext(); ) { String currentAddress = iterator.next(); iterator.set(TextUtil.removeFootnoteMarker(currentAddress)); } } Map<String, String> authorListAffiliationMap = new HashMap<>(); for (String affiliation : authorAffiliationsMap.asMap().keySet()) { authorListAffiliationMap.put(affiliation, Joiner.on(", ") .join(authorAffiliationsMap.get(affiliation))); } model.addAttribute("authorListAffiliationMap", authorListAffiliationMap); model.addAttribute("authorContributions", allAuthorsData.get("authorContributions")); model.addAttribute("competingInterests", allAuthorsData.get("competingInterests")); model.addAttribute("correspondingAuthors", correspondingAuthors); model.addAttribute("equalContributors", equalContributors); }

Target:
private void requestAuthors(Model model, String doi) throws IOException { Map<?,?> allAuthorsData = soaService.requestObject(String.format("articles/%s?authors", doi), Map.class); List<?> authors = (List<?>) allAuthorsData.get("authors"); model.addAttribute("authors", authors); List<String> correspondingAuthors = new ArrayList<>(); List<String> equalContributors = new ArrayList<>(); ListMultimap<String, String> authorAffiliationsMap = LinkedListMultimap.create(); for (Object o : authors) { Map<String, Object> author = (Map<String, Object>) o; String fullName = (String) author.get("fullName"); List<String> affiliations = (List<String>) author.get("affiliations"); for (String affiliation : affiliations) { authorAffiliationsMap.put(affiliation, fullName); } if (author.containsKey("corresponding")) { correspondingAuthors.add((String) author.get("corresponding")); } Object obj = author.get("equalContrib"); if (obj != null && (boolean) obj) { equalContributors.add(fullName); } List<String> currentAddresses = (List<String>) author.get("currentAddresses"); for (ListIterator<String> iterator = currentAddresses.listIterator(); iterator.hasNext(); ) { String currentAddress = iterator.next(); iterator.set(TextUtil.removeFootnoteMarker(currentAddress)); } } LinkedHashMap<String, String> authorListAffiliationMap = new LinkedHashMap<>(); for (Map.Entry<String, Collection<String>> affiliation : authorAffiliationsMap.asMap().entrySet()) { authorListAffiliationMap.put(affiliation.getKey(), Joiner.on(", ").join(affiliation.getValue())); } model.addAttribute("authorListAffiliationMap", authorListAffiliationMap); model.addAttribute("authorContributions", allAuthorsData.get("authorContributions")); model.addAttribute("competingInterests", allAuthorsData.get("competingInterests")); model.addAttribute("correspondingAuthors", correspondingAuthors); model.addAttribute("equalContributors", equalContributors); }