use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForICES method importStudy.
@Override
public void importStudy() throws StudyImporterException {
LabeledCSVParser parser = createParser();
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("ICES", "International Council for the Exploration of the Sea. Available at http://www.ices.dk/products/cooperative.asp .", null, "Cooperative Research Report No. 164; Cooperative Research Report No. 219, ICES Stomach DatasetImpl, ICES"));
study.setExternalId("http://ecosystemdata.ices.dk/stomachdata/");
try {
Specimen predator = null;
String lastStomachId = null;
while ((parser.getLine()) != null) {
if (importFilter.shouldImportRecord((long) parser.getLastLineNumber())) {
Date date = parseDate(parser);
Location location = parseLocation(parser);
String currentStomachId = parser.getValueByLabel("ICES StomachID");
if (lastStomachId == null || !lastStomachId.equals(currentStomachId)) {
predator = addPredator(parser, study);
nodeFactory.setUnixEpochProperty(predator, date);
predator.caughtIn(location);
}
Specimen prey = addPrey(parser, predator, study);
if (prey != null) {
nodeFactory.setUnixEpochProperty(prey, date);
prey.caughtIn(location);
}
lastStomachId = currentStomachId;
}
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("problem parsing datasource", e);
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForHafner method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try {
LabeledCSVParser parser = parserFactory.createParser(RESOURCE, "UTF-8");
while (parser.getLine() != null) {
String sourceCitation = "Mark S. Hafner, Philip D. Sudman, Francis X. Villablanca, Theresa A. Spradling, James W. Demastes, Steven A. Nadler. (1994). Disparate Rates of Molecular Evolution in Cospeciating Hosts and Parasites. Science 265: 1087-1090. doi:10.1126/science.8066445";
Study study = nodeFactory.getOrCreateStudy(new StudyImpl("hafner1994", "Shan Kothari, Pers. Comm. 2014.", "doi:10.1126/science.8066445", sourceCitation));
String hostName = parser.getValueByLabel("Host");
String parasiteName = parser.getValueByLabel("Parasite");
Specimen host = nodeFactory.createSpecimen(study, new TaxonImpl(hostName, null));
Specimen parasite = nodeFactory.createSpecimen(study, new TaxonImpl(parasiteName, null));
parasite.interactsWith(host, InteractType.PARASITE_OF);
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("failed to import [" + RESOURCE + "]", e);
}
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryWithDatasetContextTest method getOrCreateStudy.
@Test
public void getOrCreateStudy() throws NodeFactoryException {
NodeFactory factory = Mockito.mock(NodeFactory.class);
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
factoryWithDS.getOrCreateStudy(new StudyImpl("some title"));
ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
verify(factory).getOrCreateStudy(argument.capture());
assertEquals("globi:some/namespace", argument.getValue().getSourceId());
assertEquals("some title", argument.getValue().getTitle());
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class ExporterOccurrencesTest method dontExportToCSVSpecimenEmptyStomach.
@Test
public void dontExportToCSVSpecimenEmptyStomach() throws NodeFactoryException, IOException {
Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:123"));
specimen.setBasisOfRecord(new TermImpl("test:123", "aBasisOfRecord"));
resolveNames();
StringWriter row = new StringWriter();
exportOccurrences().exportStudy(myStudy, row, true);
String expected = "";
expected += getExpectedHeader();
expected += "\nglobi:occur:2\tEOL:123\t\t\t\t\t\t\t\t\t\t\t\t\taBasisOfRecord\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
assertThat(row.getBuffer().toString(), equalTo(expected));
}
use of org.eol.globi.domain.StudyImpl in project eol-globi-data by jhpoelen.
the class ExporterOccurrencesTest method createTestData.
private void createTestData(Double length) throws NodeFactoryException, ParseException {
Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:327955"));
specimen.setStomachVolumeInMilliLiter(666.0);
specimen.setLifeStage(new TermImpl("GLOBI:JUVENILE", "JUVENILE"));
specimen.setPhysiologicalState(new TermImpl("GLOBI:DIGESTATE", "DIGESTATE"));
specimen.setBodyPart(new TermImpl("GLOBI:BONE", "BONE"));
nodeFactory.setUnixEpochProperty(specimen, ExportTestUtil.utcTestDate());
if (null != length) {
specimen.setLengthInMm(length);
}
Location location = nodeFactory.getOrCreateLocation(new LocationImpl(12.0, -1.0, -60.0, null));
specimen.caughtIn(location);
Specimen wolf1 = eatWolf(specimen, myStudy);
wolf1.caughtIn(location);
Specimen wolf2 = eatWolf(specimen, myStudy);
wolf2.caughtIn(location);
}
Aggregations