/** * Create an instance of {@link Title } * */ public Title createTitle() { return new Title(); }
/** * Check if title1 and title2 are equals * * @param title1 * @param title2 * @return true if title1 is equals to title2 */ private boolean isTheSameTitle(Title title1, Title title2) { if (title1 == null) { if (title2 == null) return true; else return false; } else { if (title2 == null) return false; else return title1.equals(title2); } }
public Comparator<OrcidWork> workTitleComparator() { return (work1, work2) -> { WorkTitle title1 = work1.getWorkTitle(); WorkTitle title2 = work2.getWorkTitle(); if (title1 != null && title2 != null) { return title1.getTitle().getContent().compareTo(title2.getTitle().getContent()); } else { return NullUtils.compareNulls(title1, title2); } }; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((translatedTitle == null) ? 0 : translatedTitle.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((subtitle == null) ? 0 : subtitle.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((translatedTitle == null) ? 0 : translatedTitle.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; FundingTitle other = (FundingTitle) obj; if (title == null) { if (other.title != null) return false; } else if (!title.equals(other.title)) return false; if(translatedTitle == null){ if(other.translatedTitle != null) return false; } else if(!translatedTitle.equals(other.translatedTitle)) return false; return true; }
private WorkTitle getWorkTitle(WorkEntity work) { if (work == null || StringUtils.isBlank(work.getTitle())) { return null; } WorkTitle workTitle = new WorkTitle(); workTitle.setTitle(StringUtils.isNotBlank(work.getTitle()) ? new Title(work.getTitle()) : null); workTitle.setSubtitle(StringUtils.isNotBlank(work.getSubtitle()) ? new Subtitle(work.getSubtitle()) : null); if (work.getTranslatedTitle() != null) workTitle.setTranslatedTitle(new TranslatedTitle(work.getTranslatedTitle(), work.getTranslatedTitleLanguageCode())); return workTitle; }
private StringBuffer deriveOrcidData(String orcid, boolean definitive, List<OrcidWork> orcidWorks) { StringBuffer duplicationString = new StringBuffer(); String definitiveIdentifier = definitive ? "Definitive" : "Duplicate"; for (OrcidWork duplicate : orcidWorks) { String putCode = duplicate.getPutCode(); String title = duplicate.getWorkTitle() != null && duplicate.getWorkTitle().getTitle() != null && StringUtils.isNotBlank(duplicate.getWorkTitle().getTitle().getContent()) ? duplicate.getWorkTitle().getTitle().getContent() : MISSING_ENTRY; String visibility = duplicate.getVisibility() != null ? duplicate.getVisibility().value() : MISSING_ENTRY; duplicationString.append(orcid).append(SEPERATOR); duplicationString.append(definitiveIdentifier).append(SEPERATOR); duplicationString.append(putCode).append(SEPERATOR); duplicationString.append(title).append(SEPERATOR); duplicationString.append(visibility).append(SEPERATOR); duplicationString.append(NEW_LINE); } return duplicationString; }
/** * 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 + ((workCitation == null) ? 0 : workCitation.hashCode()); result = prime * result + ((workContributors == null) ? 0 : workContributors.hashCode()); result = prime * result + ((workExternalIdentifiers == null) ? 0 : workExternalIdentifiers.hashCode()); result = prime * result + ((workSource == null) ? 0 : workSource.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); result = prime * result + ((workTitle == null) ? 0 : workTitle.hashCode()); result = prime * result + ((workType == null) ? 0 : workType.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; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; WorkTitle other = (WorkTitle) obj; if (subtitle == null) { if (other.subtitle != null) return false; } else if (!subtitle.equals(other.subtitle)) return false; if (title == null) { if (other.title != null) return false; } else if (!title.equals(other.title)) return false; if(translatedTitle == null){ if(other.translatedTitle != null) return false; } else if(!translatedTitle.equals(other.translatedTitle)) return false; return true; }
orcidWork.setJournalTitle(StringUtils.isNotBlank(work.getJournalTitle()) ? new Title(work.getJournalTitle()) : null); orcidWork.setLanguageCode(normalizeLanguageCode(work.getLanguageCode()));
public void checkWork(OrcidWork orcidWork) { if (validateTitle) { WorkTitle title = orcidWork.getWorkTitle(); if (title == null || title.getTitle() == null || StringUtils.isEmpty(title.getTitle().getContent())) { throw new OrcidValidationException("Invalid Title: title cannot be null nor emtpy"); } } if (validateWorksHaveExternalIds) { if (orcidWork.getWorkExternalIdentifiers() == null || orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier() == null || orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) { throw new OrcidValidationException("Invalid work: Works added using message version 1.2_rc5 or greater must contain at least one external identifier"); } } }
/** * 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 + ((workCitation == null) ? 0 : workCitation.hashCode()); result = prime * result + ((workContributors == null) ? 0 : workContributors.hashCode()); result = prime * result + ((workExternalIdentifiers == null) ? 0 : workExternalIdentifiers.hashCode()); result = prime * result + ((workSource == null) ? 0 : workSource.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); result = prime * result + ((workTitle == null) ? 0 : workTitle.hashCode()); result = prime * result + ((workType == null) ? 0 : workType.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.journalTitle != null) return false; } else if (!journalTitle.equals(other.journalTitle)) return false;
title.setTitle(StringUtils.isNotEmpty(profileFundingEntity.getTitle()) ? new Title(profileFundingEntity.getTitle()) : null); if (StringUtils.isNotEmpty(profileFundingEntity.getTranslatedTitle())) { String translatedTitleValue = profileFundingEntity.getTranslatedTitle();
private void doWorkTypeValidation(OrcidMessage orcidMessage) { if (orcidMessage == null || orcidMessage.getOrcidProfile() == null || orcidMessage.getOrcidProfile().getOrcidActivities() == null || orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks() == null || orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork() == null || orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork().isEmpty()) return; List<OrcidWork> works = orcidMessage.getOrcidProfile().getOrcidActivities().getOrcidWorks().getOrcidWork(); for (OrcidWork work : works) { if (work.getWorkType() == null) if (work.getWorkTitle() != null && work.getWorkTitle().getTitle() != null && !PojoUtil.isEmpty(work.getWorkTitle().getTitle().getContent())) handleError("work-type is missing or invalid for work: '" + work.getWorkTitle().getTitle().getContent() + "'"); else handleError("work-type is missing or invalid"); } }
if (other.journalTitle != null) return false; } else if (!journalTitle.equals(other.journalTitle)) return false;
Subtitle worksubTitle = orcidWork.getWorkTitle().getSubtitle(); TranslatedTitle translatedTitle = orcidWork.getWorkTitle().getTranslatedTitle(); if (workMainTitle != null && !StringUtils.isBlank(workMainTitle.getContent())) { workTitles.add(workMainTitle.getContent()); FundingTitle title = orcidFunding.getTitle(); if (title != null) { if (title.getTitle() != null && !StringUtils.isBlank(title.getTitle().getContent())) { fundingTitle.add(title.getTitle().getContent());
|| PojoUtil.isEmpty(workExtId.getWorkExternalIdentifierId().getContent())) ? "" : workExtId.getWorkExternalIdentifierId().getContent(); String title1 = (title == null) ? "" : title.getContent(); String title2 = (titleToCompare == null) ? "" : titleToCompare.getContent(); String errorMessage = String.format("Works \"%s\" and \"%s\" have the same external id \"%s\"", title1, title2, extIdContent); || PojoUtil.isEmpty(existingExternalIdentifier.getWorkExternalIdentifierId().getContent())) ? "" : existingExternalIdentifier.getWorkExternalIdentifierId().getContent(); String title1 = (title == null) ? "" : title.getContent(); String title2 = (titleToCompare == null) ? "" : titleToCompare.getContent(); String errorMessage = String.format("Works \"%s\" and \"%s\"(put-code '%s') have the same external id \"%s\"", title1, title2, existingWork.getPutCode(), extIdContent);
String title = null, translatedTitle = null, languageCode = null; if (fundingTitle.getTitle() != null) title = fundingTitle.getTitle().getContent(); if (fundingTitle.getTranslatedTitle() != null) { translatedTitle = fundingTitle.getTranslatedTitle().getContent();