use of org.eol.globi.domain.Location in project eol-globi-data by jhpoelen.
the class StudyImporterForBell method getLocation.
protected Location getLocation(LabeledCSVParser parser, Specimen parasite) throws NodeFactoryException {
String latitude = parser.getValueByLabel("DEC_LAT");
String longitude = parser.getValueByLabel("DEC_LONG");
Location location = null;
if (StringUtils.isNotBlank(latitude) && StringUtils.isNotBlank(longitude)) {
location = nodeFactory.getOrCreateLocation(new LocationImpl(Double.parseDouble(latitude), Double.parseDouble(longitude), null, null));
}
return location;
}
use of org.eol.globi.domain.Location in project eol-globi-data by jhpoelen.
the class StudyImporterForBell method importStudy.
@Override
public void importStudy() throws StudyImporterException {
for (String resource : RESOURCE) {
LabeledCSVParser parser = null;
try {
parser = parserFactory.createParser(resource, "UTF-8");
while (parser.getLine() != null) {
String sourceCitation = "Bell, K. C., Matek, D., Demboski, J. R., & Cook, J. A. (2015). Expanded Host Range of Sucking Lice and Pinworms of Western North American Chipmunks. Comparative Parasitology, 82(2), 312–321. doi:10.1654/4756.1 . Data provided by Kayce C. Bell.";
String guid = parser.getValueByLabel("GUID");
String externalId = "http://arctos.database.museum/guid/" + guid;
String description = null;
String collectionId = null;
for (String key : REFS.keySet()) {
if (guid.startsWith(key)) {
description = REFS.get(key);
collectionId = key;
break;
}
}
if (StringUtils.isBlank(description)) {
LOG.warn("missing collectionId [" + guid + "] in file [" + resource + "] on line [" + parser.lastLineNumber() + "]");
description = sourceCitation;
collectionId = "";
}
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("bell-" + collectionId, sourceCitation, "http://dx.doi.org/10.1654/4756.1", ExternalIdUtil.toCitation(null, sourceCitation + " " + description, null)));
String genus = parser.getValueByLabel("Genus");
String species = parser.getValueByLabel("Species");
String parasiteName = StringUtils.join(new String[] { StringUtils.trim(genus), StringUtils.trim(species) }, " ");
Specimen parasite = nodeFactory.createSpecimen(study, new TaxonImpl(parasiteName, null));
parasite.setExternalId(externalId);
Location location = getLocation(parser, parasite);
parasite.caughtIn(location);
String scientificName = parser.getValueByLabel("SCIENTIFIC_NAME");
String hostName = StringUtils.trim(scientificName);
Specimen host = nodeFactory.createSpecimen(study, new TaxonImpl(hostName, null));
host.caughtIn(location);
host.setExternalId(externalId);
parasite.interactsWith(host, InteractType.PARASITE_OF);
Date date = parseDate(parser);
nodeFactory.setUnixEpochProperty(parasite, date);
nodeFactory.setUnixEpochProperty(host, date);
}
} catch (Throwable e) {
throw new StudyImporterException(getErrorMessage(resource, parser), e);
}
}
}
use of org.eol.globi.domain.Location in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewett method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String citation = "Blewett DA, Hensley RA, and Stevens PW, Feeding Habits of Common Snook, Centropomus Undecimalis, in Charlotte Harbor, Florida, Gulf and Caribbean Research Vol 18, 1–13, 2006. doi:10.18785/gcr.1801.01 ";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("Blewett 2006", StudyImporterForGoMexSI2.GOMEXI_SOURCE_DESCRIPTION, null, citation));
try {
Map<String, Location> collectionLocationMap = new HashMap<>();
Map<String, Date> collectionTimeMap = new HashMap<String, Date>();
buildLocationTimeMaps(collectionLocationMap, collectionTimeMap, study);
parsePredatorPreyInteraction(study, collectionLocationMap, collectionTimeMap);
} catch (IOException e) {
throw new StudyImporterException("failed to read resource", e);
} catch (NodeFactoryException e) {
throw new StudyImporterException("failed to create taxon", e);
} catch (TermLookupServiceException e) {
throw new StudyImporterException("failed to map terms", e);
}
}
use of org.eol.globi.domain.Location in project eol-globi-data by jhpoelen.
the class StudyImporterForBlewett method setLocationAndDate.
private void setLocationAndDate(Map<String, Location> locationMap, Map<String, Date> collectionTimeMap, List<Specimen> items, String collectionCode) throws NodeFactoryException {
String collectionCodeTrim = collectionCode.trim();
Location location = locationMap.get(collectionCodeTrim);
if (location != null) {
for (Specimen item : items) {
item.caughtIn(location);
}
}
Date collectionDatetime = collectionTimeMap.get(collectionCodeTrim);
if (collectionDatetime != null) {
for (Specimen item : items) {
nodeFactory.setUnixEpochProperty(item, collectionDatetime);
}
}
}
use of org.eol.globi.domain.Location in project eol-globi-data by jhpoelen.
the class StudyImporterForGoMexSI2Test method parseLocation.
@Test
public void parseLocation() throws IOException, StudyImporterException {
final String locationLines = "DATA_ID,PRED_ID,LOC_ID,LME_CODE,COUNTRY,STATE,GULF_OCTANT,LOCALE_NAME,LOCALE_TYPE,BAY_HIERARC_LEVEL,SAMP_DEP_REALM,LOC_CENTR_LAT,LOC_CENTR_LONG,LOC_POLY_COORDS,PRED_POLY_SHAPEFILE_ID,PRED_CENT_SHAPEFILE_ID,PRED_STAT_SHAPEFILE_ID,LOC_POLY_SOURCE,LOC_POLY_CONF,MAJOR_LOC_NAME,MAJOR_LOC_TYPE,MIN_DEP_LOC,MAX_DEP_LOC,MN_DEP_LOC,MIN_DEP_SAMP,MAX_DEP_SAMP,MN_DEP_SAMP,TIME_ZONE,START_YEAR,START_MON,START_DAY,START_TIME,START_SEAS,END_YEAR,END_MON,END_DAY,END_TIME,END_SEAS,REALM,PROVINCE,ECOREGION,HAB_SYSTEM,HAB_SUBSYSTEM,TIDAL_ZONE,SYS_CONF,LOC_NOTES,NUM_SAMPS,ENTRY_DATE,ENTRY_PERSON,EDITED_DATE,DATA_EDITOR,MODIFY_DATE,DATA_MODIFIER\n" + "ACT_16R,Cchr.1,ACT_16r.1,GOM,US,LA,NNW,Louisiana inner continental shelf,Continental shelf,NA,Demersal,29.346953,-92.980614,\"((-92.6729107838999,29.3941413332999),(-92.5604838626999,29.2066775354),(-92.7326173694,29.1150784684999),(-92.9638307704999,29.1171045174),(-93.3169089704999,29.3616452463),(-93.4007435505999,29.5222620776999),(-93.3169089704999,29.6243402981),(-93.1045280342,29.6340566488),(-92.6729107838999,29.3941413332999))\",,,,Inferred from station locations,high,Louisiana continental shelf,Gulf/Ocean waters,9.094,18.188,13.641,9.094,18.188,13.641,CDST,1970,7,NA,0:00,summer,1973,2,NA,0:00,winter,TNA,WTNA,43,Marine,Nearshore,Subtidal,NA,NA,NA,NA,Jim Simons,NA,Jim Simons,15/06/2016,Theresa Mitchell\n" + "ACT_16R,Cchr.1,ACT_16r.2,GOM,US,LA,NNW,Louisiana mid continental shelf,Continental shelf,NA,Demersal,29.032598,-92.287009,\"((-92.1815365767999,29.1068886358999),(-92.200079333,29.0069336331),(-92.3030548952999,28.9075567952),(-92.4770626883999,28.8892759983999),(-92.5999700862,28.9468493538999),(-92.6034249349,29.0088070450999),(-92.5255192441999,29.0774757406),(-92.3918542331,29.148292841),(-92.2231376575,29.1384141105999),(-92.1815365767999,29.1068886358999))\",,,,Inferred from station locations,high,Louisiana continental shelf,Gulf/Ocean waters,18.188,54.564,36.376,18.188,54.564,36.376,CDST,1970,7,NA,0:00,summer,1973,2,NA,0:00,winter,TNA,WTNA,43,Marine,Offshore,Subtidal,NA,NA,NA,NA,Jim Simons,NA,Jim Simons,15/06/2016,Theresa Mitchell\n" + "ACT_16R,Cchr.1,ACT_16r.1,GOM,US,LA,NNW,Louisiana inner continental shelf,Continental shelf,NA,Demersal,29.346953,-92.980614,\"((-92.6729107838999,29.3941413332999),(-92.5604838626999,29.2066775354),(-92.7326173694,29.1150784684999),(-92.9638307704999,29.1171045174),(-93.3169089704999,29.3616452463),(-93.4007435505999,29.5222620776999),(-93.3169089704999,29.6243402981),(-93.1045280342,29.6340566488),(-92.6729107838999,29.3941413332999))\",,,,Inferred from station locations,high,Louisiana continental shelf,Gulf/Ocean waters,9.094,18.188,13.641,9.094,18.188,13.641,CDST,1970,7,NA,0:00,summer,1973,2,NA,0:00,winter,TNA,WTNA,43,Marine,Nearshore,Subtidal,NA,NA,NA,NA,Jim Simons,NA,Jim Simons,15/06/2016,Theresa Mitchell\n" + "ACT_16R,Cchr.1,ACT_16r.2,GOM,US,LA,NNW,Louisiana mid continental shelf,Continental shelf,NA,Demersal,29.032598,-92.287009,\"((-92.1815365767999,29.1068886358999),(-92.200079333,29.0069336331),(-92.3030548952999,28.9075567952),(-92.4770626883999,28.8892759983999),(-92.5999700862,28.9468493538999),(-92.6034249349,29.0088070450999),(-92.5255192441999,29.0774757406),(-92.3918542331,29.148292841),(-92.2231376575,29.1384141105999),(-92.1815365767999,29.1068886358999))\",,,,Inferred from station locations,high,Louisiana continental shelf,Gulf/Ocean waters,18.188,54.564,36.376,18.188,54.564,36.376,CDST,1970,7,NA,0:00,summer,1973,2,NA,0:00,winter,TNA,WTNA,43,Marine,Offshore,Subtidal,NA,NA,NA,NA,Jim Simons,NA,Jim Simons,15/06/2016,Theresa Mitchell\n";
final LabeledCSVParser parser = new LabeledCSVParser(new CSVParser(IOUtils.toInputStream(locationLines)));
parser.getLine();
final Location location = StudyImporterForGoMexSI2.parseLocation("someMickeyMouseresource.csv", parser);
assertThat(location.getLatitude(), is(29.346953d));
assertThat(location.getLongitude(), is(-92.980614d));
assertThat(location.getAltitude(), is(-13.641d));
assertThat(location.getLocality(), is("Louisiana inner continental shelf"));
assertThat(location.getFootprintWKT(), is(WKT_FOOTPRINT));
}
Aggregations