use of org.globalbioticinteractions.util.SparqlClient in project eol-globi-data by jhpoelen.
the class DatasetImporterForPensoftIT method retrieveCitationById.
@Test
public void retrieveCitationById() throws IOException {
final SparqlClient sparqlClientImpl = new OpenBiodivClientImpl(getResourceServiceTest());
String citation = DatasetImporterForPensoft.findCitationById("<http://openbiodiv.net/D37E8D1A-221B-FFA6-FFE7-4458FFA0FFC2>", sparqlClientImpl);
assertThat(citation, is("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.util.SparqlClient in project eol-globi-data by jhpoelen.
the class SparqlClientCachingFactoryTest method expectCaching.
@Test
public void expectCaching() throws IOException {
final ResourceService resourceService = singleRequestResourceService();
final SparqlClient openBiodivClient = new SparqlClientCachingFactory().create(resourceService);
assertCitation(openBiodivClient);
assertCitation(openBiodivClient);
}
use of org.globalbioticinteractions.util.SparqlClient in project eol-globi-data by jhpoelen.
the class DatasetImporterForPensoft method importStudy.
@Override
public void importStudy() throws StudyImporterException {
try (SparqlClient sparqlClient = getSparqlClientFactory().create(getDataset())) {
final String url = getDataset().getOrDefault("url", null);
if (StringUtils.isBlank(url)) {
throw new StudyImporterException("please specify [url] in config");
}
final InputStream is = getDataset().retrieve(URI.create(url));
BufferedReader reader = IOUtils.toBufferedReader(new InputStreamReader(is));
String line;
while ((line = reader.readLine()) != null) {
final JsonNode biodivTable = new ObjectMapper().readTree(line);
parseRowsAndEnrich(biodivTable, getInteractionListener(), getLogger(), sparqlClient);
}
} catch (IOException e) {
throw new StudyImporterException("failed to retrieve resource", e);
}
}
Aggregations