Search in sources :

Example 41 with DOI

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

the class DOIReferenceExtractor method on.

@Override
public void on(Map<String, String> interaction) throws StudyImporterException {
    Map<String, String> emittingInteraction = interaction;
    if (!interaction.containsKey(DatasetImporterForTSV.REFERENCE_DOI) && !interaction.containsKey(DatasetImporterForTSV.REFERENCE_URL) && interaction.containsKey(DatasetImporterForTSV.REFERENCE_CITATION)) {
        String referenceCitation = interaction.get(DatasetImporterForTSV.REFERENCE_CITATION);
        if (StringUtils.isNoneBlank(referenceCitation)) {
            Matcher matcher = Pattern.compile(".*(doi:)([ ]*)(10[.])(.*)/([^ ]+)").matcher(referenceCitation);
            if (matcher.matches()) {
                String registrant = matcher.group(4);
                String suffix = matcher.group(5);
                try {
                    DOI doi = new DOI(registrant, suffix);
                    emittingInteraction = new TreeMap<String, String>(interaction) {

                        {
                            put(DatasetImporterForTSV.REFERENCE_DOI, doi.toString());
                        }
                    };
                } catch (IllegalArgumentException ex) {
                // ignore
                }
            }
        }
    }
    emit(emittingInteraction);
}
Also used : Matcher(java.util.regex.Matcher) DOI(org.globalbioticinteractions.doi.DOI)

Example 42 with DOI

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

the class DOIResolverImplIT method resolveDOIByReferenceURL.

@Test
@Ignore
public void resolveDOIByReferenceURL() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor("http://www.ncbi.nlm.nih.gov/nuccore/7109271");
    assertThat(doi, is("10.1002/bimj.4710230217"));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 43 with DOI

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

the class DOIResolverImplIT method resolveDOIByReferenceTamarins.

@Test
public void resolveDOIByReferenceTamarins() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor("Raboy, Becky E., and James M. Dietz. Diet, Foraging, and Use of Space in Wild Golden-headed Lion Tamarins. American Journal of Primatology, 63(1):, 2004, 1-15. Accessed April 20, 2015. http://hdl.handle.net/10088/4251.");
    assertThat(doi.toString(), is("10.1002/ajp.20032"));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 44 with DOI

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

the class DOIResolverImplIT method resolveDOIByReferenceMatch3.

@Test
public void resolveDOIByReferenceMatch3() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor(HOCKING);
    assertThat(doi.toString(), is(HOCKING_DOI.toString()));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

Example 45 with DOI

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

the class DOIResolverImplIT method resolveDOIByReferenceMatch8.

@Test
public void resolveDOIByReferenceMatch8() throws IOException {
    DOI doi = new DOIResolverImpl().resolveDoiFor("Tutin, C.E.G., Ham, R.M., White, L.J.T., Harrison, M.J.S. 1997. The primate community of the Lopé Reserve, Gabon: diets, responses to fruit scarcity, and effects on biomass. American Journal of Primatology, 42: 1-24.");
    assertThat(doi.toString(), is("10.1002/(sici)1098-2345(1997)42:1<1::aid-ajp1>3.0.co;2-0"));
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) Test(org.junit.Test)

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