Search in sources :

Example 6 with SparqlClient

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"));
}
Also used : SparqlClient(org.globalbioticinteractions.util.SparqlClient) OpenBiodivClientImpl(org.globalbioticinteractions.util.OpenBiodivClientImpl) Test(org.junit.Test) TestUtil.getResourceServiceTest(org.eol.globi.data.TestUtil.getResourceServiceTest)

Example 7 with SparqlClient

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);
}
Also used : SparqlClient(org.globalbioticinteractions.util.SparqlClient) ResourceService(org.eol.globi.service.ResourceService) Test(org.junit.Test)

Example 8 with SparqlClient

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);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) SparqlClient(org.globalbioticinteractions.util.SparqlClient) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

SparqlClient (org.globalbioticinteractions.util.SparqlClient)8 Test (org.junit.Test)7 OpenBiodivClientImpl (org.globalbioticinteractions.util.OpenBiodivClientImpl)6 TestUtil.getResourceServiceTest (org.eol.globi.data.TestUtil.getResourceServiceTest)5 IOException (java.io.IOException)2 ResourceService (org.eol.globi.service.ResourceService)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BufferedReader (java.io.BufferedReader)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1