@Test public void findAnnotationsStaticZenodo() throws IOException, StudyImporterException { final InputStream searchResultStream = getClass().getResourceAsStream("zenodo/search-results-zenodo.json"); List<Map<String, String>> links = new ArrayList<>(); final InteractionListener interactionListener = new InteractionListener() { @Override public void newLink(Map<String, String> link) throws StudyImporterException { links.add(link); } }; DatasetImporterForZenodoMetadata.parseSearchResults(searchResultStream, interactionListener); assertThat(links.size(), Is.is(97)); List<String> citations = new ArrayList<>(); for (Map<String, String> link : links) { final String s = link.get(REFERENCE_CITATION); assertNotNull(s); citations.add(s); } assertThat(citations.get(0), Is.is("Rachel L. Graham, Ralph S. Baric. (2010). Recombination, Reservoirs, and the Modular Spike: Mechanisms of Coronavirus Cross-Species Transmission. Journal of Virology. https: }
public static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener) throws IOException, StudyImporterException { final JsonNode searchResults = new ObjectMapper().readTree(searchResultStream); final PubListener recordListener = new MyPubListener(interactionListener); if (searchResults.has("hits")) { final JsonNode hits = searchResults.get("hits"); if (hits.has("hits")) { JsonNode hitsArray = hits.get("hits"); for (JsonNode hit : hitsArray) { recordListener.onRecord(hit); } } } URI nextPage = null; if (searchResults.has("links")) { final JsonNode links = searchResults.get("links"); if (links.has("next")) { final JsonNode next = links.get("next"); nextPage = URI.create(next.asText()); } } return nextPage; }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { public static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener) throws IOException, StudyImporterException { final JsonNode searchResults = new ObjectMapper().readTree(searchResultStream); final PubListener recordListener = new MyPubListener(interactionListener); if (searchResults.has("hits")) { final JsonNode hits = searchResults.get("hits"); if (hits.has("hits")) { JsonNode hitsArray = hits.get("hits"); for (JsonNode hit : hitsArray) { recordListener.onRecord(hit); } } } URI nextPage = null; if (searchResults.has("links")) { final JsonNode links = searchResults.get("links"); if (links.has("next")) { final JsonNode next = links.get("next"); nextPage = URI.create(next.asText()); } } return nextPage; } }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { public static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener) throws IOException, StudyImporterException { final JsonNode searchResults = new ObjectMapper().readTree(searchResultStream); final PubListener recordListener = new MyPubListener(interactionListener); if (searchResults.has("hits")) { final JsonNode hits = searchResults.get("hits"); if (hits.has("hits")) { JsonNode hitsArray = hits.get("hits"); for (JsonNode hit : hitsArray) { recordListener.onRecord(hit); } } } URI nextPage = null; if (searchResults.has("links")) { final JsonNode links = searchResults.get("links"); if (links.has("next")) { final JsonNode next = links.get("next"); nextPage = URI.create(next.asText()); } } return nextPage; } DatasetImporterForZenodoMetadata(ParserFactory parserFactory, NodeFactory nodeFactory); }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { public static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener) throws IOException, StudyImporterException { final JsonNode searchResults = new ObjectMapper().readTree(searchResultStream); final PubListener recordListener = new MyPubListener(interactionListener); if (searchResults.has("hits")) { final JsonNode hits = searchResults.get("hits"); if (hits.has("hits")) { JsonNode hitsArray = hits.get("hits"); for (JsonNode hit : hitsArray) { recordListener.onRecord(hit); } } } URI nextPage = null; if (searchResults.has("links")) { final JsonNode links = searchResults.get("links"); if (links.has("next")) { final JsonNode next = links.get("next"); nextPage = URI.create(next.asText()); } } return nextPage; } DatasetImporterForZenodoMetadata(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener); }
DatasetImporterForZenodoMetadata extends DatasetImporterWithListener { public static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener) throws IOException, StudyImporterException { final JsonNode searchResults = new ObjectMapper().readTree(searchResultStream); final PubListener recordListener = new MyPubListener(interactionListener); if (searchResults.has("hits")) { final JsonNode hits = searchResults.get("hits"); if (hits.has("hits")) { JsonNode hitsArray = hits.get("hits"); for (JsonNode hit : hitsArray) { recordListener.onRecord(hit); } } } URI nextPage = null; if (searchResults.has("links")) { final JsonNode links = searchResults.get("links"); if (links.has("next")) { final JsonNode next = links.get("next"); nextPage = URI.create(next.asText()); } } return nextPage; } DatasetImporterForZenodoMetadata(ParserFactory parserFactory, NodeFactory nodeFactory); @Override void importStudy(); static URI parseSearchResults(InputStream searchResultStream, InteractionListener interactionListener);  }