@Test public void addDOIToStudy() throws NodeFactoryException { DOIResolver doiResolver = new DOIResolver() { @Override public Map<String, DOI> resolveDoiFor(Collection<String> references) throws IOException { Map<String, DOI> doiMap = new HashMap<>(); for (String reference : references) { doiMap.put(reference, resolveDoiFor(reference)); } return doiMap; } @Override public DOI resolveDoiFor(String reference) throws IOException { return new DOI("1234", "567"); } }; StudyNode study = getNodeFactory().getOrCreateStudy(new StudyImpl("my title", null, ExternalIdUtil.toCitation("my contr", "some description", null))); LinkerDOI.linkStudy(doiResolver, study); assertThat(study.getDOI().toString(), is("10.1234/567")); assertThat(study.getExternalId(), is("https: assertThat(study.getCitation(), is("my contr. some description")); StudyImpl study1 = new StudyImpl("my other title", null, ExternalIdUtil.toCitation("my contr", "some description", null)); assertThat(study1.getExternalId(), nullValue()); study = getNodeFactory().getOrCreateStudy(study1); assertThat(study.getExternalId(), nullValue()); LinkerDOI.linkStudy(new DOIResolverThatExplodes(), study); assertThat(study.getDOI(), nullValue()); assertThat(study.getExternalId(), nullValue()); assertThat(study.getCitation(), is("my contr. some description")); }
public static void linkStudy(DOIResolver doiResolver, StudyNode study) { if (shouldResolve(study)) { try { DOI doiResolved = doiResolver.resolveDoiFor(study.getCitation()); setDOIForStudy(study, doiResolved); } catch (IOException e) { LOG.warn("failed to lookup doi for citation [" + study.getCitation() + "] with id [" + study.getTitle() + "]", e); } } }
LinkerDOI implements IndexerNeo4j { public static void linkStudy(DOIResolver doiResolver, StudyNode study) { if (shouldResolve(study)) { try { DOI doiResolved = doiResolver.resolveDoiFor(study.getCitation()); setDOIForStudy(study, doiResolved); } catch (IOException e) { LOG.warn("failed to lookup doi for citation [" + study.getCitation() + "] with id [" + study.getTitle() + "]", e); } } } }
LinkerDOI implements IndexerNeo4j { public static void linkStudy(DOIResolver doiResolver, StudyNode study) { if (shouldResolve(study)) { try { DOI doiResolved = doiResolver.resolveDoiFor(study.getCitation()); setDOIForStudy(study, doiResolved); } catch (IOException e) { LOG.warn("failed to lookup doi for citation [" + study.getCitation() + "] with id [" + study.getTitle() + "]", e); } } } LinkerDOI();  LinkerDOI(DOIResolver resolver); }
LinkerDOI implements IndexerNeo4j { public static void linkStudy(DOIResolver doiResolver, StudyNode study) { if (shouldResolve(study)) { try { DOI doiResolved = doiResolver.resolveDoiFor(study.getCitation()); setDOIForStudy(study, doiResolved); } catch (IOException e) { LOG.warn("failed to lookup doi for citation [" + study.getCitation() + "] with id [" + study.getTitle() + "]", e); } } } LinkerDOI();  LinkerDOI(DOIResolver resolver); @Override void index(GraphServiceFactory factory); void resolveBatch(DOIResolver doiResolver, Map<String, StudyNode> batch); void resolve(DOIResolver doiResolver, Map<String, StudyNode> batch, Collection<String> citations); String logProgress(int counter, StopWatch stopWatch); static void linkStudy(DOIResolver doiResolver, StudyNode study); static boolean shouldResolve(Study study); }
LinkerDOI implements IndexerNeo4j { public static void linkStudy(DOIResolver doiResolver, StudyNode study) { if (shouldResolve(study)) { try { DOI doiResolved = doiResolver.resolveDoiFor(study.getCitation()); setDOIForStudy(study, doiResolved); } catch (IOException e) { LOG.warn("failed to lookup doi for citation [" + study.getCitation() + "] with id [" + study.getTitle() + "]", e); } } } LinkerDOI();  LinkerDOI(DOIResolver resolver); @Override void index(GraphServiceFactory factory); void resolveBatch(DOIResolver doiResolver, Map<String, StudyNode> batch); void resolve(DOIResolver doiResolver, Map<String, StudyNode> batch, Collection<String> citations); String logProgress(int counter, StopWatch stopWatch); static void linkStudy(DOIResolver doiResolver, StudyNode study); static boolean shouldResolve(Study study); static final int BATCH_SIZE; }