/** * Create an instance of {@link Citation } * */ public Citation createCitation() { return new Citation(); }
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); }
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; }
@Generated(value = "com.sun.tools.xjc.Driver", date = "2018-04-24T11:17:38-05:00", comments = "JAXB RI v2.2.11") public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { { CitationType theCitationType; theCitationType = this.getCitationType(); strategy.appendField(locator, this, "citationType", buffer, theCitationType); } { String theCitationValue; theCitationValue = this.getCitationValue(); strategy.appendField(locator, this, "citationValue", buffer, theCitationValue); } return buffer; }
@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); }
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));
/** * Turn a work into Citeproc JSON. Uses bibtex citation if present, * otherwise attempts to map ORCID metadata * * @param work the work to translate * @param creditName name to use as author if no bibtex found * @param abreviate if true, will shorten bibtex derived authorship to 200 characters or 20 authors * @return the JSON as a String. */ public CSLItemData toCiteproc(Work work, String creditName, boolean abreviate) { if (work.getWorkCitation() != null && work.getWorkCitation().getWorkCitationType() != null && work.getWorkCitation().getWorkCitationType().equals(CitationType.BIBTEX)) { return translateFromBibtexCitation(work, abreviate); } return translateFromWorkMetadata(work,creditName); }
/** * Note that put-code is not part of hashcode. This is important for avoid * creation of duplication works. */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((publicationDate == null) ? 0 : publicationDate.hashCode()); result = prime * result + ((shortDescription == null) ? 0 : shortDescription.hashCode()); result = prime * result + ((url == null) ? 0 : url.hashCode()); result = prime * result + ((visibility == null) ? 0 : visibility.hashCode()); result = prime * result + ((citation == null) ? 0 : citation.hashCode()); result = prime * result + ((contributors == null) ? 0 : contributors.hashCode()); result = prime * result + ((externalIdentifiers == null) ? 0 : externalIdentifiers.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((journalTitle == null) ? 0 : journalTitle.hashCode()); result = prime * result + ((languageCode == null) ? 0 : languageCode.hashCode()); result = prime * result + ((country == null) ? 0 : country.hashCode()); return result; }
if (other.citation != null) return false; } else if (!citation.equals(other.citation)) return false; if (contributors == null) {
String citation = work.getWorkCitation().getCitation(); CitationType type = work.getWorkCitation().getWorkCitationType(); if (type == null) { Map<String, String> params = new HashMap<String, String>();
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); } } } } }