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(""));
}
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);
}
}
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");
}
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"));
}
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));
}
Aggregations