use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class StudyImporterForWrast method importStudy.
@Override
public void importStudy() throws StudyImporterException {
String citation = "Wrast JL. Spatiotemporal And Habitat-mediated Food Web Dynamics in Lavaca Bay, Texas. 2008. Master Thesis.";
StudyImpl study1 = new StudyImpl("Wrast 2008", StudyImporterForGoMexSI2.GOMEXI_SOURCE_DESCRIPTION, null, citation);
study1.setExternalId("http://www.fisheries.tamucc.edu/people_files/FINAL%20WRAST%20THESIS.pdf");
Study study = nodeFactory.getOrCreateStudy(study1);
try {
LabeledCSVParser csvParser = parserFactory.createParser(LAVACA_BAY_DATA_SOURCE, CharsetConstant.UTF8);
LengthParser parser = new LengthParserImpl(COLUMN_MAPPER.get(LENGTH_IN_MM));
getPredatorSpecimenMap().clear();
while (csvParser.getLine() != null) {
addNextRecordToStudy(csvParser, study, COLUMN_MAPPER, parser);
}
} catch (IOException e) {
throw new StudyImporterException("failed to create study [" + LAVACA_BAY_DATA_SOURCE + "]", e);
} finally {
getPredatorSpecimenMap().clear();
}
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class StudyImporterForINaturalistTest method loadIgnoredInteractions.
@Test
public void loadIgnoredInteractions() throws IOException {
LabeledCSVParser labeledCSVParser = importer.parserFactory.createParser(StudyImporterForINaturalist.TYPE_IGNORED_URI_DEFAULT, CharsetConstant.UTF8);
List<Integer> typeMap1 = StudyImporterForINaturalist.buildTypesIgnored(labeledCSVParser);
assertThat(typeMap1.contains(13), is(false));
assertThat(typeMap1.contains(1378), is(true));
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class StudyImporterForINaturalistTest method loadInteractionMap.
@Test
public void loadInteractionMap() throws IOException {
String resourceName = StudyImporterForINaturalist.TYPE_MAP_URI_DEFAULT;
LabeledCSVParser labeledCSVParser = importer.parserFactory.createParser(resourceName, CharsetConstant.UTF8);
Map<Integer, InteractType> typeMap = StudyImporterForINaturalist.buildTypeMap(resourceName, labeledCSVParser);
assertThat(typeMap.get(13), is(InteractType.ATE));
assertThat(typeMap.get(1685), is(InteractType.ATE));
assertThat(typeMap.get(839), is(InteractType.PREYS_UPON));
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class SchemaControllerTest method interactionTypesCSV.
@Test
public void interactionTypesCSV() throws IOException {
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
when(request.getParameter("type")).thenReturn("csv");
String interactionTypes = new SchemaController().getInteractionTypes(request);
LabeledCSVParser parser = CSVTSVUtil.createLabeledCSVParser(IOUtils.toInputStream(interactionTypes));
assertThat(parser.getLabels(), is(new String[] { "interaction", "source", "target", "termIRI" }));
while (parser.getLine() != null) {
assertThat(parser.getValueByLabel("interaction"), is(notNullValue()));
assertThat(parser.getValueByLabel("source"), is(notNullValue()));
assertThat(parser.getValueByLabel("target"), is(notNullValue()));
assertThat(parser.getValueByLabel("termIRI"), is(notNullValue()));
}
}
use of com.Ostermiller.util.LabeledCSVParser in project eol-globi-data by jhpoelen.
the class TaxonMapParserTest method parse.
public static void parse(BufferedReader reader, TaxonMapListener listener) throws IOException {
LabeledCSVParser labeledCSVParser = CSVTSVUtil.createLabeledCSVParser(reader);
listener.start();
while (labeledCSVParser.getLine() != null) {
Taxon providedTaxon = TaxonMapParser.parseProvidedTaxon(labeledCSVParser);
Taxon resolvedTaxon = TaxonMapParser.parseResolvedTaxon(labeledCSVParser);
listener.addMapping(providedTaxon, resolvedTaxon);
}
listener.finish();
}
Aggregations