use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForMetaTableIT method importAll.
public static void importAll(InteractionListener interactionListener, DatasetImporterForMetaTable.TableParserFactory tableFactory, String baseUrl, String resource) throws IOException, StudyImporterException {
final InputStream inputStream = ResourceUtil.asInputStream(resource, inStream -> inStream);
final JsonNode config = new ObjectMapper().readTree(inputStream);
final Dataset dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(config);
for (JsonNode table : DatasetImporterForMetaTable.collectTables(dataset)) {
DatasetImporterForMetaTable.importTable(interactionListener, tableFactory, table, new DatasetImpl(null, URI.create(baseUrl), inStream -> inStream), null);
}
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForPensoftIT method importStudy.
@Test
public void importStudy() throws StudyImporterException, URISyntaxException {
final DatasetImporterForPensoft importer = new DatasetImporterForPensoft(new ParserFactoryLocal(), null);
final Dataset dataset = new DatasetImpl("some/name", URI.create("some:uri"), in -> in);
final ObjectNode objectNode = new ObjectMapper().createObjectNode();
final URL resource = getClass().getResource("pensoft/annotated-tables-first-two.json");
objectNode.put("url", resource.toURI().toString());
objectNode.put("citation", "some dataset citation");
dataset.setConfig(objectNode);
List<Map<String, String>> links = new ArrayList<>();
importer.setDataset(dataset);
importer.setInteractionListener(new InteractionListener() {
@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
links.add(interaction);
}
});
importer.importStudy();
assertThat(links.size(), is(121));
assertThat(links.get(0), hasEntry("Family Name", "Acanthaceae"));
assertThat(links.get(0), hasEntry("Family Name_expanded_taxon_name", "Acanthaceae"));
assertThat(links.get(0), hasEntry("Family Name_expanded_taxon_id", "http://openbiodiv.net/4B689A17-2541-4F5F-A896-6F0C2EEA3FB4"));
assertThat(links.get(0), hasEntry("referenceUrl", "https://doi.org/10.3897/zookeys.306.5455"));
assertThat(links.get(0), hasEntry("referenceDoi", "10.3897/zookeys.306.5455"));
assertThat(links.get(0), hasEntry("referenceCitation", "Dewi Sartiami, Laurence A. Mound. 2013. Identification of the terebrantian thrips (Insecta, Thysanoptera) associated with cultivated plantsĀ inĀ Java, Indonesia. ZooKeys. https://doi.org/10.3897/zookeys.306.5455"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForRSSTest method useUrlOnly.
@Test
public void useUrlOnly() throws IOException {
DatasetImpl dataset = datasetFor("{ \"url\": \"bar\" }");
assertThat(DatasetImporterForRSS.getRSSEndpoint(dataset), is("bar"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForRSSTest method useUrl.
@Test
public void useUrl() throws IOException {
DatasetImpl dataset = datasetFor("{ \"url\": \"bar\", " + "\"resources\": { \"rss\": \"foo\" } " + "}");
assertThat(DatasetImporterForRSS.getRSSEndpoint(dataset), is("bar"));
}
use of org.globalbioticinteractions.dataset.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetImporterForRSSTest method useRssNamedProperty.
@Test
public void useRssNamedProperty() throws IOException {
DatasetImpl dataset = datasetFor("{ \"url\": \"bar\", " + "\"resources\": { \"rss\": \"foo\" } " + "}");
assertThat(DatasetImporterForRSS.getRSSEndpoint(dataset), is("bar"));
}
Aggregations