Search in sources :

Example 21 with DOI

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

the class DatasetImporterForPensoft method addDOIReferenceIfAvailable.

private static void addDOIReferenceIfAvailable(String doiString, TreeMap<String, String> references) {
    try {
        final DOI doiObj = DOI.create(doiString);
        references.put(DatasetImporterForTSV.REFERENCE_DOI, doiString);
        references.put(DatasetImporterForTSV.REFERENCE_URL, doiObj.toURI().toString());
    } catch (MalformedDOIException e) {
    // ignore
    }
}
Also used : DOI(org.globalbioticinteractions.doi.DOI) MalformedDOIException(org.globalbioticinteractions.doi.MalformedDOIException)

Example 22 with DOI

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

the class LinkerDOI method linkStudy.

public static void linkStudy(DOIResolver doiResolver, StudyNode study) {
    if (shouldResolve(study)) {
        try {
            DOI doiResolved = doiResolver.resolveDoiFor(study.getCitation());
            setDOIForStudy(study, doiResolved);
        } catch (IOException e) {
            LOG.warn("failed to lookup doi for citation [" + study.getCitation() + "] with id [" + study.getTitle() + "]", e);
        }
    }
}
Also used : IOException(java.io.IOException) DOI(org.globalbioticinteractions.doi.DOI)

Example 23 with DOI

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

the class DatasetImporterForCruaud method importStudy.

@Override
public void importStudy() throws StudyImporterException {
    LabeledCSVParser dataParser;
    try {
        dataParser = getParserFactory().createParser(RESOURCE_PATH, CharsetConstant.UTF8);
    } catch (IOException e) {
        throw new StudyImporterException("failed to read resource [" + RESOURCE_PATH + "]", e);
    }
    try {
        Study study = getNodeFactory().getOrCreateStudy(new StudyImpl("cruaud", new DOI("1093", "sysbio/sys068"), SOURCE));
        while (dataParser.getLine() != null) {
            if (importFilter.shouldImportRecord((long) dataParser.getLastLineNumber())) {
                try {
                    String parasiteName = StringUtils.trim(dataParser.getValueByLabel("Family and Species"));
                    String hostName = StringUtils.trim(dataParser.getValueByLabel("Natural host Ficus species"));
                    hostName = StringUtils.replace(hostName, "F.", "Ficus");
                    if (areNamesAvailable(parasiteName, hostName)) {
                        Specimen parasite = getNodeFactory().createSpecimen(study, new TaxonImpl(parasiteName, null));
                        Specimen host = getNodeFactory().createSpecimen(study, new TaxonImpl(hostName, null));
                        String samplingLocation = StringUtils.trim(dataParser.getValueByLabel("Sampling location"));
                        if (getGeoNamesService().hasTermForLocale(samplingLocation)) {
                            LatLng pointForLocality = getGeoNamesService().findLatLng(samplingLocation);
                            if (pointForLocality == null) {
                                LOG.warn("no location associated with locality [" + samplingLocation + "]");
                            } else {
                                Location location = getNodeFactory().getOrCreateLocation(new LocationImpl(pointForLocality.getLat(), pointForLocality.getLng(), null, null));
                                parasite.caughtIn(location);
                                host.caughtIn(location);
                            }
                        } else {
                            LOG.warn("no location associated with locality [" + samplingLocation + "]");
                        }
                        parasite.interactsWith(host, InteractType.PARASITE_OF);
                    }
                } catch (NodeFactoryException | NumberFormatException e) {
                    throw new StudyImporterException("failed to import line [" + (dataParser.lastLineNumber() + 1) + "]", e);
                }
            }
        }
    } catch (IOException e) {
        throw new StudyImporterException("problem importing [" + RESOURCE_PATH + "]", e);
    }
}
Also used : Study(org.eol.globi.domain.Study) TaxonImpl(org.eol.globi.domain.TaxonImpl) StudyImpl(org.eol.globi.domain.StudyImpl) LabeledCSVParser(com.Ostermiller.util.LabeledCSVParser) IOException(java.io.IOException) Specimen(org.eol.globi.domain.Specimen) LocationImpl(org.eol.globi.domain.LocationImpl) LatLng(org.eol.globi.geo.LatLng) DOI(org.globalbioticinteractions.doi.DOI) Location(org.eol.globi.domain.Location)

Example 24 with DOI

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

the class DatasetImporterForAkin method importStudy.

private Study importStudy(URI studyResource) throws StudyImporterException {
    Study study;
    try {
        DOI doi = new DOI("1007", "bf02784282");
        StudyImpl study1 = new StudyImpl("Akin et al 2006", doi, ExternalIdUtil.toCitation("Senol Akin", "S. Akin, K. O. Winemiller, Seasonal variation in food web composition and structure in a temperate tidal estuary, Estuaries and Coasts" + "; August 2006, Volume 29, Issue 4, pp 552-567", "2006"));
        study = getNodeFactory().getOrCreateStudy(study1);
        String[][] siteInfo = loadSampleSiteLocations();
        importAkinStudyFile(siteInfo, studyResource, study);
    } catch (IOException e) {
        throw new StudyImporterException("failed to find resource [" + studyResource + "]", e);
    } catch (NodeFactoryException e) {
        throw new StudyImporterException("failed to parse resource [" + studyResource + "]", e);
    }
    return study;
}
Also used : Study(org.eol.globi.domain.Study) StudyImpl(org.eol.globi.domain.StudyImpl) IOException(java.io.IOException) DOI(org.globalbioticinteractions.doi.DOI)

Example 25 with DOI

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

the class DatasetWithCache method generateCitation.

private String generateCitation(String citation) {
    StringBuilder citationGenerated = new StringBuilder();
    citationGenerated.append(trim(citation));
    DOI doi = getDOI();
    if (doi != null) {
        citationGenerated.append(CitationUtil.separatorFor(citationGenerated.toString()));
        citationGenerated.append("<");
        citationGenerated.append(doi.toURI());
        citationGenerated.append(">");
    }
    citationGenerated.append(CitationUtil.separatorFor(citationGenerated.toString()));
    citationGenerated.append("Accessed");
    if (null != getAccessedAt()) {
        citationGenerated.append(" on ").append(getAccessedAt());
    }
    if (null != getArchiveURI()) {
        citationGenerated.append(" via <").append(getArchiveURI()).append(">.");
    }
    return StringUtils.trim(citationGenerated.toString());
}
Also used : 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