use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class NodeFactoryWithDatasetContextTest method createStudy.
@Test
public void createStudy() {
NodeFactory factory = Mockito.mock(NodeFactory.class);
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
StudyImpl study = new StudyImpl("some title", "some source", "some doi", "some citation");
study.setExternalId("some:id");
factoryWithDS.createStudy(study);
ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
verify(factory).createStudy(argument.capture());
assertEquals("globi:some/namespace", argument.getValue().getSourceId());
assertEquals("some title", argument.getValue().getTitle());
assertEquals("some citation", argument.getValue().getCitation());
assertEquals("some doi", argument.getValue().getDOI());
assertEquals("some:id", argument.getValue().getExternalId());
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class GraphExporterImpl method export.
private void export(List<Study> importedStudies, String exportPath, String filename, DarwinCoreExporter studyExporter, FileWriter darwinCoreMeta) throws IOException {
OutputStreamWriter writer = openStream(exportPath + filename);
for (Study importedStudy : importedStudies) {
boolean includeHeader = importedStudies.indexOf(importedStudy) == 0;
studyExporter.exportStudy(importedStudy, writer, includeHeader);
}
closeStream(exportPath + filename, writer);
LOG.info("darwin core meta file writing... ");
studyExporter.exportDarwinCoreMetaTable(darwinCoreMeta, filename);
LOG.info("darwin core meta file written. ");
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class GraphExporterImpl method export.
@Override
public void export(GraphDatabaseService graphService, String baseDir) throws StudyImporterException {
try {
FileUtils.forceMkdir(new File(baseDir));
} catch (IOException e) {
throw new StudyImporterException("failed to create output dir [" + baseDir + "]", e);
}
LOG.info("site maps generating... ");
File siteMapDir = new File(baseDir, "sitemap");
final File citations = new File(siteMapDir, "citations");
LOG.info("site maps at [" + citations.getAbsolutePath() + "] generating... ");
new ExporterSiteMapForCitations().export(graphService, citations.getAbsolutePath());
LOG.info("site maps at [" + citations.getAbsolutePath() + "] generated.");
final File names = new File(siteMapDir, "names");
LOG.info("site maps at [" + names.getAbsolutePath() + "] generating... ");
final GraphExporter exporter = new ExporterSiteMapForNames();
exporter.export(graphService, names.getAbsolutePath());
LOG.info("site maps at [" + names.getAbsolutePath() + "] generated.");
LOG.info("site maps generated... ");
List<Study> studies = NodeUtil.findAllStudies(graphService);
exportNames(baseDir, studies);
// export to taxa for now, to avoid additional assemblies
new ExportFlatInteractions().export(graphService, "tsv");
new ExportCitations().export(graphService, "tsv");
exportNCBILinkOut(graphService, baseDir, studies);
exportDataOntology(studies, baseDir);
exportDarwinCoreAggregatedByStudy(baseDir, studies);
exportDarwinCoreAll(baseDir, studies);
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForBroseIT method importAll.
@Test
public void importAll() throws StudyImporterException {
StudyImporterForBrose studyImporterForBrose = new StudyImporterForBrose(new ParserFactoryLocal(), nodeFactory);
studyImporterForBrose.importStudy();
List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
assertThat(studies.size(), is(20));
for (Study study : studies) {
assertThat(study.getTitle(), is(notNullValue()));
assertThat(study.getSource(), is(notNullValue()));
assertThat(StringUtils.isBlank(study.getCitation()), is(false));
}
}
use of org.eol.globi.domain.Study in project eol-globi-data by jhpoelen.
the class StudyImporterForByrnesTest method importAll.
@Test
public void importAll() throws StudyImporterException {
StudyImporterForByrnes studyImporterForByrnes = new StudyImporterForByrnes(new ParserFactoryLocal(), nodeFactory);
studyImporterForByrnes.importStudy();
resolveNames();
List<String> citationList = new ArrayList<String>();
Set<String> citations = new HashSet<String>();
List<Study> studies = NodeUtil.findAllStudies(getGraphDb());
assertTrue(studies.size() > 0);
for (Study study : studies) {
assertThat(study.getTitle(), is(notNullValue()));
assertThat(study.getSource(), is(notNullValue()));
assertThat(study.getCitation(), is(notNullValue()));
citations.add(study.getCitation());
citationList.add(study.getCitation());
}
assertThat("found duplicates in citation list", citationList.size(), is(citations.size()));
assertNotNull(taxonIndex.findTaxonByName("Anisotremus davidsonii"));
assertThat(citations, hasItem("Pennings, S. C. 1990. Size-related shifts in herbivory: specialization in the sea hare Aplysia californica Cooper. Journal of Experimental Marine Biology and Ecology 142:43-61."));
assertThat(citations, hasItem("Barry, J. and M. Ehret. 1993. Diet, food preference, and algal availability for fishes and crabs on intertidal reef communities in southern California. Environmental Biology of Fishes 37:75-95."));
assertThat(citations, hasItem("Byrnes, J.E. et al., 2011. Climate-driven increases in storm frequency simplify kelp forest food webs. Global Change Biology, 17(8), pp.2513–2524. Available at: http://dx.doi.org/10.1111/j.1365-2486.2011.02409.x."));
assertThat(citations, not(hasItem("17(8)")));
ExecutionEngine executionEngine = new ExecutionEngine(getGraphDb());
ExecutionResult result = executionEngine.execute("START taxon = node:taxons(name=\"Strongylocentrotus purpuratus\")" + " MATCH taxon<-[:CLASSIFIED_AS]-specimen-[:ATE]->prey-[:CLASSIFIED_AS]->preyTaxon " + " RETURN collect(distinct(preyTaxon.name))");
assertThat(result.dumpToString(), containsString("Bossiella orbigiana"));
}
Aggregations