use of org.globalbioticinteractions.dataset.DatasetProxy in project eol-globi-data by jhpoelen.
the class DatasetProxyTest method getTestDataset.
public DatasetProxy getTestDataset(JsonNode config, JsonNode configProxy) {
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(config);
DatasetProxy datasetProxy = new DatasetProxy(dataset);
datasetProxy.setConfig(configProxy);
return datasetProxy;
}
use of org.globalbioticinteractions.dataset.DatasetProxy in project eol-globi-data by jhpoelen.
the class DatasetImporterForMetaTable method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try {
for (JsonNode tableConfig : collectTables(dataset)) {
Dataset datasetProxy = new DatasetProxy(dataset);
datasetProxy.setConfig(tableConfig);
InteractionListener interactionListener = getInteractionListener();
final InteractionListener listener = new TableInteractionListenerProxy(datasetProxy, interactionListener);
importTable(listener, new TableParserFactoryImpl(), tableConfig, datasetProxy, getLogger());
}
} catch (IOException | NodeFactoryException e) {
String msg = "problem importing from [" + getBaseUrl() + "]";
LogUtil.logError(getLogger(), msg, e);
throw new StudyImporterException(msg, e);
}
}
use of org.globalbioticinteractions.dataset.DatasetProxy in project eol-globi-data by jhpoelen.
the class DatasetProxyTest method getMappedResource.
@Test
public void getMappedResource() throws IOException, URISyntaxException {
URL original = getClass().getResource("/org/globalbioticinteractions/content/original.txt");
URL proxied = getClass().getResource("/org/globalbioticinteractions/content/proxied.txt");
JsonNode configProxy = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"" + proxied.toURI() + "\" } }");
DatasetImpl dataset = new DatasetImpl("some/namespace", URI.create("http://example.com"), inStream -> inStream);
dataset.setConfig(null);
final String hashOfOriginal = "0682c5f2076f099c34cfdd15a9e063849ed437a49677e6fcc5b4198c76575be5";
final String hashOfProxied = "b09f17ea1b5ca77b7a01a3ed62c84b38578817eddb34f827666c898a27504f67";
DatasetProxy datasetProxy = new DatasetProxy(dataset);
datasetProxy.setConfig(configProxy);
DatasetProxy testDataset = datasetProxy;
TestHashUtil.assertContentHash(testDataset.retrieve(URI.create("archive")), hashOfProxied);
JsonNode config = new ObjectMapper().readTree("{ \"resources\": { \"archive\": \"" + original.toURI() + "\" } }");
testDataset = getTestDataset(config, configProxy);
TestHashUtil.assertContentHash(testDataset.retrieve(URI.create("archive")), hashOfProxied);
testDataset = getTestDataset(config, null);
TestHashUtil.assertContentHash(testDataset.retrieve(URI.create("archive")), hashOfOriginal);
}
use of org.globalbioticinteractions.dataset.DatasetProxy in project eol-globi-data by jhpoelen.
the class DatasetImportUtilTest method getReferences.
public static List<Dataset> getReferences(Dataset dataset) {
List<Dataset> referenceList = new ArrayList<>();
final JsonNode config = dataset.getConfig();
final JsonNode references = config.get("references");
if (references != null && references.isArray()) {
for (JsonNode reference : references) {
final DatasetProxy datasetProxy = new DatasetProxy(dataset);
datasetProxy.setConfig(reference);
referenceList.add(datasetProxy);
}
}
return referenceList;
}
use of org.globalbioticinteractions.dataset.DatasetProxy in project eol-globi-data by jhpoelen.
the class DatasetImporterForRSS method embeddedDatasetFor.
static Dataset embeddedDatasetFor(final Dataset datasetOrig, final String embeddedCitation, final URI embeddedArchiveURI, final Map<String, String> properties) {
String hasDependencies = datasetOrig.getOrDefault(HAS_DEPENDENCIES, "false");
ObjectNode config = new ObjectMapper().createObjectNode();
config.put("citation", embeddedCitation);
config.put("format", properties.getOrDefault("format", PropertyAndValueDictionary.MIME_TYPE_DWCA));
config.put("url", embeddedArchiveURI.toString());
config.put(HAS_DEPENDENCIES, hasDependencies);
config.put("isDependency", properties.getOrDefault("isDependency", "false"));
DatasetProxy dataset = new DatasetProxy(datasetOrig) {
@Override
public URI getArchiveURI() {
return embeddedArchiveURI;
}
};
dataset.setConfig(config);
return dataset;
}
Aggregations