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()));
}
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()));
}
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;
}
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;
}
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;
}
Aggregations