Search in sources :

Example 46 with TaxonImpl

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

the class StudyImporterForBioInfo method createSpecimen.

private Specimen createSpecimen(Study study, LabeledCSVParser labeledCSVParser, String externalId) throws StudyImporterException {
    try {
        Specimen specimen = nodeFactory.createSpecimen(study, new TaxonImpl(null, TaxonomyProvider.NBN.getIdPrefix() + externalId));
        setSpecimenExternalId(labeledCSVParser, specimen);
        return specimen;
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to create taxon with scientific name [" + externalId + "]", e);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 47 with TaxonImpl

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

the class StudyImporterForByrnes method addInteractionForPredator.

private void addInteractionForPredator(LabeledCSVParser parser, Study localStudy, String predatorName) throws NodeFactoryException, StudyImporterException {
    Specimen predator = nodeFactory.createSpecimen(localStudy, new TaxonImpl(predatorName, null));
    String preyName = parser.getValueByLabel("Prey");
    if (StringUtils.isBlank(preyName)) {
        getLogger().warn(localStudy, "found empty prey name on line [" + parser.lastLineNumber() + "]");
    } else {
        Specimen prey = nodeFactory.createSpecimen(localStudy, new TaxonImpl(preyName, null));
        String feedingLink = parser.getValueByLabel("Feeding Link?");
        if (StringUtils.equals("1", StringUtils.trim(feedingLink))) {
            predator.ate(prey);
        } else {
            predator.interactsWith(prey, InteractType.INTERACTS_WITH);
        }
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 48 with TaxonImpl

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

the class StudyImporterForBioInfo method buildTaxonMap.

protected static Map<String, Taxon> buildTaxonMap(LabeledCSVParser parser) throws IOException {
    Map<String, Taxon> taxonMap = new HashMap<String, Taxon>();
    while (parser.getLine() != null) {
        if (StringUtils.isBlank(parser.getValueByLabel("NBN Code"))) {
            Taxon taxon = new TaxonImpl();
            taxon.setRank(parser.getValueByLabel("rank"));
            taxon.setName(StringUtils.replaceChars(parser.getValueByLabel("latin"), "'", ""));
            String bioInfoTaxonId = parser.getValueByLabel("my taxon id");
            taxon.setExternalId(TaxonomyProvider.BIO_INFO + "taxon:" + bioInfoTaxonId);
            taxonMap.put(bioInfoTaxonId, taxon);
        }
    }
    return taxonMap;
}
Also used : HashMap(java.util.HashMap) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 49 with TaxonImpl

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

the class StudyImporterForBlewett method addPredator.

private Specimen addPredator(Study study, LabeledCSVParser parser, String[] line) throws NodeFactoryException, TermLookupServiceException {
    Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Centropomus undecimalis", null));
    predatorSpecimen.setLifeStage(nodeFactory.getTermLookupService().lookupTermByName("adult"));
    try {
        String length = parser.getValueByLabel("Standard Length");
        predatorSpecimen.setLengthInMm(Double.parseDouble(length));
    } catch (NumberFormatException ex) {
        getLogger().warn(study, "found malformed length in line:" + parser.lastLineNumber() + " [" + StringUtils.join(line, ",") + "]");
    }
    return predatorSpecimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 50 with TaxonImpl

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

the class TaxonUtilTest method toTaxonImageNonEOL.

@Test
public void toTaxonImageNonEOL() {
    TaxonImage image = new TaxonImage();
    Taxon taxon = new TaxonImpl("Donald duckus", "ZZZ: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(nullValue()));
    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)

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