use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class StudyImporterForGrayTest method createImporter.
private StudyImporterForGray createImporter() throws IOException {
StudyImporterForGray gray = new StudyImporterForGray(new ParserFactoryLocal(), nodeFactory);
JsonNode config = new ObjectMapper().readTree("{ \"citation\": \"Gray C, Ma A, Perkins D, Hudson L, Figueroa D, Woodward G (2015). Database of trophic interactions. Zenodo. http://dx.doi.org/10.5281/zenodo.13751\",\n" + " \"doi\": \"http://dx.doi.org/10.5281/zenodo.13751\",\n" + " \"format\": \"gray\",\n" + " \"resources\": {\n" + " \"links\": \"https://zenodo.org/record/13751/files/trophic.links.2014-11-10.csv\" \n" + " }\n" + "}");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"));
dataset.setConfig(config);
gray.setDataset(dataset);
return gray;
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetWithCacheTest method datasetLastAccessedAt.
private DatasetWithCache datasetLastAccessedAt(String lastAccessed) {
Cache cache = Mockito.mock(Cache.class);
CachedURI cacheURI = Mockito.mock(CachedURI.class);
when(cacheURI.getAccessedAt()).thenReturn(lastAccessed);
when(cache.asMeta(any(URI.class))).thenReturn(cacheURI);
DatasetImpl datasetUncached = new DatasetImpl("some/namespace", URI.create("some:bla"));
return new DatasetWithCache(datasetUncached, cache);
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class DatasetFinderLocal method datasetFor.
@Override
public Dataset datasetFor(String namespace) throws DatasetFinderException {
Dataset dataset;
try {
final URI sourceURI = findLastCachedDatasetURI(namespace);
dataset = sourceURI == null ? null : DatasetFactory.datasetFor(namespace, new DatasetFinder() {
@Override
public Collection<String> findNamespaces() throws DatasetFinderException {
return Collections.singletonList(namespace);
}
@Override
public Dataset datasetFor(String s) throws DatasetFinderException {
Dataset dataset = new DatasetImpl(namespace, sourceURI);
return new DatasetWithCache(dataset, cacheFactory.cacheFor(dataset));
}
});
} catch (IOException e) {
throw new DatasetFinderException("failed to access [" + namespace + "]", e);
}
if (dataset == null) {
throw new DatasetFinderException("failed to retrieve/cache dataset in namespace [" + namespace + "]");
}
return dataset;
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class NodeFactoryWithDatasetContextTest method getOrCreateStudy.
@Test
public void getOrCreateStudy() throws NodeFactoryException {
NodeFactory factory = Mockito.mock(NodeFactory.class);
Dataset dataset = new DatasetImpl("some/namespace", URI.create("some:uri"));
NodeFactoryWithDatasetContext factoryWithDS = new NodeFactoryWithDatasetContext(factory, dataset);
factoryWithDS.getOrCreateStudy(new StudyImpl("some title"));
ArgumentCaptor<Study> argument = ArgumentCaptor.forClass(Study.class);
verify(factory).getOrCreateStudy(argument.capture());
assertEquals("globi:some/namespace", argument.getValue().getSourceId());
assertEquals("some title", argument.getValue().getTitle());
}
use of org.eol.globi.service.DatasetImpl in project eol-globi-data by jhpoelen.
the class ReferenceUtilTest method generateSourceCitation.
@Test
public void generateSourceCitation() throws IOException, StudyImporterException {
final InputStream inputStream = getClass().getResourceAsStream("/org/eol/globi/data/test-meta-globi.json");
DatasetImpl dataset = new DatasetImpl(null, URI.create("http://base"));
dataset.setConfig(new ObjectMapper().readTree(inputStream));
String citation = CitationUtil.sourceCitationLastAccessed(dataset);
assertThat(citation, startsWith("Seltzer, Carrie; Wysocki, William; Palacios, Melissa; Eickhoff, Anna; Pilla, Hannah; Aungst, Jordan; Mercer, Aaron; Quicho, Jamie; Voss, Neil; Xu, Man; J. Ndangalasi, Henry; C. Lovett, Jon; J. Cordeiro, Norbert (2015): Plant-animal interactions from Africa. figshare. https://dx.doi.org/10.6084/m9.figshare.1526128. Accessed at <https://ndownloader.figshare.com/files/2231424>"));
}
Aggregations