public static FundingTitleForm valueOf(FundingTitle grantTitle) { FundingTitleForm gt = new FundingTitleForm(); if (grantTitle != null) { if (grantTitle.getTitle() != null) { gt.setTitle(Text.valueOf(grantTitle.getTitle().getContent())); } if(grantTitle.getTranslatedTitle() != null){ TranslatedTitleForm translatedTitle = new TranslatedTitleForm(); translatedTitle.setContent((grantTitle.getTranslatedTitle() == null) ? null : grantTitle.getTranslatedTitle().getContent()); translatedTitle.setLanguageCode((grantTitle.getTranslatedTitle() == null || grantTitle.getTranslatedTitle().getLanguageCode() == null) ? null : grantTitle.getTranslatedTitle().getLanguageCode()); gt.setTranslatedTitle(translatedTitle); } } return gt; }
public FundingTitle toFundingTitle() { FundingTitle gt = new FundingTitle(); if (this.getTitle() != null) gt.setTitle(new Title(this.getTitle().getValue())); if(this.getTranslatedTitle() != null) gt.setTranslatedTitle(this.getTranslatedTitle().toTranslatedTitle()); return gt; }
return false; } else { if (!title.equals(other.title)) return false;
public static FundingGroup valueOf(org.orcid.jaxb.model.v3.rc2.record.summary.FundingGroup fundingGroup) { FundingGroup group = new FundingGroup(); group.setFundings(new ArrayList<>()); group.setUserVersionPresent(false); Long maxDisplayIndex = null; for (FundingSummary fundingSummary : fundingGroup.getFundingSummary()) { FundingForm fundingForm = FundingForm.valueOf(fundingSummary); group.setGroupId(fundingSummary.getPutCode()); // any value fine for group id as long as it's unique group.getFundings().add(fundingForm); Long displayIndex = Long.parseLong(fundingSummary.getDisplayIndex()); if (maxDisplayIndex == null || displayIndex > maxDisplayIndex) { maxDisplayIndex = displayIndex; group.setActivePutCode(fundingSummary.getPutCode()); group.setDefaultPutCode(fundingSummary.getPutCode()); group.setActiveVisibility(fundingSummary.getVisibility().name()); group.setStartDate(fundingSummary.getStartDate() != null ? Date.valueOf(fundingSummary.getStartDate()) : null); group.setEndDate(fundingSummary.getEndDate() != null ? Date.valueOf(fundingSummary.getEndDate()) : null); group.setTitle(fundingSummary.getTitle().getTitle().getContent()); } } if (fundingGroup.getIdentifiers() != null) { for (ExternalID extId : fundingGroup.getIdentifiers().getExternalIdentifier()) { group.getExternalIdentifiers().add(ActivityExternalIdentifier.valueOf(extId)); } } return group; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((createdDate == null) ? 0 : createdDate.hashCode()); result = prime * result + ((endDate == null) ? 0 : endDate.hashCode()); result = prime * result + ((externalIdentifiers == null) ? 0 : externalIdentifiers.hashCode()); result = prime * result + ((url == null) ? 0 : url.hashCode()); result = prime * result + ((lastModifiedDate == null) ? 0 : lastModifiedDate.hashCode()); result = prime * result + ((putCode == null) ? 0 : putCode.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); result = prime * result + ((startDate == null) ? 0 : startDate.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((visibility == null) ? 0 : visibility.hashCode()); result = prime * result + ((organization == null) ? 0 : organization.hashCode()); return result; }
private SchemaOrgAffiliation createFundingOrg(FundingGroup fundingGroup) { SchemaOrgAffiliation a = new SchemaOrgAffiliation(); a.name = fundingGroup.getFundingSummary().get(0).getOrganization().getName(); a.alternateName = fundingGroup.getFundingSummary().get(0).getTitle().getTitle().getContent(); //add org ids for (FundingSummary s : fundingGroup.getFundingSummary()){ if (s.getOrganization().getDisambiguatedOrganization() !=null){ if (!StringUtils.isEmpty(s.getOrganization().getDisambiguatedOrganization().getDisambiguationSource()) && !StringUtils.isEmpty(s.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier())) addIdToAffiliation(s.getOrganization().getDisambiguatedOrganization().getDisambiguationSource(),s.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier(), a); if (s.getOrganization().getDisambiguatedOrganization().getExternalIdentifiers() != null) for (DisambiguatedOrganizationExternalIdentifier i : s.getOrganization().getDisambiguatedOrganization().getExternalIdentifiers()) { addIdToAffiliation(i.getIdentifierType(),i.getIdentifier(), a); } } } //add grant ids if (fundingGroup.getIdentifiers() != null && fundingGroup.getIdentifiers().getExternalIdentifier() != null) for (ExternalID id : fundingGroup.getIdentifiers().getExternalIdentifier()) a.identifier.add(new SchemaOrgExternalID(id.getType(), norm.normalise(id.getType(), id.getValue()))); return a; }
/** * * Note that put-code is not part of hashCode or equals! This is to allow * better de-duplication. * */ @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((title == null) ? 0 : title.hashCode()); result = prime * result + ((description == null) ? 0 : description.hashCode()); result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((organizationDefinedType == null) ? 0 : organizationDefinedType.hashCode()); result = prime * result + ((amount == null) ? 0 : amount.hashCode()); result = prime * result + ((url == null) ? 0 : url.hashCode()); result = prime * result + ((organization == null) ? 0 : organization.hashCode()); result = prime * result + ((visibility == null) ? 0 : visibility.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); result = prime * result + ((externalIdentifiers == null) ? 0 : externalIdentifiers.hashCode()); result = prime * result + ((contributors == null) ? 0 : contributors.hashCode()); result = prime * result + ((startDate == null) ? 0 : startDate.hashCode()); result = prime * result + ((endDate == null) ? 0 : endDate.hashCode()); return result; }
public void validateFunding(Funding funding, Source activeSource, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) { FundingTitle title = funding.getTitle(); if (title == null || title.getTitle() == null || StringUtils.isEmpty(title.getTitle().getContent())) { throw new ActivityTitleValidationException(); if (title != null && title.getTranslatedTitle() != null && !PojoUtil.isEmpty(title.getTranslatedTitle().getContent())) { if (PojoUtil.isEmpty(title.getTranslatedTitle().getLanguageCode()) || !Arrays.stream(LanguageCode.getValues()).anyMatch(title.getTranslatedTitle().getLanguageCode()::equals)) { Map<String, String> params = new HashMap<String, String>(); String values = Arrays.stream(LanguageCode.getValues()).collect(Collectors.joining(", "));
if (other.title != null) return false; } else if (!title.equals(other.title)) return false; if (type != other.type)
if (fundingSummary.getTitle().getTitle() != null) fundingTitle.setTitle(Text.valueOf(fundingSummary.getTitle().getTitle().getContent())); else fundingTitle.setTitle(new Text()); if (fundingSummary.getTitle().getTranslatedTitle() != null) { TranslatedTitleForm translatedTitle = new TranslatedTitleForm(); translatedTitle.setContent(fundingSummary.getTitle().getTranslatedTitle().getContent()); translatedTitle.setLanguageCode(fundingSummary.getTitle().getTranslatedTitle().getLanguageCode()); fundingTitle.setTranslatedTitle(translatedTitle);
return false; } else { if (!title.equals(other.title)) return false;
if (funding.getTitle().getTitle() != null) fundingTitle.setTitle(Text.valueOf(funding.getTitle().getTitle().getContent())); else fundingTitle.setTitle(new Text()); if (funding.getTitle().getTranslatedTitle() != null) { TranslatedTitleForm translatedTitle = new TranslatedTitleForm(); translatedTitle.setContent(funding.getTitle().getTranslatedTitle().getContent()); translatedTitle.setLanguageCode(funding.getTitle().getTranslatedTitle().getLanguageCode()); fundingTitle.setTranslatedTitle(translatedTitle);