Search in sources :

Example 36 with DOI

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

the class DOIResolverImplIT method findCitationForDOIStrangeCharacters.

@Test
public void findCitationForDOIStrangeCharacters() throws IOException {
    String citation = new DOIResolverImpl().findCitationForDOI(new DOI("1007", "s00300-004-0645-x"));
    assertThat(citation, is("La Mesa M, Dalú M, Vacchi M. Trophic ecology of the emerald notothen Trematomus bernacchii (Pisces, Nototheniidae) from Terra Nova Bay, Ross Sea, Antarctica. Polar Biology [Internet]. 2004 July 27;27(11):721–728. Available from: http://dx.doi.org/10.1007/s00300-004-0645-x"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 37 with DOI

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

the class DOIResolverImplIT method findCitationForDOI2.

@Test
public void findCitationForDOI2() throws IOException {
    String citationForDOI = new DOIResolverImpl().findCitationForDOI(new DOI("1371", "journal.pone.0052967"));
    assertThat(citationForDOI, is("García-Robledo C, Erickson DL, Staines CL, Erwin TL, Kress WJ. Tropical Plant–Herbivore Networks: Reconstructing Species Interactions Using DNA Barcodes Heil M, editor. PLoS ONE [Internet]. 2013 January 8;8(1):e52967. Available from: http://dx.doi.org/10.1371/journal.pone.0052967"));
}
Also used : Matchers.containsString(org.hamcrest.Matchers.containsString) DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 38 with DOI

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

the class DOIResolverImplIT method resolveDOIByNonExistentCitation2.

@Test
public void resolveDOIByNonExistentCitation2() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor("donald duck and mickey mouse run around");
    assertThat(doi, is(nullValue()));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 39 with DOI

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

the class ExternalIdUtil method urlForExternalId.

public static String urlForExternalId(String externalId) {
    URI uri = null;
    String url = null;
    if (externalId != null) {
        for (Map.Entry<String, String> idPrefixToUrlPrefix : getURLPrefixMap().entrySet()) {
            String idPrefix = idPrefixToUrlPrefix.getKey();
            if (StringUtils.startsWith(externalId, idPrefix)) {
                if (DOI.isCommonlyUsedDoiPrefix(idPrefix)) {
                    try {
                        DOI doi = DOI.create(externalId);
                        url = doi.toURI().toString();
                    } catch (MalformedDOIException e) {
                        LOG.warn("found malformed doi [" + externalId + "]", e);
                    }
                } else {
                    url = idPrefixToUrlPrefix.getValue() + externalId.replaceAll(idPrefix, "");
                }
                String suffix = getURLSuffixMap().get(idPrefix);
                if (StringUtils.isNotBlank(suffix)) {
                    url = url + suffix;
                }
            }
            if (url != null) {
                try {
                    URIBuilder uriBuilder = new URIBuilder(url);
                    uri = uriBuilder.build();
                // URL ur= new URL(url);
                // uri = new URI(ur.getProtocol(), ur.getUserInfo(), ur.getHost(), ur.getPort(), ur.getPath(), ur.getQuery(), ur.getRef());
                } catch (URISyntaxException e) {
                // 
                }
                break;
            }
        }
    }
    return uri == null ? null : uri.toString();
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) HashMap(java.util.HashMap) Map(java.util.Map) DOI(org.globalbioticinteractions.doi.DOI) MalformedDOIException(org.globalbioticinteractions.doi.MalformedDOIException) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 40 with DOI

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

the class CypherQueryBuilder method extractDOIs.

private static List<DOI> extractDOIs(List<String> accordingToParams) {
    List<DOI> dois = new ArrayList<>();
    for (String accordingToParam : accordingToParams) {
        try {
            DOI doi = DOI.create(accordingToParam);
            dois.add(doi);
        } catch (MalformedDOIException e) {
        // 
        }
    }
    return dois;
}
Also used : ArrayList(java.util.ArrayList) DOI(org.globalbioticinteractions.doi.DOI) MalformedDOIException(org.globalbioticinteractions.doi.MalformedDOIException)

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