try { BibTeXConverter conv = new BibTeXConverter(); String ascii = Normalizer.normalize(work.getWorkCitation().getCitation(), Normalizer.Form.NFKD); ascii = ascii.replaceAll("[^\\x00-\\x7F]", ""); BibTeXDatabase db = conv.loadDatabase(IOUtils.toInputStream(ascii));
String citation = work.getWorkCitation().getCitation(); CitationType type = work.getWorkCitation().getWorkCitationType(); if (type == null) {
@Override public String generateBibtex(String orcid, Work work){ //if we have a citation use that if (work.getWorkCitation() != null && work.getWorkCitation().getWorkCitationType() != null && work.getWorkCitation().getWorkCitationType().equals(CitationType.BIBTEX)) { return work.getWorkCitation().getCitation(); } //if we have a DOI, use that if (work.getWorkExternalIdentifiers() != null && work.getWorkExternalIdentifiers().getExternalIdentifier() != null){ String doi = extractID(work, WorkExternalIdentifierType.DOI); if (doi != null){ try{ String bibtex = doiManager.fetchDOIBibtex(doi); if (bibtex != null) return bibtex; }catch (Exception e){ //something went wrong at crossref/datacite e.g. 10.1890/1540-9295(2006)004[0244:elsdvs]2.0.co;2 //ignore and use our metadata LOGGER.warn("cannot resolve DOI to metadata:"+doi); } } } //otherwise, use whatever we can String creditName = getCreditName(orcid); return workToBibtex(work,creditName); }
public static void cleanEmptyFields(Work work) { if(work != null) { if(work.getWorkCitation() != null) { if(PojoUtil.isEmpty(work.getWorkCitation().getCitation())) { work.setWorkCitation(null); } } if(work.getWorkTitle() != null) { if(work.getWorkTitle().getTranslatedTitle() != null) { if(PojoUtil.isEmpty(work.getWorkTitle().getTranslatedTitle().getContent())) { work.getWorkTitle().setTranslatedTitle(null); } } } if(work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) { for(Contributor c : work.getWorkContributors().getContributor()) { if(c.getCreditName() != null && PojoUtil.isEmpty(c.getCreditName().getContent())) { c.setCreditName(null); } } } } }