Search in sources :

Example 71 with StudyImpl

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

the class ExporterAssociationsTest method createTestData.

private void createTestData(Double length) throws NodeFactoryException, ParseException {
    Study myStudy = nodeFactory.getOrCreateStudy(new StudyImpl("myStudy", "data\tsource description", null, ExternalIdUtil.toCitation("contributor", "description", "pubYear")));
    Specimen specimen = nodeFactory.createSpecimen(myStudy, new TaxonImpl("Homo sapiens", "EOL:123"));
    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, new Date(ExportTestUtil.utcTestTime()));
    eats(specimen, "Canis lupus", "EOL:456", myStudy);
    eats(specimen, "Felis whateverus", PropertyAndValueDictionary.NO_MATCH, myStudy);
    if (null != length) {
        specimen.setLengthInMm(length);
    }
    Location location = nodeFactory.getOrCreateLocation(new LocationImpl(13.0, 45.9, -60.0, null));
    specimen.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) Date(java.util.Date) TermImpl(org.eol.globi.domain.TermImpl) Location(org.eol.globi.domain.Location)

Example 72 with StudyImpl

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

the class ExportUnmatchedTaxonNamesTest method exportOnePredatorNoPathButWithSameAs.

@Test
public void exportOnePredatorNoPathButWithSameAs() throws NodeFactoryException, IOException {
    taxonIndex = ExportTestUtil.taxonIndexWithEnricher(null, getGraphDb());
    String citation = "cite, study";
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("my, study", "my first, source", null, citation));
    Specimen predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapienz", null));
    Taxon humanz = taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapienz", null));
    TaxonImpl taxon = new TaxonImpl("Homo sapiens", "TESTING:123");
    taxon.setPath("one | two | Homo sapiens");
    NodeUtil.connectTaxa(taxon, (TaxonNode) humanz, getGraphDb(), RelTypes.SIMILAR_TO);
    assertNotNull(humanz);
    Specimen preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Caniz", null));
    predatorSpecimen.interactsWith(preySpecimen, InteractType.ATE);
    predatorSpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Homo sapiens", null));
    Node synonymNode = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens Synonym", null))).getUnderlyingNode();
    Node node = ((NodeBacked) taxonIndex.getOrCreateTaxon(new TaxonImpl("Homo sapiens", null))).getUnderlyingNode();
    Transaction tx = getGraphDb().beginTx();
    try {
        node.createRelationshipTo(synonymNode, NodeUtil.asNeo4j(RelTypes.SAME_AS));
        tx.success();
    } finally {
        tx.finish();
    }
    preySpecimen = nodeFactory.createSpecimen(study, new TaxonImpl("Canis", null));
    predatorSpecimen.ate(preySpecimen);
    resolveNames();
    StringWriter writer = new StringWriter();
    new ExportUnmatchedTaxonNames().exportStudy(study, writer, true);
    assertThat(writer.toString(), is("unmatched taxon name\tunmatched taxon id\tname status\tsimilar to taxon name\tsimilar to taxon path\tsimilar to taxon id\tstudy\tsource" + "\nHomo sapienz\t\t\tHomo sapiens\tone | two | Homo sapiens\tTESTING:123\tcite, study\tmy first, source" + "\nCaniz\t\t\t\t\t\tcite, study\tmy first, source" + "\nCanis\t\t\t\t\t\tcite, study\tmy first, source"));
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) NodeBacked(org.eol.globi.domain.NodeBacked) Transaction(org.neo4j.graphdb.Transaction) StringWriter(java.io.StringWriter) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) Node(org.neo4j.graphdb.Node) TaxonNode(org.eol.globi.domain.TaxonNode) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 73 with StudyImpl

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

the class ExportFlatInteractionsTest method createTestData.

private void createTestData(Double length) throws NodeFactoryException, ParseException {
    Study myStudy = factory.createStudy(new StudyImpl("myStudy", null, null, null));
    specimenEatCatAndDog(length, myStudy, "Homo sapiens", "EOL:333");
    specimenEatCatAndDog(length, myStudy, "Homo sapiens", "EOL:333");
    specimenEatCatAndDog(length, myStudy, "Homo erectus", "EOL:123");
    specimenEatCatAndDog(length, myStudy, "Homo erectus", "EOL:123");
    specimenEatCatAndDog(length, factory.createStudy(new StudyImpl("yourStudy", null, null, null)), "Homo erectus", "EOL:888");
    specimenEatCatAndDog(length, factory.createStudy(new StudyImpl("yourStudy2", null, null, null)), "Homo erectus", "EOL:888");
    specimenEatCatAndDog(length, myStudy, "Blo blaaus", PropertyAndValueDictionary.NO_MATCH);
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl)

Example 74 with StudyImpl

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

the class ExportCitationsTest method exportCitations.

@Test
public void exportCitations() throws IOException, NodeFactoryException {
    StringWriter writer = new StringWriter();
    getNodeFactory().getOrCreateStudy(new StudyImpl("some title", "some source", "doi:some/doi", "some citation"));
    getNodeFactory().getOrCreateStudy(new StudyImpl("some other title", "some other source", "doi:some/otherdoi", "some other citation"));
    new ExportCitations().export(getGraphDb(), writer, "START study = node:studies('*:*') " + "RETURN study.externalId? as uri" + ", study.citation? as citation");
    assertThat(writer.toString(), Is.is("uri\tcitation" + "\nhttp://dx.doi.org/some/doi\tsome citation" + "\nhttp://dx.doi.org/some/otherdoi\tsome other citation"));
}
Also used : StringWriter(java.io.StringWriter) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 75 with StudyImpl

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

the class ExporterOccurrenceAggregatesTest method createTestData.

private void createTestData(Double length) throws NodeFactoryException, ParseException {
    Study myStudy = nodeFactory.createStudy(new StudyImpl("myStudy", null, null, null));
    specimenEatCatAndDog(length, myStudy, "Homo sapiens", "EOL:333");
    specimenEatCatAndDog(length, myStudy, "Homo sapiens", "EOL:333");
    specimenEatCatAndDog(length, myStudy, "Homo erectus", "EOL:123");
    specimenEatCatAndDog(length, myStudy, "Homo erectus", "EOL:123");
    specimenEatCatAndDog(length, nodeFactory.createStudy(new StudyImpl("yourStudy", null, null, null)), "Homo erectus", "EOL:888");
    specimenEatCatAndDog(length, nodeFactory.createStudy(new StudyImpl("yourStudy2", null, null, null)), "Homo erectus", "EOL:888");
    specimenEatCatAndDog(length, myStudy, "Blo blaaus", PropertyAndValueDictionary.NO_MATCH);
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl)

Aggregations

StudyImpl (org.eol.globi.domain.StudyImpl)82 Study (org.eol.globi.domain.Study)60 Test (org.junit.Test)40 Specimen (org.eol.globi.domain.Specimen)33 TaxonImpl (org.eol.globi.domain.TaxonImpl)33 IOException (java.io.IOException)20 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)17 Location (org.eol.globi.domain.Location)15 StringWriter (java.io.StringWriter)12 LocationImpl (org.eol.globi.domain.LocationImpl)12 Date (java.util.Date)9 HashMap (java.util.HashMap)9 Taxon (org.eol.globi.domain.Taxon)9 StudyNode (org.eol.globi.domain.StudyNode)7 Node (org.neo4j.graphdb.Node)7 File (java.io.File)6 TermImpl (org.eol.globi.domain.TermImpl)6 DatasetImpl (org.eol.globi.service.DatasetImpl)6 InteractType (org.eol.globi.domain.InteractType)5 NonResolvingTaxonIndex (org.eol.globi.taxon.NonResolvingTaxonIndex)5