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;
}
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;
}
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));
}
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()));
}
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"));
}
Aggregations