Source:
public boolean fetchFor(BibDatabaseContext database, ObservableList<BibEntry> entries, DialogService dialogService, ExtendedTask<List<BibEntry>> fetchReferenceMetadataTask) { fetchReferenceMetadataTask.updateMessage("Fetching data from Semantic Scholar..."); for (int entryIndex = 0; entryIndex < entries.size(); entryIndex++) { BibEntry entry = entries.get(entryIndex); String citationKey = entry.getField(InternalField.KEY_FIELD).orElse("").trim(); Optional<DOI> doi = entry.getField(StandardField.DOI).flatMap(DOI::parse); if (doi.isPresent()) { String doiString = doi.get().getDOI(); HttpResponse<JsonNode> jsonResponse = Unirest.get(API_URL + doiString) .queryString("httpAccept", "application/json") .asJson(); fetchReferenceMetadataTask.updateProgress(entryIndex + 1, entries.size()); if (!jsonResponse.isSuccess()) { entriesWithIncompleteMetadata.add(entry); LOGGER.info("fetching metadata for reference with citation key \"" + citationKey + "\" was not successful"); continue; } JSONObject jsonData = jsonResponse.getBody().getObject(); if (jsonData != null && jsonData.has("influentialCitationCount")) { int citationCountNumber = jsonData.getInt("influentialCitationCount"); String citationCount = String.format("%0" + CITATION_COUNT_STRING_LENGTH + "d", citationCountNumber); entry.setField(InternalField.CITATION_COUNT, citationCount); } else { entriesWithIncompleteMetadata.add(entry); LOGGER.info("reference with citation key \"" + citationKey + "\" does not have the required metadata"); } } else { entriesWithIncompleteMetadata.add(entry); LOGGER.info("skipping reference with citation key \"" + citationKey + "\", since it does not have a DOI"); } } return false; }

Target:
public boolean fetchFor(BibDatabaseContext database, ObservableList<BibEntry> entries, DialogService dialogService, ExtendedTask<List<BibEntry>> fetchReferenceMetadataTask) { fetchReferenceMetadataTask.updateMessage("Fetching data from Semantic Scholar..."); for (int entryIndex = 0; entryIndex < entries.size(); entryIndex++) { BibEntry entry = entries.get(entryIndex); String citationKey = entry.getField(InternalField.KEY_FIELD).orElse("").trim(); Optional<DOI> doi = entry.getField(StandardField.DOI).flatMap(DOI::parse); if (doi.isEmpty()) { entriesWithIncompleteMetadata.add(entry); LOGGER.info("skipping reference with citation key \"" + citationKey + "\", since it does not have a DOI"); continue; } String doiString = doi.get().getDOI(); HttpResponse<JsonNode> jsonResponse = Unirest.get(API_URL + doiString) .queryString("httpAccept", "application/json") .asJson(); fetchReferenceMetadataTask.updateProgress(entryIndex + 1, entries.size()); if (!jsonResponse.isSuccess()) { entriesWithIncompleteMetadata.add(entry); LOGGER.info("fetching metadata for reference with citation key \"" + citationKey + "\" was not successful"); continue; } JSONObject jsonData = jsonResponse.getBody().getObject(); if (jsonData != null && jsonData.has("influentialCitationCount")) { int citationCountNumber = jsonData.getInt("influentialCitationCount"); String citationCount = String.format("%0" + CITATION_COUNT_STRING_LENGTH + "d", citationCountNumber); entry.setField(InternalField.CITATION_COUNT, citationCount); } else { entriesWithIncompleteMetadata.add(entry); LOGGER.info("reference with citation key \"" + citationKey + "\" does not have the required metadata"); } } return false; }