Search in sources :

Example 46 with Study

use of org.eol.globi.domain.Study 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));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) TermImpl(org.eol.globi.domain.TermImpl) Test(org.junit.Test)

Example 47 with Study

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

the class ExporterOccurrencesTest method exportNoHeader.

@Test
public void exportNoHeader() throws IOException, NodeFactoryException, ParseException {
    createTestData(null);
    resolveNames();
    String expected = getExpectedData();
    Study myStudy1 = nodeFactory.findStudy("myStudy");
    StringWriter row = new StringWriter();
    exportOccurrences().exportStudy(myStudy1, row, false);
    assertThat(row.getBuffer().toString(), equalTo(expected));
}
Also used : Study(org.eol.globi.domain.Study) StringWriter(java.io.StringWriter) Test(org.junit.Test)

Example 48 with Study

use of org.eol.globi.domain.Study 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);
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) LocationImpl(org.eol.globi.domain.LocationImpl) TermImpl(org.eol.globi.domain.TermImpl) Location(org.eol.globi.domain.Location)

Example 49 with Study

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

the class ExporterMeasurementOrFactTest method noMatchNames.

@Test
public void noMatchNames() throws IOException, NodeFactoryException, ParseException {
    Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
    nodeFactory.createSpecimen(myStudy, new TaxonImpl(PropertyAndValueDictionary.NO_NAME, "externalId1"));
    nodeFactory.createSpecimen(myStudy, new TaxonImpl("Some namus", PropertyAndValueDictionary.NO_MATCH));
    Study myStudy1 = nodeFactory.findStudy("myStudy");
    StringWriter row = new StringWriter();
    new ExporterMeasurementOrFact().exportStudy(myStudy1, row, false);
    assertThat(row.getBuffer().toString(), equalTo(""));
}
Also used : Study(org.eol.globi.domain.Study) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 50 with Study

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

the class GraphExporterImplTest method exportAll.

@Test
public void exportAll() throws StudyImporterException, IOException {
    File tmpDir = FileUtils.getTempDirectory();
    File tmpDirPath = new File(tmpDir, "test" + new Random().nextLong());
    FileUtils.forceMkdir(tmpDirPath);
    assertThat(tmpDirPath.list().length, is(0));
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("a study", "a source", "doi:12345L", null));
    Specimen human = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", "NCBI:123"));
    human.ate(nodeFactory.createSpecimen(study, new TaxonImpl("Canis familiaris", "BLA:444")));
    resolveNames();
    try {
        new GraphExporterImpl().export(getGraphDb(), tmpDirPath.getAbsolutePath() + "/");
        assertThat(tmpDirPath.list().length, is(6));
    } finally {
        FileUtils.deleteQuietly(tmpDirPath);
    }
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) Random(java.util.Random) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) File(java.io.File) Test(org.junit.Test)

Aggregations

Study (org.eol.globi.domain.Study)141 Test (org.junit.Test)84 StudyImpl (org.eol.globi.domain.StudyImpl)61 Specimen (org.eol.globi.domain.Specimen)38 Relationship (org.neo4j.graphdb.Relationship)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)32 IOException (java.io.IOException)30 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)24 Location (org.eol.globi.domain.Location)24 StringWriter (java.io.StringWriter)21 LocationImpl (org.eol.globi.domain.LocationImpl)20 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)16 Taxon (org.eol.globi.domain.Taxon)16 SpecimenNode (org.eol.globi.domain.SpecimenNode)14 Date (java.util.Date)13 DatasetImpl (org.eol.globi.service.DatasetImpl)13 Node (org.neo4j.graphdb.Node)12 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)10 InteractType (org.eol.globi.domain.InteractType)9