use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class StudyImporterForMetaTable method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try {
for (JsonNode tableConfig : collectTables(dataset)) {
Dataset datasetProxy = new DatasetProxy(dataset);
datasetProxy.setConfig(tableConfig);
InteractionListenerImpl interactionListener = new InteractionListenerImpl(nodeFactory, getGeoNamesService(), getLogger());
final InteractionListener listener = new TableInteractionListenerProxy(datasetProxy, interactionListener);
importTable(listener, new TableParserFactoryImpl(), tableConfig, datasetProxy, getLogger());
}
} catch (IOException | NodeFactoryException e) {
throw new StudyImporterException("problem importing from [" + getBaseUrl() + "]", e);
}
}
use of org.eol.globi.service.Dataset in project eol-globi-data by jhpoelen.
the class DatasetFinderWithCacheTest method cacheDatasetLocal.
@Test
public void cacheDatasetLocal() throws DatasetFinderException, IOException, URISyntaxException {
Dataset datasetCached = datasetCached();
assertNotNull(datasetCached.getArchiveURI());
URI uri = datasetCached.getResourceURI("globi.json");
assertThat(uri.isAbsolute(), is(true));
assertThat(uri.toString(), startsWith("jar:file:"));
InputStream is = datasetCached.getResource("globi.json");
assertNotNull(is);
JsonNode jsonNode = new ObjectMapper().readTree(is);
assertThat(jsonNode.has("citation"), is(true));
String[] list = new File(cachePath + "/some/namespace").list();
assertThat(list.length, is(2));
assertThat(Arrays.asList(list), hasItem("c9ecb3b0100c890bd00a5c201d06f0a78d92488591f726fbf4de5c88bda39147"));
assertThat(Arrays.asList(list), hasItem("access.tsv"));
}
use of org.eol.globi.service.Dataset 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.Dataset 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.Dataset in project eol-globi-data by jhpoelen.
the class StudyImporterForArthopodEasyCaptureTest method embeddedDataset.
@Test
public void embeddedDataset() throws IOException {
Dataset embeddedDataset = StudyImporterForArthopodEasyCapture.embeddedDatasetFor(getDatasetGroup(), "some other citation", URI.create("http://example.com/archive.zip"));
assertThat(embeddedDataset.getCitation(), is("some other citation"));
assertThat(embeddedDataset.getOrDefault(DatasetConstant.SHOULD_RESOLVE_REFERENCES, "foo"), is("foo"));
assertThat(DatasetUtil.getNamedResourceURI(embeddedDataset, "archive"), is("http://example.com/archive.zip"));
}
Aggregations