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