use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class ReferenceUtilTest method sourceCitationDatasetNoConfig.
@Test
public void sourceCitationDatasetNoConfig() {
String citation = CitationUtil.sourceCitationLastAccessed(new DatasetImpl("some/namespace", URI.create("http://example")));
assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class ReferenceUtilTest method sourceCitationDataset.
@Test
public void sourceCitationDataset() throws IOException {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example"));
JsonNode config = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"archive.zip\" } }");
dataset.setConfig(config);
String citation = CitationUtil.sourceCitationLastAccessed(dataset);
assertThat(citation, startsWith("<http://example>. Accessed at <http://example> on"));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForDunneTest method importStudy.
@Test
public void importStudy() throws StudyImporterException, IOException {
String configJson = "{ \"citation\": \"blabla\",\n" + " \"format\": \"dunne\",\n" + " \"resources\": {\n" + " \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/master/nodes.tsv\",\n" + " \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakIntertidal/master/links.tsv\"\n" + " },\n" + " \"location\": {\n" + " \"locality\": {\n" + " \"id\": \"GEONAMES:5873327\",\n" + " \"name\": \"Sanak Island, Alaska, USA\"\n" + " },\n" + " \"latitude\": 60,\n" + " \"longitude\": 60\n" + " }\n" + "}";
JsonNode jsonNode = new ObjectMapper().readTree(configJson);
DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"));
dunne2016.setConfig(jsonNode);
ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
StudyImporterForDunne importer = new StudyImporterForDunne(parserFactory, nodeFactory);
importer.setDataset(dunne2016);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertThat(study, is(notNullValue()));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
int count = 0;
for (Relationship specimen : specimens) {
count++;
}
assertThat(count, is(1804 * 2));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForDunneTest method importStudy2.
@Test
public void importStudy2() throws StudyImporterException, IOException {
String configJson = "{ \"citation\": \"blabla\",\n" + " \"format\": \"dunne\",\n" + " \"resources\": {\n" + " \"nodes\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/master/nodes.tsv\",\n" + " \"links\": \"https://raw.githubusercontent.com/globalbioticinteractions/dunne2016SanakNearshore/master/links.tsv\"\n" + " },\n" + " \"location\": {\n" + " \"locality\": {\n" + " \"id\": \"GEONAMES:5873327\",\n" + " \"name\": \"Sanak Island, Alaska, USA\"\n" + " },\n" + " \"latitude\": 60,\n" + " \"longitude\": 60\n" + " }\n" + "}";
DatasetImpl dunne2016 = new DatasetImpl("dunne2016", URI.create("http://example.com"));
dunne2016.setConfig(new ObjectMapper().readTree(configJson));
ParserFactory parserFactory = new ParserFactoryForDataset(dunne2016);
StudyImporterForDunne importer = new StudyImporterForDunne(parserFactory, nodeFactory);
importer.setDataset(dunne2016);
importStudy(importer);
Study study = getStudySingleton(getGraphDb());
assertThat(study, is(notNullValue()));
assertThat(study.getSource(), containsString("Accessed at "));
Iterable<Relationship> specimens = NodeUtil.getSpecimens(study);
int count = 0;
for (Relationship specimen : specimens) {
count++;
}
assertThat(count, is(6774 * 2));
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForCoetzerTest method importSome.
@Test
public void importSome() throws StudyImporterException, IOException {
StudyImporterForCoetzer importer = new StudyImporterForCoetzer(null, nodeFactory);
DatasetImpl dataset = new DatasetLocal();
JsonNode config = new ObjectMapper().readTree("{\"citation\": \"source citation\", \"resources\": {\"archive\": \"coetzer/CatalogOfAfrotropicalBees.zip\"}}");
dataset.setConfig(config);
importer.setDataset(dataset);
importStudy(importer);
List<Study> allStudies = NodeUtil.findAllStudies(getGraphDb());
for (Study allStudy : allStudies) {
assertThat(allStudy.getSource(), startsWith("source citation"));
assertThat(allStudy.getSource(), containsString("Accessed at"));
}
assertThat(taxonIndex.findTaxonByName("Agrostis tremula"), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Coelioxys erythrura"), is(notNullValue()));
assertThat(taxonIndex.findTaxonByName("Patellapis namaquensis"), is(notNullValue()));
}
Aggregations