/** * Create an instance of {@link OrcidWork } * */ public OrcidWork createOrcidWork() { return new OrcidWork(); }
OrcidWork other = (OrcidWork) obj; if (this.getWorkTitle() == null) { if (other.getWorkTitle() != null) return false; } else if (!this.getWorkTitle().equals(other.getWorkTitle())) return false; if (this.getWorkType() == null) { if (other.getWorkType() != null) return false; } else if (!this.getWorkType().equals(other.getWorkType())) return false; if (this.getWorkExternalIdentifiers() == null) { if (other.getWorkExternalIdentifiers() != null) return false; } else if (!this.getWorkExternalIdentifiers().equals(other.getWorkExternalIdentifiers())) return false; if (this.getSource() == null) { if (other.getSource() != null) return false; } else if (!this.getSource().equals(other.getSource())) return false;
public Comparator<OrcidWork> workDisplayIndexComparator() { return (work1, work2) -> { Long displayIndex1 = work1.getDisplayIndex(); Long displayIndex2 = work2.getDisplayIndex(); if (displayIndex1 != null && displayIndex2 != null) { return -displayIndex1.compareTo(displayIndex2); } else { return NullUtils.compareNulls(displayIndex1, displayIndex2); } }; }
@Override public int hashCode() { int result = this.orcidWork.getWorkTitle() != null ? this.orcidWork.getWorkTitle().hashCode() : 0; result = 31 * result + (this.orcidWork.getShortDescription() != null ? this.orcidWork.getShortDescription().hashCode() : 0); result = 31 * result + (this.orcidWork.getWorkCitation() != null ? this.orcidWork.getWorkCitation().hashCode() : 0); result = 31 * result + (this.orcidWork.getWorkType() != null ? this.orcidWork.getWorkType().hashCode() : 0); result = 31 * result + (this.orcidWork.getPublicationDate() != null ? this.orcidWork.getPublicationDate().hashCode() : 0); result = 31 * result + (this.orcidWork.getWorkExternalIdentifiers() != null ? this.orcidWork.getWorkExternalIdentifiers().hashCode() : 0); result = 31 * result + (this.orcidWork.getUrl() != null ? this.orcidWork.getUrl().hashCode() : 0); result = 31 * result + (this.orcidWork.getWorkContributors() != null ? this.orcidWork.getWorkContributors().hashCode() : 0); result = 31 * result + (this.orcidWork.getWorkSource() != null ? this.orcidWork.getWorkSource().hashCode() : 0); return result; }
private String getWorkExternalIdsJson(OrcidWork work) { if (work == null || work.getWorkExternalIdentifiers() == null) { return null; } JSONWorkExternalIdentifiersConverterV1 converter = new JSONWorkExternalIdentifiersConverterV1(); return converter.convertTo(work.getWorkExternalIdentifiers(), work.getWorkType()); }
OrcidWork orcidWork = new OrcidWork(); PublicationDateEntity publicationDate = work.getPublicationDate(); orcidWork.setPublicationDate(getPublicationDateFromEntity(publicationDate)); orcidWork.setPutCode(Long.toString(work.getId())); orcidWork.setShortDescription(work.getDescription()); orcidWork.setUrl(StringUtils.isNotBlank(work.getWorkUrl()) ? new Url(work.getWorkUrl()) : null); orcidWork.setWorkCitation(getWorkCitation(work)); orcidWork.setWorkContributors(getWorkContributors(work)); if (work.getExternalIdentifiersJson() != null){ JSONWorkExternalIdentifiersConverterV1 converter = new JSONWorkExternalIdentifiersConverterV1(); orcidWork.setWorkExternalIdentifiers(converter.convertFrom(work.getExternalIdentifiersJson())); orcidWork.setSource(getSource(work)); orcidWork.setWorkTitle(getWorkTitle(work)); orcidWork.setJournalTitle(StringUtils.isNotBlank(work.getJournalTitle()) ? new Title(work.getJournalTitle()) : null); orcidWork.setLanguageCode(normalizeLanguageCode(work.getLanguageCode())); orcidWork.setCountry(country); orcidWork.setWorkType(WorkType.OTHER); } else if(org.orcid.jaxb.model.v3.rc1.record.WorkType.PREPRINT.name().equals(work.getWorkType())) { orcidWork.setWorkType(WorkType.OTHER); } else if(org.orcid.jaxb.model.common.WorkType.DISSERTATION_THESIS.name().equals(work.getWorkType())) { orcidWork.setWorkType(WorkType.DISSERTATION); } else { orcidWork.setWorkType(WorkType.valueOf(work.getWorkType())); orcidWork.setVisibility(Visibility.valueOf(work.getVisibility()));
OrcidWork orcidWorkSubset = new OrcidWork(); orcidWorkSubset.setVisibility(fullOrcidWork.getVisibility()); orcidWorkSubset.setWorkTitle(fullOrcidWork.getWorkTitle()); orcidWorkSubset.setWorkExternalIdentifiers(fullOrcidWork.getWorkExternalIdentifiers()); orcidWorksTitlesOnly.getOrcidWork().add(orcidWorkSubset);
if (orcidWork != null) { if(workEntity == null) { String putCode = orcidWork.getPutCode(); if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) { throw new IllegalArgumentException("Invalid put-code was supplied: " + putCode); Citation workCitation = orcidWork.getWorkCitation(); if (workCitation != null && StringUtils.isNotBlank(workCitation.getCitation()) && workCitation.getWorkCitationType() != null) { workEntity.setCitation(workCitation.getCitation()); workEntity.setContributorsJson(getWorkContributorsJson(orcidWork.getWorkContributors())); workEntity.setDescription(orcidWork.getShortDescription() != null ? orcidWork.getShortDescription() : null); WorkTitle workTitle = orcidWork.getWorkTitle(); if (workTitle != null) { workEntity.setSubtitle(workTitle.getSubtitle() != null ? workTitle.getSubtitle().getContent() : null); workEntity.setJournalTitle(orcidWork.getJournalTitle() != null ? orcidWork.getJournalTitle().getContent() : null); workEntity.setLanguageCode(orcidWork.getLanguageCode() != null ? orcidWork.getLanguageCode() : null); if(orcidWork.getCountry() != null && orcidWork.getCountry().getValue() != null) { workEntity.setIso2Country(orcidWork.getCountry().getValue().value()); workEntity.setWorkUrl(orcidWork.getUrl() != null ? orcidWork.getUrl().getValue() : null); if(orcidWork.getWorkType() != null) { if(WorkType.DISSERTATION.equals(orcidWork.getWorkType())) { workEntity.setWorkType(org.orcid.jaxb.model.common.WorkType.DISSERTATION_THESIS.name()); } else { workEntity.setWorkType(orcidWork.getWorkType().name());
if (this.getWorkTitle() == null) { if (other.getWorkTitle() != null) return false; } else if (!this.getWorkTitle().equals(other.getWorkTitle())) return false; if (this.getWorkExternalIdentifiers() == null) { if (other.getWorkExternalIdentifiers() != null && other.getWorkExternalIdentifiers().getWorkExternalIdentifier() != null && !other.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) return false; } else if (other.getWorkExternalIdentifiers() == null) { if (this.getWorkExternalIdentifiers().getWorkExternalIdentifier() != null && !this.getWorkExternalIdentifiers().getWorkExternalIdentifier().isEmpty()) return false; } else { List<WorkExternalIdentifier> otherExternalIdentifiers = other.getWorkExternalIdentifiers().getWorkExternalIdentifier(); List<WorkExternalIdentifier> thisExternalIdentifiers = this.getWorkExternalIdentifiers().getWorkExternalIdentifier(); boolean sharedExtId = false; if (this.getSource() == null) { if (other.getSource() != null) return false; } else if (!this.getSource().equals(other.getSource())) return false; return true;
private void downGradeActivity(OrcidWork orcidWork) { Source source = orcidWork.getSource(); if (source != null) { SourceOrcid sourceOrcid = source.getSourceOrcid(); if (sourceOrcid != null) { orcidWork.setSource(null); orcidWork.setWorkSource(new WorkSource(sourceOrcid)); } } WorkExternalIdentifiers externalIdentifiers = orcidWork.getWorkExternalIdentifiers(); if (externalIdentifiers != null) { for (WorkExternalIdentifier wei : externalIdentifiers.getWorkExternalIdentifier()) { WorkExternalIdentifierType type = wei.getWorkExternalIdentifierType(); if (type != null) { if (Arrays.binarySearch(NEW_WORK_EXT_ID_TYPES, type) >= 0) { wei.setWorkExternalIdentifierType(OTHER_ID); } } } } }
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"); } } }
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; }
@Override public OrcidMessage upgradeMessage(OrcidMessage orcidMessage) { if (orcidMessage == null) { return null; } if (orcidMessage.getOrcidProfile() != null) { OrcidProfile op = orcidMessage.getOrcidProfile(); if (op.getOrcidActivities() != null && op.getOrcidActivities().getOrcidWorks() != null) { for (OrcidWork ow : op.getOrcidActivities().getOrcidWorks().getOrcidWork()) { ow.setLanguageCode(Jpa2JaxbAdapterImpl.normalizeLanguageCode(ow.getLanguageCode())); if (ow.getWorkTitle() != null && ow.getWorkTitle().getTranslatedTitle() != null) ow.getWorkTitle().getTranslatedTitle().setLanguageCode(ow.getWorkTitle().getTranslatedTitle().getLanguageCode()); } } } orcidMessage.setMessageVersion(TO_VERSION); return orcidMessage; }
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"); } }
for (OrcidWork updatedWork : updatedOrcidWorksList) { Item activity = new Item(); activity.setItemName(updatedWork.getWorkTitle().getTitle().getContent()); activity.setItemType(ItemType.WORK); activity.setPutCode(updatedWork.getPutCode()); activities.add(activity);
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); } }; }
private void downGradeActivity(OrcidWork orcidWork) { WorkExternalIdentifiers externalIdentifiers = orcidWork.getWorkExternalIdentifiers(); if (externalIdentifiers != null) { for (WorkExternalIdentifier wei : externalIdentifiers.getWorkExternalIdentifier()) { WorkExternalIdentifierType type = wei.getWorkExternalIdentifierType(); if (WOSUID.equals(type)) { wei.setWorkExternalIdentifierType(OTHER_ID); } } } }
public Comparator<OrcidWork> workPubDateComparator() { return (work1, work2) -> { PublicationDate pubDate1 = work1.getPublicationDate(); PublicationDate pubDate2 = work2.getPublicationDate(); if (pubDate1 != null && pubDate2 != null) { @SuppressWarnings("deprecation") String dateString1 = PojoUtil.createDateSortString(null, pubDate1); @SuppressWarnings("deprecation") String dateString2 = PojoUtil.createDateSortString(null, pubDate2); return -dateString1.compareTo(dateString2); } else { return NullUtils.compareNulls(pubDate1, pubDate2); } }; }
if (this.orcidWork.getPublicationDate() != null ? !this.orcidWork.getPublicationDate().equals(orcidWork.getPublicationDate()) : orcidWork.getPublicationDate() != null) { return false; if (this.orcidWork.getShortDescription() != null ? !this.orcidWork.getShortDescription().equals(orcidWork.getShortDescription()) : orcidWork .getShortDescription() != null) { return false; if (this.orcidWork.getUrl() != null ? !this.orcidWork.getUrl().equals(orcidWork.getUrl()) : orcidWork.getUrl() != null) { return false; if (this.orcidWork.getWorkCitation() != null ? !this.orcidWork.getWorkCitation().equals(orcidWork.getWorkCitation()) : orcidWork.getWorkCitation() != null) { return false; if (this.orcidWork.getWorkContributors() != null ? !this.orcidWork.getWorkContributors().equals(orcidWork.getWorkContributors()) : orcidWork .getWorkContributors() != null) { return false; if (this.orcidWork.getWorkExternalIdentifiers() != null ? !this.orcidWork.getWorkExternalIdentifiers().equals(orcidWork.getWorkExternalIdentifiers()) : orcidWork .getWorkExternalIdentifiers() != null) { return false; if (this.orcidWork.getWorkSource() != null ? !this.orcidWork.getWorkSource().equals(orcidWork.getWorkSource()) : orcidWork.getWorkSource() != null) { return false; if (this.orcidWork.getWorkTitle() != null ? !this.orcidWork.getWorkTitle().equals(orcidWork.getWorkTitle()) : orcidWork.getWorkTitle() != null) { return false; if (this.orcidWork.getWorkType() != orcidWork.getWorkType()) {