use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class DatasetFinderWithCacheTest method datasetCached.
private Dataset datasetCached() throws IOException, URISyntaxException {
Dataset dataset = Mockito.mock(Dataset.class);
when(dataset.getNamespace()).thenReturn("some/namespace");
when(dataset.getArchiveURI()).thenReturn(getClass().getResource("archive.zip").toURI());
Cache cache = CacheUtil.cacheFor("some/namespace", cachePath);
return new DatasetWithCache(dataset, cache);
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class StudyImporterForMetaTableIT method importNHMStatic.
@Test
public void importNHMStatic() throws IOException, StudyImporterException {
final List<Map<String, String>> links = new ArrayList<Map<String, String>>();
final InteractionListener interactionListener = properties -> links.add(properties);
final StudyImporterForMetaTable.TableParserFactory tableFactory = (config, dataset) -> {
String firstFewLines = "\"InteractionID\",\"InteractionURL\",\"Species1UUID\",\"Species1Name\",\"Species1LifeCycleStage\",\"Species1OrganismPart\",\"Species1Status\",\"InteractionType\",\"InteractionOntologyURL\",\"Species2UUID\",\"Species2Name\",\"Species2LifeCycleStage\",\"Species2OrganismPart\",\"Species2Status\",\"LocationUUID\",\"LocationName\",\"LocationCountryName\",\"ISO2\",\"Importance\",\"InteractionRecordType\",\"Reference\",\"ReferenceDOI\",\"Reference Page\",\"Notes\"\n" + "\"4bee827f-c9f5-4c0e-9db3-e40a6e4d8008\",\"http://phthiraptera.info/node/94209\",\"c8faa033-237b-40b9-9b76-d9e7fcff9238\",\"Menacanthus alaudae\",\"\",\"\",\"\",\"ectoparasite of\",\"http://purl.obolibrary.org/obo/RO_0002632\",\"e275d77c-e993-4de0-981f-b3f39fd4da9b\",\"Acanthis flavirostris\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"310\",\"[REF: Palma, Price & Hellenthal, 1998:310]\"\n" + "\"80e66e7c-75db-467f-9a89-a11f94d58eb3\",\"http://phthiraptera.info/node/94210\",\"fe5b2e50-b414-41d9-840d-189e732b2ea5\",\"Ricinus fringillae flammeae\",\"\",\"\",\"\",\"ectoparasite of\",\"http://purl.obolibrary.org/obo/RO_0002632\",\"f26a1199-c0bb-4d7c-a511-2fe6284c5378\",\"Acanthis flammea flammea\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"Self citation to checklist added. Requires page number.\"\n" + "\"001ee8aa-dbab-43b8-9137-a61565ccf41b\",\"http://phthiraptera.info/node/94211\",\"ee17d179-9f60-4198-ac49-dc9dab3ae529\",\"Brueelia sibirica\",\"\",\"\",\"\",\"ectoparasite of\",\"http://purl.obolibrary.org/obo/RO_0002632\",\"f26a1199-c0bb-4d7c-a511-2fe6284c5378\",\"Acanthis flammea flammea\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"Self citation to checklist added. Requires page number.\"\n" + "\"d0929673-2f4c-49ec-877f-116e74ea360e\",\"http://phthiraptera.info/node/94212\",\"46084bc3-cfbf-4e01-96f8-5ecb50bc5ff9\",\"Ricinus fringillae\",\"\",\"\",\"\",\"ectoparasite of\",\"http://purl.obolibrary.org/obo/RO_0002632\",\"2027cf09-f15d-4c2b-be28-9cb00fabf308\",\"Acanthis flammea\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"204\",\"[REF: Rheinwald, 1968:204]\"\n";
return new LabeledCSVParser(new CSVParser(IOUtils.toInputStream(firstFewLines)));
};
final String baseUrl = "https://raw.githubusercontent.com/globalbioticinteractions/natural-history-museum-london-interactions-bank/master";
final String resource = baseUrl + "/globi.json";
importAll(interactionListener, tableFactory, baseUrl, resource);
assertThat(links.size(), is(4));
for (Map<String, String> firstLine : links) {
assertNotNull(firstLine.get(StudyImporterForTSV.INTERACTION_TYPE_NAME));
assertNotNull(firstLine.get(StudyImporterForTSV.TARGET_TAXON_ID));
assertNotNull(firstLine.get(StudyImporterForTSV.TARGET_TAXON_NAME));
assertNotNull(firstLine.get(StudyImporterForTSV.SOURCE_TAXON_ID));
assertNotNull(firstLine.get(StudyImporterForTSV.SOURCE_TAXON_NAME));
}
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class StudyImporterForMetaTableIT method importAll.
public static void importAll(InteractionListener interactionListener, StudyImporterForMetaTable.TableParserFactory tableFactory, String baseUrl, String resource) throws IOException, StudyImporterException {
final InputStream inputStream = ResourceUtil.asInputStream(resource);
final JsonNode config = new ObjectMapper().readTree(inputStream);
final Dataset dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
dataset.setConfig(config);
for (JsonNode table : StudyImporterForMetaTable.collectTables(dataset)) {
StudyImporterForMetaTable.importTable(interactionListener, tableFactory, table, new DatasetImpl(null, URI.create(baseUrl)), null);
}
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class StudyImporterForHurlbertIT method importAll.
@Test
public void importAll() throws StudyImporterException, DatasetFinderException {
Dataset dataset = datasetFor("hurlbertlab/dietdatabase");
ParserFactory parserFactory = new ParserFactoryForDataset(dataset);
StudyImporter importer = new StudyImporterForHurlbert(parserFactory, nodeFactory);
importer.setDataset(dataset);
importer.setLogger(new ImportLogger() {
@Override
public void warn(LogContext study, String message) {
fail("did not expect warning [" + message + "]");
}
@Override
public void info(LogContext study, String message) {
}
@Override
public void severe(LogContext study, String message) {
fail("did not expect error [" + message + "]");
}
});
importStudy(importer);
List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
assertThat(allStudies.size() > 10, is(true));
assertThat(allStudies.get(0).getOriginatingDataset(), is(notNullValue()));
Taxon formicidae = taxonIndex.findTaxonByName("Formicidae");
assertThat(formicidae.getExternalId(), is(notNullValue()));
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class StudyImporterForHurlbertTest method doImport.
public StudyImporter doImport(final String namespace) throws StudyImporterException {
StudyImporter importer = new StudyImporterForHurlbert(null, nodeFactory);
Dataset dataset = new DatasetImpl(namespace, URI.create("some:uri")) {
@Override
public InputStream getResource(String name) {
return StudyImporterForHurlbertTest.getResource();
}
};
importer.setDataset(dataset);
importStudy(importer);
return importer;
}
Aggregations