@Test public void invalidateAll() throws PropertyEnricherException { TermResource<Taxon> termCache = new TermResource<Taxon>() { @Override public String getResource() { return TAXON_CACHE_TEST_RESOURCE; } @Override public Function<String, Taxon> getParser() { return null; } @Override public Predicate<String> getValidator() { return s -> false; } }; TermResource<Triple<Taxon, NameType, Taxon>> termMap = new TermResource<Triple<Taxon, NameType, Taxon>>() { @Override public String getResource() { return TAXON_MAP_TEST_RESOURCE; } @Override public Function<String, Triple<Taxon, NameType, Taxon>> getParser() { return str -> { throw new RuntimeException("kaboom!"); }; } @Override public Predicate<String> getValidator() { return s -> false; } }; final TaxonCacheService cacheService = new TaxonCacheService(termCache, termMap); cacheService.setCacheDir(mapdbDir); cacheService.match(Collections.singletonList(new TermImpl("EOL:1276240", null)), (nodeId, name, taxon, nameType) -> assertThat(nameType, is(NameType.NONE))); }
@Override public void match(List<Term> terms, TermMatchListener termMatchListener) throws PropertyEnricherException { lazyInit(); for (Term term : terms) { String nodeIdAndName = term.getName(); Long nodeId = term instanceof TermRequestImpl ? ((TermRequestImpl) term).getNodeId() : null; if (!resolveName(termMatchListener, term, term.getId(), nodeId)) { if (StringUtils.isBlank(nodeIdAndName) || !resolveName(termMatchListener, term, term.getName(), nodeId)) { termMatchListener.foundTaxonForTerm(nodeId, term, new TaxonImpl(term.getId(), term.getName()), NameType.NONE); } } } }
TaxonCacheService extends CacheService implements PropertyEnricher, TermMatcher { @Override public void match(List<Term> terms, TermMatchListener termMatchListener) throws PropertyEnricherException { lazyInit(); for (Term term : terms) { String nodeIdAndName = term.getName(); Long nodeId = term instanceof TermRequestImpl ? ((TermRequestImpl) term).getNodeId() : null; if (!resolveName(termMatchListener, term, term.getId(), nodeId)) { if (StringUtils.isBlank(nodeIdAndName) || !resolveName(termMatchListener, term, term.getName(), nodeId)) { termMatchListener.foundTaxonForTerm(nodeId, term, new TaxonImpl(term.getId(), term.getName()), NameType.NONE); } } } } }
TaxonCacheService extends CacheService implements PropertyEnricher, TermMatcher { @Override public void match(List<Term> terms, TermMatchListener termMatchListener) throws PropertyEnricherException { lazyInit(); for (Term term : terms) { String nodeIdAndName = term.getName(); Long nodeId = term instanceof TermRequestImpl ? ((TermRequestImpl) term).getNodeId() : null; if (!resolveName(termMatchListener, term, term.getId(), nodeId)) { if (StringUtils.isBlank(nodeIdAndName) || !resolveName(termMatchListener, term, term.getName(), nodeId)) { termMatchListener.foundTaxonForTerm(nodeId, term, new TaxonImpl(term.getId(), term.getName()), NameType.NONE); } } } } TaxonCacheService(final TermResource<Taxon> taxonCache, final TermResource<Triple<Taxon, NameType, Taxon>> taxonMap);  TaxonCacheService(final String termResource, final String taxonMapResource); }
TaxonCacheService extends CacheService implements PropertyEnricher, TermMatcher { @Override public void match(List<Term> terms, TermMatchListener termMatchListener) throws PropertyEnricherException { lazyInit(); for (Term term : terms) { String nodeIdAndName = term.getName(); Long nodeId = term instanceof TermRequestImpl ? ((TermRequestImpl) term).getNodeId() : null; if (!resolveName(termMatchListener, term, term.getId(), nodeId)) { if (StringUtils.isBlank(nodeIdAndName) || !resolveName(termMatchListener, term, term.getName(), nodeId)) { termMatchListener.foundTaxonForTerm(nodeId, term, new TaxonImpl(term.getId(), term.getName()), NameType.NONE); } } } } TaxonCacheService(final TermResource<Taxon> taxonCache, final TermResource<Triple<Taxon, NameType, Taxon>> taxonMap);  TaxonCacheService(final String termResource, final String taxonMapResource); @Override Map<String, String> enrichFirstMatch(Map<String, String> properties); @Override List<Map<String, String>> enrichAllMatches(Map<String, String> properties); String getName(Map<String, String> properties); String getExternalId(Map<String, String> properties); @Override void match(List<Term> terms, TermMatchListener termMatchListener); int getMaxTaxonLinks(); void setMaxTaxonLinks(int maxTaxonLinks); static Iterator<Fun.Tuple2<String, Map<String, String>>> taxonCacheIterator(final TermResource<Taxon> config); static void logCacheLoadStats(long time, int numberOfItems); static void logCacheLoadStats(long time, int numberOfItems, Log log); @Override void shutdown(); static void close(Engine engine); }
TaxonCacheService extends CacheService implements PropertyEnricher, TermMatcher { @Override public void match(List<Term> terms, TermMatchListener termMatchListener) throws PropertyEnricherException { lazyInit(); for (Term term : terms) { String nodeIdAndName = term.getName(); Long nodeId = term instanceof TermRequestImpl ? ((TermRequestImpl) term).getNodeId() : null; if (!resolveName(termMatchListener, term, term.getId(), nodeId)) { if (StringUtils.isBlank(nodeIdAndName) || !resolveName(termMatchListener, term, term.getName(), nodeId)) { termMatchListener.foundTaxonForTerm(nodeId, term, new TaxonImpl(term.getId(), term.getName()), NameType.NONE); } } } } TaxonCacheService(final TermResource<Taxon> taxonCache, final TermResource<Triple<Taxon, NameType, Taxon>> taxonMap);  TaxonCacheService(final String termResource, final String taxonMapResource); @Override Map<String, String> enrichFirstMatch(Map<String, String> properties); @Override List<Map<String, String>> enrichAllMatches(Map<String, String> properties); String getName(Map<String, String> properties); String getExternalId(Map<String, String> properties); @Override void match(List<Term> terms, TermMatchListener termMatchListener); int getMaxTaxonLinks(); void setMaxTaxonLinks(int maxTaxonLinks); static Iterator<Fun.Tuple2<String, Map<String, String>>> taxonCacheIterator(final TermResource<Taxon> config); static void logCacheLoadStats(long time, int numberOfItems); static void logCacheLoadStats(long time, int numberOfItems, Log log); @Override void shutdown(); static void close(Engine engine);  }