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