use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterForTSVTest method assertEventDate.
private void assertEventDate(String header) throws StudyImporterException {
AtomicInteger atomicInteger = new AtomicInteger(0);
String firstFewLines = header + "\tITIS:632267\tRousettus aegyptiacus\t\t\t\t\thttp://purl.obolibrary.org/obo/RO_0002470\teats\t\tITIS:28882\tCitrus sp.\thttp://purl.obolibrary.org/obo/PO_0009001\tfruit\t\t\tGEONAMES:298795\tHatay, Adana, Mersin, and Antalya, Turkey\t\t\t1999-09/2003-09\t\thttp://journals.tubitak.gov.tr/zoology/issues/zoo-08-32-1/zoo-32-1-2-0604-8.pdf\tAlbayrak, I., Aşan, N., & Yorulmaz, T. (2008). The natural history of the Egyptian fruit bat, Rousettus aegyptiacus, in Turkey (Mammalia: Chiroptera). Turkish Journal of Zoology, 32(1), 11-18.";
Dataset dataset = getDataset(new TreeMap<URI, String>() {
{
put(URI.create("/interactions.tsv"), firstFewLines);
}
});
DatasetImporterForTSV importer = new DatasetImporterForTSV(null, nodeFactory);
importer.setDataset(dataset);
importer.setInteractionListener(link -> {
atomicInteger.incrementAndGet();
assertThat(link.get(DatasetImporterForMetaTable.EVENT_DATE), is(not(nullValue())));
assertThat(link.get(SOURCE_TAXON_NAME), is("Rousettus aegyptiacus"));
assertThat(link.get(TARGET_TAXON_NAME), is("Citrus sp."));
});
importStudy(importer);
assertThat(atomicInteger.get(), is(1));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterForRSSIT method importUCSB.
@Test
public void importUCSB() throws StudyImporterException, IOException {
File tempFile = File.createTempFile("test", ".tmp", new File("target"));
DatasetImporter importer = new StudyImporterTestFactory(nodeFactory).instantiateImporter(DatasetImporterForRSS.class);
final DatasetLocal dataset = new DatasetLocal(inStream -> inStream);
DatasetWithCache datasetWithCache = new DatasetWithCache(dataset, new CachePullThrough("testing", tempFile.getParentFile().getAbsolutePath()));
ObjectNode rssUrl = new ObjectMapper().createObjectNode();
rssUrl.put("rss", "https://symbiota.ccber.ucsb.edu/webservices/dwc/rss.xml");
ObjectNode configNode = new ObjectMapper().createObjectNode();
configNode.set("resources", rssUrl);
datasetWithCache.setConfig(configNode);
importer.setDataset(datasetWithCache);
importStudy(importer);
final Dataset datasetImported = nodeFactory.getOrCreateDataset(dataset);
assertThat(datasetImported.getNamespace(), Is.is("jhpoelen/eol-globidata"));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class DatasetImporterForSeltmannTest method importSome.
@Test
public void importSome() throws StudyImporterException, IOException {
DatasetImporterForSeltmann importer = new DatasetImporterForSeltmann(null, nodeFactory);
Dataset dataset = new DatasetLocal(inStream -> inStream);
JsonNode config = new ObjectMapper().readTree("{\"citation\": \"some citation\", \"resources\": {\"archive\": \"seltmann/testArchive.zip\"}}");
dataset.setConfig(config);
importer.setDataset(dataset);
importStudy(importer);
List<StudyNode> allStudies = NodeUtil.findAllStudies(getGraphDb());
for (StudyNode allStudy : allStudies) {
assertThat(allStudy.getCitation(), is("Digital Bee Collections Network, 2014 (and updates). Version: 2015-03-18. National Science Foundation grant DBI 0956388"));
AtomicBoolean success = new AtomicBoolean(false);
NodeUtil.handleCollectedRelationships(new NodeTypeDirection(allStudy.getUnderlyingNode()), relationship -> {
SpecimenNode spec = new SpecimenNode(relationship.getEndNode());
final String recordId = (String) spec.getUnderlyingNode().getProperty("idigbio:recordID");
assertThat(recordId, is(notNullValue()));
assertThat(spec.getExternalId(), is(recordId));
Term basisOfRecord = spec.getBasisOfRecord();
assertThat(basisOfRecord.getId(), either(is("TEST:PreservedSpecimen")).or(is("TEST:LabelObservation")));
assertThat(basisOfRecord.getName(), either(is("PreservedSpecimen")).or(is("LabelObservation")));
success.set(true);
});
assertTrue(success.get());
}
assertThat(taxonIndex.findTaxonByName("Megandrena mentzeliae"), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Mentzelia tricuspis"), is(notNullValue()));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class CmdGenerateReportTest method generateIndividualStudySourceReports.
@Test
public void generateIndividualStudySourceReports() throws NodeFactoryException {
Dataset originatingDataset1 = nodeFactory.getOrCreateDataset(new DatasetImpl("az/source", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study1 = new StudyImpl("a title", null, "citation");
study1.setOriginatingDataset(originatingDataset1);
createStudy(study1);
StudyImpl study2 = new StudyImpl("another title", null, "citation");
study2.setOriginatingDataset(originatingDataset1);
createStudy(study2);
Dataset originatingDataset3 = nodeFactory.getOrCreateDataset(new DatasetImpl("zother/source", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study3 = new StudyImpl("yet another title", null, null);
study3.setOriginatingDataset(originatingDataset3);
createStudy(study3);
resolveNames();
new CmdGenerateReport(getGraphDb(), cacheService).generateReportForSourceIndividuals();
String escapedQuery = QueryParser.escape("globi:az/source");
IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, escapedQuery);
Node reportNode = reports.getSingle();
assertThat(reportNode.getProperty(StudyConstant.SOURCE_ID), is("globi:az/source"));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
reports.close();
IndexHits<Node> otherReports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, "globi\\:zother\\/source");
Node otherReport = otherReports.getSingle();
assertThat(otherReport.getProperty(StudyConstant.SOURCE_ID), is("globi:zother/source"));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
use of org.globalbioticinteractions.dataset.Dataset in project eol-globi-data by jhpoelen.
the class CmdGenerateReportTest method generateStudySourceOrganizationReports.
@Test
public void generateStudySourceOrganizationReports() throws NodeFactoryException {
Dataset originatingDataset1 = nodeFactory.getOrCreateDataset(new DatasetImpl("az/source1", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study1 = new StudyImpl("a title", null, "citation");
study1.setOriginatingDataset(originatingDataset1);
createStudy(study1);
Dataset originatingDataset2 = nodeFactory.getOrCreateDataset(new DatasetImpl("az/source2", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study2 = new StudyImpl("another title", null, "citation");
study2.setOriginatingDataset(originatingDataset2);
createStudy(study2);
Dataset originatingDataset3 = nodeFactory.getOrCreateDataset(new DatasetImpl("zother/source", URI.create("http://example.com"), inStream -> inStream));
StudyImpl study3 = new StudyImpl("yet another title", null, null);
study3.setOriginatingDataset(originatingDataset3);
createStudy(study3);
resolveNames();
new CmdGenerateReport(getGraphDb(), cacheService).generateReportForSourceOrganizations();
IndexHits<Node> reports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, "globi\\:az");
Node reportNode = reports.getSingle();
assertThat(reportNode.getProperty(StudyConstant.SOURCE_ID), is("globi:az"));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(2));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(8));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(reportNode.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
reports.close();
IndexHits<Node> otherReports = getGraphDb().index().forNodes("reports").query(StudyConstant.SOURCE_ID, "globi\\:zother");
Node otherReport = otherReports.getSingle();
assertThat(otherReport.getProperty(StudyConstant.SOURCE_ID), is("globi:zother"));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_STUDIES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_SOURCES), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DATASETS), is(1));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_INTERACTIONS), is(4));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA), is(3));
assertThat(otherReport.getProperty(PropertyAndValueDictionary.NUMBER_OF_DISTINCT_TAXA_NO_MATCH), is(2));
}
Aggregations