Search in sources :

Example 6 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class TaxonUtil method mapToTaxon.

public static Taxon mapToTaxon(Map<String, String> properties) {
    Taxon taxon = new TaxonImpl();
    mapToTaxon(properties, taxon);
    return taxon;
}
Also used : Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 7 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class TaxonUtil method copy.

public static Taxon copy(Taxon taxon) {
    TaxonImpl taxonCopy = new TaxonImpl();
    mapToTaxon(taxonToMap(taxon), taxonCopy);
    return taxonCopy;
}
Also used : TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 8 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class TaxonUtilTest method homonym.

@Test
public void homonym() {
    TaxonImpl taxon = new TaxonImpl();
    taxon.setName("Lestes");
    taxon.setExternalId("some:id");
    taxon.setPath("Insecta|Lestidae|Lestes");
    taxon.setPathNames("class|family|genus");
    TaxonImpl otherTaxon = new TaxonImpl();
    otherTaxon.setName("Lestes");
    otherTaxon.setExternalId("some:otherid");
    otherTaxon.setPath("Mammalia|Mesonychidae|Lestes");
    otherTaxon.setPathNames("class|family|genus");
    assertTrue(TaxonUtil.likelyHomonym(taxon, otherTaxon));
}
Also used : TaxonImpl(org.eol.globi.domain.TaxonImpl) Test(org.junit.Test)

Example 9 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class TaxonUtilTest method toTaxonImage.

@Test
public void toTaxonImage() {
    TaxonImage image = new TaxonImage();
    Taxon taxon = new TaxonImpl("Donald duckus", "EOL:123");
    taxon.setCommonNames("bla @en | boo @de");
    taxon.setPath("one | two | three");
    Map<String, String> taxonMap = new TreeMap<String, String>(TaxonUtil.taxonToMap(taxon));
    taxonMap.put(PropertyAndValueDictionary.THUMBNAIL_URL, "http://foo/bar/thumb");
    taxonMap.put(PropertyAndValueDictionary.EXTERNAL_URL, "http://foo/bar");
    TaxonImage enrichedImage = TaxonUtil.enrichTaxonImageWithTaxon(taxonMap, image);
    assertThat(enrichedImage.getCommonName(), is("bla"));
    assertThat(enrichedImage.getTaxonPath(), is("one | two | three"));
    assertThat(enrichedImage.getInfoURL(), is("http://foo/bar"));
    assertThat(enrichedImage.getThumbnailURL(), is("http://foo/bar/thumb"));
    assertThat(enrichedImage.getPageId(), is("123"));
    assertThat(enrichedImage.getImageURL(), is(nullValue()));
}
Also used : TaxonImage(org.eol.globi.domain.TaxonImage) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 10 with TaxonImpl

use of org.eol.globi.domain.TaxonImpl in project eol-globi-data by jhpoelen.

the class ExportTaxonCacheTest method exportOnePredatorTwoPrey.

@Test
public void exportOnePredatorTwoPrey() throws NodeFactoryException, IOException {
    taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("title", "source", null, "citation"));
    Taxon taxon = new TaxonImpl("Homo sapiens");
    taxon.setExternalId("homoSapiensId");
    taxon.setPath("one\ttwo three");
    taxon.setExternalUrl("http://some/thing");
    taxon.setThumbnailUrl("http://thing/some");
    Taxon human = taxonIndex.getOrCreateTaxon(taxon);
    TaxonImpl taxon1 = new TaxonImpl("Canis lupus", "canisLupusId");
    taxon1.setPath("four five six");
    taxonIndex.getOrCreateTaxon(taxon1);
    NodeUtil.connectTaxa(new TaxonImpl("Alternate Homo sapiens no path", "alt:123"), (TaxonNode) human, getGraphDb(), RelTypes.SAME_AS);
    final TaxonImpl altTaxonWithPath = new TaxonImpl("Alternate Homo sapiens", "alt:123");
    altTaxonWithPath.setPath("some path here");
    NodeUtil.connectTaxa(altTaxonWithPath, (TaxonNode) human, getGraphDb(), RelTypes.SAME_AS);
    NodeUtil.connectTaxa(new TaxonImpl("Similar Homo sapiens", "alt:456"), (TaxonNode) human, getGraphDb(), RelTypes.SIMILAR_TO);
    StringWriter writer = new StringWriter();
    new ExportTaxonCache().exportStudy(study, writer, true);
    assertThat(writer.toString(), is("id\tname\trank\tcommonNames\tpath\tpathIds\tpathNames\texternalUrl\tthumbnailUrl" + "\nhomoSapiensId\tHomo sapiens\t\t\tone two three\t\t\thttp://some/thing\thttp://thing/some" + "\nalt:123\tAlternate Homo sapiens\t\t\tsome path here\t\t\thttp://some/thing\thttp://thing/some" + "\ncanisLupusId\tCanis lupus\t\t\tfour five six\t\t\t\t"));
}
Also used : Study(org.eol.globi.domain.Study) StringWriter(java.io.StringWriter) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Aggregations

TaxonImpl (org.eol.globi.domain.TaxonImpl)123 Specimen (org.eol.globi.domain.Specimen)59 Test (org.junit.Test)54 Taxon (org.eol.globi.domain.Taxon)42 StudyImpl (org.eol.globi.domain.StudyImpl)34 Study (org.eol.globi.domain.Study)32 Location (org.eol.globi.domain.Location)16 LocationImpl (org.eol.globi.domain.LocationImpl)15 TaxonNode (org.eol.globi.domain.TaxonNode)13 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)12 IOException (java.io.IOException)11 TermImpl (org.eol.globi.domain.TermImpl)11 StringWriter (java.io.StringWriter)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)7 HashMap (java.util.HashMap)7 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)7 Map (java.util.Map)5 Node (org.neo4j.graphdb.Node)5 File (java.io.File)4