Search in sources :

Example 21 with StudyImpl

use of org.eol.globi.domain.StudyImpl 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 22 with StudyImpl

use of org.eol.globi.domain.StudyImpl 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)

Example 23 with StudyImpl

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

the class ExporterSiteMapForNamesTest method writeSiteMapWithNames.

@Test
public void writeSiteMapWithNames() throws StudyImporterException, IOException {
    taxonIndex = new NonResolvingTaxonIndex(getGraphDb());
    Study study = nodeFactory.getOrCreateStudy(new StudyImpl("title", "source", null, "citation 123"));
    TaxonImpl homoSapiens = new TaxonImpl("Homo sapiens", "homoSapiensId");
    homoSapiens.setPath("one two three");
    final Specimen human = nodeFactory.createSpecimen(study, homoSapiens);
    TaxonImpl dogTaxon = new TaxonImpl("Canis familiaris", null);
    final Specimen dog = nodeFactory.createSpecimen(study, dogTaxon);
    human.ate(dog);
    resolveNames();
    final File baseDirNames = createBaseDir("target/sitemap/names");
    final GraphExporter siteMapForNames = new ExporterSiteMapForNames();
    siteMapForNames.export(getGraphDb(), baseDirNames.getAbsolutePath());
    assertSiteMap(baseDirNames, "http://www.globalbioticinteractions.org/?interactionType=interactsWith&sourceTaxon=Homo%20sapiens", "https://depot.globalbioticinteractions.org/snapshot/target/data/sitemap/names/sitemap.xml.gz");
}
Also used : Study(org.eol.globi.domain.Study) Specimen(org.eol.globi.domain.Specimen) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) File(java.io.File) Test(org.junit.Test)

Example 24 with StudyImpl

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

the class NameResolverTest method iNaturalistTaxon.

@Test
public void iNaturalistTaxon() throws NodeFactoryException {
    Specimen someOtherOrganism = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Blaus bla", "INAT_TAXON:58831"));
    Specimen someOtherOrganism2 = nodeFactory.createSpecimen(nodeFactory.createStudy(new StudyImpl("bla", null, null, null)), new TaxonImpl("Redus rha", "INAT_TAXON:126777"));
    someOtherOrganism.ate(someOtherOrganism2);
    final NameResolver nameResolver = new NameResolver(getGraphDb(), new NonResolvingTaxonIndex(getGraphDb()));
    nameResolver.setBatchSize(1L);
    nameResolver.resolve();
    Taxon resolvedTaxon = taxonIndex.findTaxonById("INAT_TAXON:58831");
    assertThat(resolvedTaxon, is(notNullValue()));
    assertThat(resolvedTaxon.getExternalId(), is("INAT_TAXON:58831"));
    assertThat(resolvedTaxon.getName(), is("Blaus bla"));
    Taxon resolvedTaxon2 = taxonIndex.findTaxonByName("Blaus bla");
    assertThat(resolvedTaxon2, is(notNullValue()));
    assertThat(resolvedTaxon2.getExternalId(), is("INAT_TAXON:58831"));
}
Also used : Specimen(org.eol.globi.domain.Specimen) NonResolvingTaxonIndex(org.eol.globi.taxon.NonResolvingTaxonIndex) TaxonImpl(org.eol.globi.domain.TaxonImpl) Taxon(org.eol.globi.domain.Taxon) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

Example 25 with StudyImpl

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

the class ReportGeneratorTest method generateStudySourceOrganizationReports.

@Test
public void generateStudySourceOrganizationReports() throws NodeFactoryException {
    StudyImpl study1 = new StudyImpl("a title", "az source", null, "citation");
    study1.setSourceId("az/source1");
    createStudy(study1);
    StudyImpl study2 = new StudyImpl("another title", "az source", null, "citation");
    study2.setSourceId("az/source2");
    createStudy(study2);
    StudyImpl study3 = new StudyImpl("yet another title", "zother source", null, null);
    study3.setSourceId("zother/source");
    createStudy(study3);
    resolveNames();
    new ReportGenerator(getGraphDb()).generateReportForSourceOrganizations();
    IndexHits<Node> reports = getGraphDb().index().forNodes("reports").get(StudyConstant.SOURCE_ID, "az");
    Node reportNode = reports.getSingle();
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(2));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
    assertThat((String) reportNode.getProperty(StudyConstant.SOURCE_ID), is("az"));
    reports.close();
    IndexHits<Node> otherReports = getGraphDb().index().forNodes("reports").get(StudyConstant.SOURCE_ID, "zother");
    Node otherReport = otherReports.getSingle();
    assertThat((String) otherReport.getProperty(StudyConstant.SOURCE_ID), is("zother"));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(1));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
    assertThat((Integer) otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Also used : Node(org.neo4j.graphdb.Node) StudyImpl(org.eol.globi.domain.StudyImpl) Test(org.junit.Test)

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