diff --git a/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziService.java b/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziService.java index feba43ba..e955a272 100644 --- a/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziService.java +++ b/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziService.java @@ -9,16 +9,20 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.lucene.store.SimpleFSDirectory; +import org.eol.globi.domain.NameType; import org.eol.globi.domain.PropertyAndValueDictionary; import org.eol.globi.domain.Taxon; -import org.eol.globi.domain.TaxonomyProvider; +import org.eol.globi.domain.TaxonImpl; +import org.eol.globi.domain.Term; +import org.eol.globi.domain.TermImpl; import org.eol.globi.service.PropertyEnricher; import org.eol.globi.service.PropertyEnricherException; import org.eol.globi.service.TaxonUtil; import org.eol.globi.taxon.TaxonCacheListener; import org.eol.globi.taxon.TaxonCacheService; import org.eol.globi.taxon.TaxonLookupServiceImpl; -import org.eol.globi.util.ExternalIdUtil; +import org.eol.globi.taxon.TermMatchListener; +import org.eol.globi.taxon.TermMatcher; import org.globalbioticinteractions.nomer.util.PropertyEnricherInfo; import org.globalbioticinteractions.nomer.util.TermMatcherContext; @@ -26,14 +30,13 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.concurrent.atomic.AtomicLong; @PropertyEnricherInfo(name = "plazi", description = "Lookup Plazi taxon treatment by name or id using offline-enabled database dump") -public class PlaziService implements PropertyEnricher { +public class PlaziService implements TermMatcher { private static final Log LOG = LogFactory.getLog(PlaziService.class); @@ -46,32 +49,33 @@ public PlaziService(TermMatcherContext ctx) { } @Override - public Map enrichFirstMatch(Map properties) throws PropertyEnricherException { - List> enrichedList = enrichAllMatches(properties); - return enrichedList.get(0); - } - - @Override - public List> enrichAllMatches(Map properties) throws PropertyEnricherException { - Map enriched = new TreeMap<>(properties); - Taxon[] taxa = lookupByName(properties); - - List> enrichedList = new ArrayList<>(); - if (taxa == null || taxa.length == 0) { - enrichedList.add(enriched); - } else { - for (Taxon taxon : taxa) { - enrichedList.add(new TreeMap<>(TaxonUtil.taxonToMap(taxon))); + public void match(List terms, TermMatchListener termMatchListener) throws PropertyEnricherException { + for (Term term : terms) { + Taxon[] taxons = lookupLinkedTerms(term); + if (taxons == null || taxons.length == 0) { + termMatchListener.foundTaxonForTerm( + null, + term, + new TaxonImpl(term.getName(), term.getId()), + NameType.NONE + ); + } else { + for (Taxon taxon : taxons) { + Taxon taxonToBeSubmitted = taxon; + if (StringUtils.startsWith(taxon.getExternalId(), "doi:") + || StringUtils.startsWith(taxon.getExternalId(), "http://treatment.plazi.org/id/")) { + taxonToBeSubmitted = new TaxonImpl(taxon.getExternalId(), taxon.getExternalId()); + taxonToBeSubmitted.setPath(taxon.getExternalId()); + } + termMatchListener.foundTaxonForTerm(null, term, taxonToBeSubmitted, NameType.SAME_AS); + } } } - return enrichedList; } - private Taxon[] lookupByName(Map properties) throws PropertyEnricherException { + private Taxon[] lookupLinkedTerms(Term term) throws PropertyEnricherException { Taxon[] taxa = null; - String name = properties.get(PropertyAndValueDictionary.NAME); - String externalId = properties.get(PropertyAndValueDictionary.EXTERNAL_ID); - if (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(externalId)) { + if (StringUtils.isNotBlank(term.getName()) || StringUtils.isNotBlank(term.getId())) { if (needsInit()) { if (ctx == null) { throw new PropertyEnricherException("context needed to initialize"); @@ -80,17 +84,18 @@ private Taxon[] lookupByName(Map properties) throws PropertyEnri } try { - if (StringUtils.isNotBlank(externalId)) { - if (StringUtils.startsWith(externalId, "PLAZI:")) { - externalId = StringUtils.replace(externalId, "PLAZI:", "http://treatment.plazi.org/id/"); + String externalId = term.getId(); + if (StringUtils.isNotBlank(term.getId())) { + if (StringUtils.startsWith(term.getId(), "PLAZI:")) { + externalId = StringUtils.replace(term.getId(), "PLAZI:", "http://treatment.plazi.org/id/"); } taxa = taxonLookupService.lookupTermsById(externalId); } - if ((taxa == null || taxa.length == 0) && StringUtils.isNotBlank(name)) { - taxa = taxonLookupService.lookupTermsByName(name); + if ((taxa == null || taxa.length == 0) && StringUtils.isNotBlank(term.getName())) { + taxa = taxonLookupService.lookupTermsByName(term.getName()); } } catch (IOException e) { - throw new PropertyEnricherException("failed to lookup [" + name + "]", e); + throw new PropertyEnricherException("failed to lookup [" + term.getName() + "]", e); } } return taxa; @@ -173,12 +178,6 @@ private boolean needsInit() { return taxonLookupService == null; } - - @Override - public void shutdown() { - - } - private File getCacheDir(TermMatcherContext ctx) { return new File(ctx.getCacheDir(), "plazi"); } diff --git a/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoader.java b/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoader.java index 14d1ae0a..20fb260d 100644 --- a/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoader.java +++ b/nomer-taxon-resolver/src/main/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoader.java @@ -12,7 +12,7 @@ import org.apache.commons.lang3.StringUtils; import org.eol.globi.data.CharsetConstant; import org.eol.globi.domain.PropertyAndValueDictionary; -import org.eol.globi.domain.TaxonImpl; +import org.eol.globi.domain.Taxon; import org.eol.globi.service.TaxonUtil; import org.eol.globi.taxon.TaxonCacheListener; import org.globalbioticinteractions.doi.DOI; @@ -60,13 +60,15 @@ public static void importTreatment(InputStream treatmentGraph, TaxonCacheListene ResultSet rs = qexec.execSelect(); while (rs.hasNext()) { final QuerySolution next = rs.next(); - addTaxonByPlaziId(listener, next); - addTaxonByPublicationDoi(listener, next); - addTaxonConcept(listener, next); + Taxon addedTaxon = addTaxonConcept(listener, next); + if (addedTaxon != null) { + addTaxonByPlaziId(listener, next, addedTaxon); + addTaxonByPublicationDoi(listener, next, addedTaxon); + } } } - private static void addTaxonConcept(TaxonCacheListener listener, QuerySolution next) { + private static Taxon addTaxonConcept(TaxonCacheListener listener, QuerySolution next) { List taxonRanks = Arrays.asList( "?subspecificEpithet", "?specificEpithet", @@ -90,41 +92,46 @@ private static void addTaxonConcept(TaxonCacheListener listener, QuerySolution n .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); populateTaxa(taxonRanks, taxonMap); - addTaxonByTaxonConcept(listener, next, taxonMap); + return addTaxonByTaxonConcept(listener, next, taxonMap); } - private static void addTaxonByPublicationDoi(TaxonCacheListener listener, QuerySolution next) { + private static void addTaxonByPublicationDoi(TaxonCacheListener listener, QuerySolution next, Taxon some_name) { RDFNode pubNode = next.get("?publication"); if (pubNode != null && pubNode.isURIResource()) { try { DOI pubDoi = DOI.create(URI.create(pubNode.asResource().getURI())); String doiString = pubDoi.toPrintableDOI(); - addTermForPubId(listener, doiString); + Taxon copy = TaxonUtil.copy(some_name); + copy.setExternalId(doiString); + addTermForPubId(listener, copy); } catch (MalformedDOIException e) { // ignore non-DOIs } } } - private static void addTermForPubId(TaxonCacheListener listener, String doiString) { - TaxonImpl taxon = new TaxonImpl(doiString, doiString); - taxon.setPath(doiString); - listener.addTaxon(taxon); + private static void addTermForPubId(TaxonCacheListener listener, Taxon term) { + listener.addTaxon(term); } - private static void addTaxonByTaxonConcept(TaxonCacheListener listener, QuerySolution next, Map taxonMap) { + private static Taxon addTaxonByTaxonConcept(TaxonCacheListener listener, QuerySolution next, Map taxonMap) { + Taxon taxonToBeAdded = null; RDFNode pubNode = next.get("?tc"); if (pubNode != null && pubNode.isURIResource()) { taxonMap.put(PropertyAndValueDictionary.EXTERNAL_ID, pubNode.asResource().getURI()); - listener.addTaxon(TaxonUtil.mapToTaxon(taxonMap)); + taxonToBeAdded = TaxonUtil.mapToTaxon(taxonMap); + listener.addTaxon(taxonToBeAdded); } + return taxonToBeAdded; } - private static void addTaxonByPlaziId(TaxonCacheListener listener, QuerySolution next) { + private static void addTaxonByPlaziId(TaxonCacheListener listener, QuerySolution next, Taxon name) { RDFNode pubNode1 = next.get("?treatment"); if (pubNode1 != null && pubNode1.isURIResource()) { String externalId = pubNode1.asResource().getURI(); - addTermForPubId(listener, externalId); + Taxon copy = TaxonUtil.copy(name); + copy.setExternalId(externalId); + addTermForPubId(listener, copy); } } diff --git a/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziServiceTest.java b/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziServiceTest.java index fbcdaf29..14315717 100644 --- a/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziServiceTest.java +++ b/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziServiceTest.java @@ -1,9 +1,15 @@ package org.globalbioticinteractions.nomer.match; +import org.eol.globi.domain.NameType; +import org.eol.globi.domain.Taxon; import org.eol.globi.domain.TaxonImpl; +import org.eol.globi.domain.Term; +import org.eol.globi.domain.TermImpl; import org.eol.globi.service.PropertyEnricher; import org.eol.globi.service.PropertyEnricherException; import org.eol.globi.service.TaxonUtil; +import org.eol.globi.taxon.TermMatchListener; +import org.eol.globi.taxon.TermMatcher; import org.globalbioticinteractions.doi.DOI; import org.globalbioticinteractions.doi.MalformedDOIException; import org.globalbioticinteractions.nomer.util.TermMatcherContext; @@ -13,10 +19,14 @@ import java.io.IOException; import java.io.InputStream; import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; import static org.eol.globi.service.TaxonUtil.taxonToMap; import static org.hamcrest.core.Is.is; @@ -26,96 +36,128 @@ public class PlaziServiceTest { @Test - public void enrich() throws PropertyEnricherException { - PropertyEnricher service = createService(); + public void match() throws PropertyEnricherException { - TaxonImpl taxon = new TaxonImpl("Carvalhoma", null); - Map enriched = service.enrichFirstMatch(taxonToMap(taxon)); + TermMatcher service = createService(); - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is("Animalia | Arthropoda | Insecta | Hemiptera | Miridae | Carvalhoma")); - assertThat(TaxonUtil.mapToTaxon(enriched).getExternalId(), is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); - assertThat(TaxonUtil.mapToTaxon(enriched).getPathNames(), is("kingdom | phylum | class | order | family | genus")); - assertThat(TaxonUtil.mapToTaxon(enriched).getName(), is("Carvalhoma")); + List found = new ArrayList<>(); + service.match( + Collections.singletonList(new TermImpl(null, "Carvalhoma")), new TermMatchListener() { + @Override + public void foundTaxonForTerm(Long aLong, Term term, Taxon taxon, NameType nameType) { + found.add(taxon); + } + }); + + + assertThat(found.size(), is(3)); + Taxon taxon = found.get(0); + assertThat(taxon.getPath(), is("Animalia | Arthropoda | Insecta | Hemiptera | Miridae | Carvalhoma")); + assertThat(taxon.getExternalId(), is("http://taxon-concept.plazi.org/id/Animalia/Carvalhoma_Slater_1977")); + assertThat(taxon.getPathNames(), is("kingdom | phylum | class | order | family | genus")); + assertThat(taxon.getName(), is("Carvalhoma")); } @Test public void enrichById() throws PropertyEnricherException { - PropertyEnricher service = createService(); - - TaxonImpl taxon = new TaxonImpl(null, "http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B"); - Map enriched = service.enrichFirstMatch(taxonToMap(taxon)); + TermMatcher service = createService(); + + List found = new ArrayList<>(); + service.match( + Collections.singletonList(new TermImpl("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B", null)), new TermMatchListener() { + @Override + public void foundTaxonForTerm(Long aLong, Term term, Taxon taxon, NameType nameType) { + found.add(taxon); + } + }); - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is("Animalia | Arthropoda | Insecta | Hemiptera | Miridae | Carvalhoma")); - assertThat(TaxonUtil.mapToTaxon(enriched).getExternalId(), is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); - assertThat(TaxonUtil.mapToTaxon(enriched).getPathNames(), is("kingdom | phylum | class | order | family | genus")); - assertThat(TaxonUtil.mapToTaxon(enriched).getName(), is("Carvalhoma")); - } - @Test - public void enrichByDOI() throws PropertyEnricherException, MalformedDOIException { - PropertyEnricher service = createService(); - - DOI doi = DOI.create(URI.create("http://doi.org/10.5281/zenodo.3854772")); - String externalId = doi.toPrintableDOI(); - assertThat(externalId, is("doi:10.5281/zenodo.3854772")); - TaxonImpl taxon = new TaxonImpl(null, externalId); - Map enriched = service.enrichFirstMatch(taxonToMap(taxon)); - - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is("Animalia | Arthropoda | Insecta | Hemiptera | Miridae | Carvalhoma")); - assertThat(TaxonUtil.mapToTaxon(enriched).getExternalId(), is("doi:10.5281/zenodo.3854772")); - assertThat(TaxonUtil.mapToTaxon(enriched).getPathNames(), is("kingdom | phylum | class | order | family | genus")); - assertThat(TaxonUtil.mapToTaxon(enriched).getName(), is("Carvalhoma")); + assertThat(found.size(), is(1)); + Taxon taxon = found.get(0); + String expectedTreatment = "http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B"; + assertThat(taxon.getExternalId(), is(expectedTreatment)); + assertThat(taxon.getPath(), is(expectedTreatment)); + assertThat(taxon.getName(), is(expectedTreatment)); } @Test public void enrichByShortId() throws PropertyEnricherException { - PropertyEnricher service = createService(); - TaxonImpl taxon = new TaxonImpl(null, "PLAZI:000087F6E320FF95FF7EFDC1FAE4FA7B"); - Map enriched = service.enrichFirstMatch(taxonToMap(taxon)); + TermMatcher service = createService(); - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is("Animalia | Arthropoda | Insecta | Hemiptera | Miridae | Carvalhoma")); - assertThat(TaxonUtil.mapToTaxon(enriched).getExternalId(), is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); - assertThat(TaxonUtil.mapToTaxon(enriched).getPathNames(), is("kingdom | phylum | class | order | family | genus")); - assertThat(TaxonUtil.mapToTaxon(enriched).getName(), is("Carvalhoma")); + List found = new ArrayList<>(); + service.match( + Collections.singletonList(new TermImpl("PLAZI:000087F6E320FF95FF7EFDC1FAE4FA7B", null)), new TermMatchListener() { + @Override + public void foundTaxonForTerm(Long aLong, Term term, Taxon taxon, NameType nameType) { + found.add(taxon); + } + }); + + + Taxon taxon1 = found.get(0); + String expectedTreatmentId = "http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B"; + assertThat(taxon1.getExternalId(), is(expectedTreatmentId)); + assertThat(taxon1.getPath(), is(expectedTreatmentId)); + assertThat(taxon1.getName(), is(expectedTreatmentId)); + assertThat(taxon1.getPathNames(), is(nullValue())); } @Test public void enrichByDoi() throws PropertyEnricherException { - PropertyEnricher service = createService(); + TermMatcher service = createService(); - TaxonImpl taxon = new TaxonImpl(null, "PLAZI:000087F6E320FF95FF7EFDC1FAE4FA7B"); - Map enriched = service.enrichFirstMatch(taxonToMap(taxon)); + List found = new ArrayList<>(); + service.match( + Collections.singletonList(new TermImpl("doi:10.5281/zenodo.3854772", null)), + (aLong, term, taxon, nameType) -> found.add(taxon)); - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is("Animalia | Arthropoda | Insecta | Hemiptera | Miridae | Carvalhoma")); - assertThat(TaxonUtil.mapToTaxon(enriched).getExternalId(), is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); - assertThat(TaxonUtil.mapToTaxon(enriched).getPathNames(), is("kingdom | phylum | class | order | family | genus")); - assertThat(TaxonUtil.mapToTaxon(enriched).getName(), is("Carvalhoma")); + + assertThat(found.size(), is(1)); + Taxon taxon1 = found.get(0); + assertThat(taxon1.getPath(), is("doi:10.5281/zenodo.3854772")); + assertThat(taxon1.getExternalId(), is("doi:10.5281/zenodo.3854772")); + assertThat(taxon1.getPathNames(), is(nullValue())); + assertThat(taxon1.getName(), is("doi:10.5281/zenodo.3854772")); } @Test public void enrichNoMatch() throws PropertyEnricherException { - PropertyEnricher service = createService(); - - Map enriched = service.enrichFirstMatch( - taxonToMap(new TaxonImpl(null, "ITIS:999999999"))); + TermMatcher service = createService(); + + AtomicInteger counter = new AtomicInteger(); + service.match( + Collections.singletonList(new TermImpl("ITIS:999999999", null)), new TermMatchListener() { + @Override + public void foundTaxonForTerm(Long aLong, Term term, Taxon taxon, NameType nameType) { + counter.getAndIncrement(); + assertThat(nameType, is(NameType.NONE)); + } + }); - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is(nullValue())); + assertThat(counter.get(), is(1)); } @Test public void enrichPrefixMismatch() throws PropertyEnricherException { - PropertyEnricher service = createService(); - - Map enriched = service.enrichFirstMatch( - taxonToMap(new TaxonImpl(null, "FOO:2"))); + TermMatcher service = createService(); + + AtomicInteger counter = new AtomicInteger(); + service.match( + Collections.singletonList(new TermImpl("FOO:2", null)), new TermMatchListener() { + @Override + public void foundTaxonForTerm(Long aLong, Term term, Taxon taxon, NameType nameType) { + counter.getAndIncrement(); + assertThat(nameType, is(NameType.NONE)); + } + }); - assertThat(TaxonUtil.mapToTaxon(enriched).getPath(), is(nullValue())); + assertThat(counter.get(), is(1)); } - private PropertyEnricher createService() { + private TermMatcher createService() { File file = new File("target/cache" + UUID.randomUUID()); return new PlaziService(new TermMatcherContext() { @Override diff --git a/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoaderTest.java b/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoaderTest.java index 6829c701..9e693042 100644 --- a/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoaderTest.java +++ b/nomer-taxon-resolver/src/test/java/org/globalbioticinteractions/nomer/match/PlaziTreatmentsLoaderTest.java @@ -46,17 +46,15 @@ public void finish() { PlaziTreatmentsLoader.importTreatment(treatmentGraph, listener); assertThat(counter.get(), Is.is(3)); - Taxon taxon = taxa.get(0); + Taxon taxon = taxa.get(1); assertThat(taxon.getExternalId(), Is.is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); - assertThat(taxon.getPath(), Is.is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); - assertThat(taxon.getName(), Is.is("http://treatment.plazi.org/id/000087F6E320FF95FF7EFDC1FAE4FA7B")); + assertThat(taxon.getName(), Is.is("Carvalhoma")); - taxon = taxa.get(1); + taxon = taxa.get(2); assertThat(taxon.getExternalId(), Is.is("doi:10.5281/zenodo.3854772")); - assertThat(taxon.getName(), Is.is("doi:10.5281/zenodo.3854772")); - assertThat(taxon.getPath(), Is.is("doi:10.5281/zenodo.3854772")); + assertThat(taxon.getName(), Is.is("Carvalhoma")); - taxon = taxa.get(2); + taxon = taxa.get(0); assertThat(taxon.getExternalId(), Is.is("http://taxon-concept.plazi.org/id/Animalia/Carvalhoma_Slater_1977")); assertThat(taxon.getName(), Is.is("Carvalhoma")); assertThat(taxon.getRank(), Is.is("genus")); @@ -97,15 +95,13 @@ public void finish() { PlaziTreatmentsLoader.importTreatment(treatmentGraph, listener); assertThat(counter.get(), Is.is(3)); - Taxon taxon = taxa.get(0); + Taxon taxon = taxa.get(1); assertThat(taxon.getExternalId(), Is.is("http://treatment.plazi.org/id/03AF87D3C435B542FF728049FB55BB1B")); assertThat(taxon.getName(), Is.is("Rhinolophus sinicus")); - assertThat(taxon.getRank(), Is.is("species")); - Taxon secondTaxon = taxa.get(1); + Taxon secondTaxon = taxa.get(2); assertThat(secondTaxon.getExternalId(), Is.is("doi:10.3161/150811009X465703")); assertThat(secondTaxon.getName(), Is.is("Rhinolophus sinicus")); - assertThat(secondTaxon.getRank(), Is.is("species")); } @@ -139,7 +135,7 @@ public void finish() { PlaziTreatmentsLoader.importTreatment(treatmentGraph, listener); assertThat(counter.get(), Is.is(3)); - Taxon taxon = taxa.get(2); + Taxon taxon = taxa.get(0); assertThat(taxon.getExternalId(), Is.is("http://taxon-concept.plazi.org/id/Animalia/Homo_sapiens_ferus_Linnaeus_1758")); assertThat(taxon.getName(), Is.is("Homo sapiens ferus")); assertThat(taxon.getPath(), Is.is("Animalia | Chordata | Mammalia | Primates | Hominidae | Homo | Homo sapiens ferus")); diff --git a/nomer/src/main/java/org/globalbioticinteractions/nomer/match/TermMatcherPlaziFactory.java b/nomer/src/main/java/org/globalbioticinteractions/nomer/match/TermMatcherPlaziFactory.java index c12ee174..aa0d6067 100644 --- a/nomer/src/main/java/org/globalbioticinteractions/nomer/match/TermMatcherPlaziFactory.java +++ b/nomer/src/main/java/org/globalbioticinteractions/nomer/match/TermMatcherPlaziFactory.java @@ -26,25 +26,6 @@ public String getDescription() { @Override public TermMatcher createTermMatcher(TermMatcherContext ctx) { - final PlaziService plaziService = new PlaziService(ctx); - - return new TermMatcher() { - @Override - public void match(List terms, TermMatchListener termMatchListener) throws PropertyEnricherException { - for (Term term : terms) { - List> linkedTreatments = plaziService - .enrichAllMatches(TaxonUtil.taxonToMap(new TaxonImpl(term.getName(), term.getId()))); - - for (Map linkedTreatment : linkedTreatments) { - termMatchListener.foundTaxonForTerm( - null, - term, - TaxonUtil.mapToTaxon(linkedTreatment), - NameType.SAME_AS); - - } - } - } - }; + return new PlaziService(ctx); } }