Search in sources :

Example 51 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class DOIResolverImplIT method resolveDOIByReferenceNoMatchToBookReview.

@Test
public void resolveDOIByReferenceNoMatchToBookReview() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor("J. N. Kremer and S. W. Nixon, A Coastal Marine Ecosystem:  Simulation and Analysis, Vol. 24 of Ecol. Studies (Springer-Verlag, Berlin, 1978), from p. 12.");
    assertThat(doi, is(nullValue()));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 52 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class DOIResolverImplIT method resolveDOIByReferenceNoMatch2.

@Test
public void resolveDOIByReferenceNoMatch2() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor("Petanidou, T. (1991). Pollination ecology in a phryganic ecosystem. Unp. PhD. Thesis, Aristotelian University, Thessaloniki.");
    assertThat(doi, is(nullValue()));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 53 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class CitationUtil method getDOI.

public static DOI getDOI(Dataset dataset) {
    String doi = dataset.getOrDefault("doi", "");
    DOI doiObj = null;
    URI archiveURI = dataset.getArchiveURI();
    if (StringUtils.isBlank(doi)) {
        String recordZenodo = StringUtils.replace(archiveURI.toString(), ZENODO_URL_PREFIX, "");
        String[] split = recordZenodo.split("/");
        if (split.length > 0) {
            doiObj = new DOI("5281", "zenodo." + split[0]);
        }
    }
    try {
        doiObj = doiObj == null ? DOI.create(doi) : doiObj;
    } catch (MalformedDOIException e) {
        LOG.warn("found malformed doi [" + doi + "]", e);
    }
    return doiObj;
}
Also used : StringUtils.defaultString(org.apache.commons.lang3.StringUtils.defaultString) URI(java.net.URI) DOI(org.globalbioticinteractions.doi.DOI) MalformedDOIException(org.globalbioticinteractions.doi.MalformedDOIException)

Example 54 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class DOIResolverImpl method requestLinks.

private Map<String, DOI> requestLinks(Collection<String> references) throws IOException {
    Map<String, DOI> doiMap = new TreeMap<>();
    for (String reference : references) {
        try {
            URIBuilder builder = new URIBuilder(baseURL + "/works");
            builder.addParameter("sort", "score");
            builder.addParameter("order", "desc");
            builder.addParameter("rows", "1");
            builder.addParameter("select", "DOI,score");
            builder.addParameter("query.bibliographic", reference);
            HttpGet get = new HttpGet(builder.build());
            get.setHeader("Content-Type", "application/json");
            doiMap.put(reference, getMostRelevantDOIMatch(get));
        } catch (URISyntaxException e) {
            LOG.warn("unexpected malformed URI on resolving crossref dois", e);
        } catch (MalformedDOIException e) {
            LOG.warn("received malformed doi from cross ref", e);
        }
    }
    return doiMap;
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) URISyntaxException(java.net.URISyntaxException) TreeMap(java.util.TreeMap) DOI(org.globalbioticinteractions.doi.DOI) URIBuilder(org.apache.http.client.utils.URIBuilder) MalformedDOIException(org.globalbioticinteractions.doi.MalformedDOIException)

Example 55 with DOI

use of org.globalbioticinteractions.doi.DOI in project eol-globi-data by jhpoelen.

the class DOIResolverImpl method extractDOI.

DOI extractDOI(String response) throws IOException, MalformedDOIException {
    ObjectMapper mapper = new ObjectMapper();
    JsonNode jsonNode = mapper.readTree(response);
    DOI doi = null;
    if (jsonNode.has("message")) {
        JsonNode msg = jsonNode.get("message");
        if (msg.has("items")) {
            for (JsonNode items : msg.get("items")) {
                if (hasReasonableMatchScore(items)) {
                    if (items.hasNonNull("DOI")) {
                        doi = DOI.create(items.get("DOI").asText());
                    }
                }
            }
        }
    }
    return doi;
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DOI(org.globalbioticinteractions.doi.DOI)

Aggregations

DOI (org.globalbioticinteractions.doi.DOI)74 Test (org.junit.Test)50 StudyImpl (org.eol.globi.domain.StudyImpl)28 IOException (java.io.IOException)15 Study (org.eol.globi.domain.Study)15 Specimen (org.eol.globi.domain.Specimen)13 StudyNode (org.eol.globi.domain.StudyNode)12 Matchers.containsString (org.hamcrest.Matchers.containsString)12 TaxonImpl (org.eol.globi.domain.TaxonImpl)11 URI (java.net.URI)10 LabeledCSVParser (com.Ostermiller.util.LabeledCSVParser)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 DatasetImpl (org.globalbioticinteractions.dataset.DatasetImpl)8 MalformedDOIException (org.globalbioticinteractions.doi.MalformedDOIException)8 Location (org.eol.globi.domain.Location)7 LocationImpl (org.eol.globi.domain.LocationImpl)7 ArrayList (java.util.ArrayList)6 Dataset (org.globalbioticinteractions.dataset.Dataset)6 Reader (java.io.Reader)5 StringReader (java.io.StringReader)5