Search in sources :

Example 51 with Specimen

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

the class StudyImporterForAkin method addSpecimen.

private Specimen addSpecimen(Study study, LabeledCSVParser parser, String[] header, String[] line) throws StudyImporterException, NodeFactoryException {
    Specimen specimen = null;
    int speciesIndex = findIndexForColumnWithNameThrowOnMissing("Fish Species", header);
    String speciesName = line[speciesIndex];
    if (StringUtils.isNotBlank(speciesName)) {
        specimen = nodeFactory.createSpecimen(study, new TaxonImpl(speciesName, null));
        addSpecimenLength(parser, header, line, specimen, study);
        addStomachVolume(parser, header, line, specimen, study);
        addCollectionDate(study, parser, header, line, specimen);
    } else {
        getLogger().warn(study, "found blank species name on line [" + parser.lastLineNumber() + "]");
    }
    return specimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 52 with Specimen

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

the class StudyImporterForAkin method parseLine.

private void parseLine(String[][] siteInfos, String studyResource, Study study, LabeledCSVParser parser, String[] header, String[] line) throws NodeFactoryException, IOException {
    try {
        Specimen specimen = addSpecimen(study, parser, header, line);
        if (specimen != null) {
            Location location = parseLocation(findSiteInfo(header, line, siteInfos, parser));
            specimen.caughtIn(location);
            addPrey(study, parser, header, line, specimen, location);
        }
    } catch (StudyImporterException ex) {
        getLogger().warn(study, "[" + studyResource + "]:" + ex.getMessage());
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) Location(org.eol.globi.domain.Location)

Example 53 with Specimen

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

the class StudyImporterForBioInfo method createSpecimen.

private Specimen createSpecimen(LabeledCSVParser parser, Study study, Map<String, Taxon> taxonMap, String nbnId, String bioTaxonId) throws StudyImporterException {
    Specimen specimen = null;
    if (StringUtils.isBlank(nbnId)) {
        try {
            Taxon taxon = taxonMap.get(bioTaxonId);
            if (taxon == null) {
                getLogger().warn(study, "empty/no taxon name for bioinfo taxon id [" + bioTaxonId + "] on line [" + parser.lastLineNumber() + 1 + "]");
            } else {
                specimen = nodeFactory.createSpecimen(study, new TaxonImpl(taxon.getName(), TaxonomyProvider.BIO_INFO + "taxon:" + bioTaxonId));
                setSpecimenExternalId(parser, specimen);
            }
        } catch (NodeFactoryException e) {
            throw new StudyImporterException("failed to create taxon with scientific name [" + bioTaxonId + "]", e);
        }
    } else {
        specimen = createSpecimen(study, parser, nbnId);
    }
    return specimen;
}
Also used : Specimen(org.eol.globi.domain.Specimen) Taxon(org.eol.globi.domain.Taxon) TaxonImpl(org.eol.globi.domain.TaxonImpl)

Example 54 with Specimen

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

the class StudyImporterForSeltmann method createInteraction.

protected void createInteraction(LabeledCSVParser occurrence, Study study, Map<String, String> assoc, String targetName, String sourceName, Date date, InteractType interactType) throws StudyImporterException {
    Specimen source = nodeFactory.createSpecimen(study, new TaxonImpl(sourceName, null));
    Specimen target = nodeFactory.createSpecimen(study, new TaxonImpl(targetName, null));
    source.interactsWith(target, interactType);
    String sourceBasisOfRecord = occurrence.getValueByLabel("basisOfRecord");
    source.setBasisOfRecord(nodeFactory.getOrCreateBasisOfRecord(sourceBasisOfRecord, sourceBasisOfRecord));
    final String recordId = occurrence.getValueByLabel(FIELD_IDIGBIO_RECORD_ID);
    source.setProperty(FIELD_IDIGBIO_RECORD_ID, recordId);
    source.setExternalId(recordId);
    source.setProperty(FIELD_OCCURRENCE_ID, occurrence.getValueByLabel(FIELD_OCCURRENCE_ID));
    source.setProperty(FIELD_CATALOG_NUMBER, occurrence.getValueByLabel(FIELD_CATALOG_NUMBER));
    String targetBasisOfRecord = assoc.get("dwc:basisOfRecord");
    target.setBasisOfRecord(nodeFactory.getOrCreateBasisOfRecord(targetBasisOfRecord, targetBasisOfRecord));
    final String assocRecordId = assoc.get(FIELD_IDIGBIO_RECORD_ID);
    target.setProperty(FIELD_IDIGBIO_RECORD_ID, assocRecordId);
    target.setExternalId(assocRecordId);
    nodeFactory.setUnixEpochProperty(source, date);
    nodeFactory.setUnixEpochProperty(target, date);
    String latitude = occurrence.getValueByLabel("decimalLatitude");
    String longitude = occurrence.getValueByLabel("decimalLongitude");
    if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) {
        Location loc = nodeFactory.getOrCreateLocation(new LocationImpl(Double.parseDouble(latitude), Double.parseDouble(longitude), null, null));
        source.caughtIn(loc);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) LocationImpl(org.eol.globi.domain.LocationImpl) Location(org.eol.globi.domain.Location)

Example 55 with Specimen

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

the class StudyImporterForRoopnarine method importTrophicInteractions.

private List<Specimen> importTrophicInteractions(String trophicGuildLookup, Map<Integer, List<String>> trophicGuildNumberToSpeciesMap, String studyResource, Study study, Location location) throws StudyImporterException {
    try {
        LabeledCSVParser parser = parserFactory.createParser(studyResource, CharsetConstant.UTF8);
        List<Specimen> predatorSpecimen = new ArrayList<Specimen>();
        while (parser.getLine() != null) {
            List<String> preyTaxonList = importPreyList(trophicGuildNumberToSpeciesMap, parser, study);
            if (preyTaxonList.size() > 0) {
                predatorSpecimen.addAll(importPredatorSpecimen(trophicGuildLookup, trophicGuildNumberToSpeciesMap, parser, preyTaxonList, study, location));
            }
        }
        return predatorSpecimen;
    } catch (IOException e) {
        throw new StudyImporterException("failed to read trophic guild lookup [" + trophicGuildLookup + "]", e);
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to import trophic links [" + studyResource + "]", e);
    } catch (StudyImporterException e) {
        throw new StudyImporterException("failed to import trophic links from resource [" + studyResource + "]", e);
    }
}
Also used : Specimen(org.eol.globi.domain.Specimen) ArrayList(java.util.ArrayList) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException)

Aggregations

Specimen (org.eol.globi.domain.Specimen)91 TaxonImpl (org.eol.globi.domain.TaxonImpl)59 Study (org.eol.globi.domain.Study)38 StudyImpl (org.eol.globi.domain.StudyImpl)34 Location (org.eol.globi.domain.Location)31 LocationImpl (org.eol.globi.domain.LocationImpl)22 Test (org.junit.Test)17 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)15 IOException (java.io.IOException)15 Date (java.util.Date)14 Relationship (org.neo4j.graphdb.Relationship)12 HashMap (java.util.HashMap)11 Taxon (org.eol.globi.domain.Taxon)11 SpecimenNode (org.eol.globi.domain.SpecimenNode)9 TermImpl (org.eol.globi.domain.TermImpl)9 ArrayList (java.util.ArrayList)8 InteractType (org.eol.globi.domain.InteractType)7 LatLng (org.eol.globi.geo.LatLng)6 Map (java.util.Map)5 TaxonNode (org.eol.globi.domain.TaxonNode)5