/** * Create an instance of {@link Funding } * */ public Funding createFunding() { return new Funding(); }
private void checkFunding(Funding funding) { if (validateFundingHaveExternalIds) { if (funding.getFundingExternalIdentifiers() == null || funding.getFundingExternalIdentifiers().getFundingExternalIdentifier() == null || funding.getFundingExternalIdentifiers().getFundingExternalIdentifier().isEmpty()) { throw new OrcidValidationException( "Invalid funding: Funding added using message version 1.2_rc5 or greater must contain at least one external identifier"); } } if (funding.getStartDate() != null) { if (!PojoUtil.isEmpty(funding.getStartDate().getMonth()) && PojoUtil.isEmpty(funding.getStartDate().getYear())) { throw new OrcidValidationException("Invalid funding: Invalid start date"); } } if (funding.getEndDate() != null) { if (!PojoUtil.isEmpty(funding.getEndDate().getMonth()) && PojoUtil.isEmpty(funding.getEndDate().getYear())) { throw new OrcidValidationException("Invalid funding: Invalid end date"); } } }
Funding funding = new Funding(); orcidAmount.setContent(stringAmount); orcidAmount.setCurrencyCode(profileFundingEntity.getCurrencyCode() != null ? profileFundingEntity.getCurrencyCode() : null); funding.setAmount(orcidAmount); funding.setDescription(StringUtils.isNotEmpty(profileFundingEntity.getDescription()) ? profileFundingEntity.getDescription() : null); FundingTitle title = new FundingTitle(); title.setTitle(StringUtils.isNotEmpty(profileFundingEntity.getTitle()) ? new Title(profileFundingEntity.getTitle()) : null); funding.setTitle(title); if(profileFundingEntity.getType() != null) { funding.setType(FundingType.valueOf(profileFundingEntity.getType())); funding.setOrganizationDefinedFundingType(profileFundingEntity.getOrganizationDefinedType() != null ? new OrganizationDefinedFundingSubType(profileFundingEntity .getOrganizationDefinedType()) : null); funding.setUrl(StringUtils.isNotEmpty(profileFundingEntity.getUrl()) ? new Url(profileFundingEntity.getUrl()) : new Url(new String())); funding.setVisibility(Visibility.valueOf(profileFundingEntity.getVisibility())); } else { funding.setVisibility(Visibility.PRIVATE); funding.setPutCode(Long.toString(profileFundingEntity.getId())); funding.setFundingContributors(getFundingContributors(profileFundingEntity)); funding.setFundingExternalIdentifiers(converter.convertFrom(profileFundingEntity.getExternalIdentifiersJson())); funding.setOrganization(organization);
String putCode = funding.getPutCode(); if (StringUtils.isNotBlank(putCode) && !"-1".equals(putCode)) { throw new IllegalArgumentException("Invalid put-code was supplied for a funding: " + putCode); FuzzyDate startDate = funding.getStartDate(); FuzzyDate endDate = funding.getEndDate(); if (funding.getAmount() != null) { String amount = StringUtils.isNotBlank(funding.getAmount().getContent()) ? funding.getAmount().getContent() : null; String currencyCode = funding.getAmount().getCurrencyCode() != null ? funding.getAmount().getCurrencyCode() : null; if (StringUtils.isNotBlank(amount)) { try { profileFundingEntity.setContributorsJson(getFundingContributorsJson(funding.getFundingContributors())); profileFundingEntity.setDescription(StringUtils.isNotBlank(funding.getDescription()) ? funding.getDescription() : null); profileFundingEntity.setEndDate(endDate != null ? FuzzyDateUtils.getEndDateEntity(endDate) : null); String fundingExternalIdentifiersJSONString = fundingExternalIDConverter.convertTo(funding.getFundingExternalIdentifiers()); FundingTitle fundingTitle = funding.getTitle(); if (fundingTitle != null) { String title = null, translatedTitle = null, languageCode = null; if(funding.getType() != null) { profileFundingEntity.setType(funding.getType().name()); profileFundingEntity.setOrganizationDefinedType(funding.getOrganizationDefinedFundingType() != null ? funding.getOrganizationDefinedFundingType() .getContent() : null); if (funding.getUrl() != null)
Funding reducedFunding = new Funding(); reducedFunding.setVisibility(fullOrcidFunding.getVisibility()); reducedFunding.setDescription(fullOrcidFunding.getDescription()); reducedFunding.setTitle(fullOrcidFunding.getTitle()); reducedFundings.getFundings().add(reducedFunding);
if (funding.getAmount() != null && StringUtils.isNotBlank(funding.getAmount().getContent())) { String amount = funding.getAmount().getContent(); Locale locale = localeManager.getLocale(); ParsePosition parsePosition = new ParsePosition(0); "The amount: " + amount + " doesn'n have the right format, it should use the format: " + numberFormatExample.format(example)); funding.getAmount().setContent(formattedAmount);
/** * Get an OrgEntity object based on the provided orcidGrant * * @param orcidGrant * @return a OrgEntity based on the provided OrcidGrant * */ private OrgEntity getOrgEntity(Funding orcidFunding) { if (orcidFunding != null) { OrgEntity orgEntity = new OrgEntity(); Organization organization = orcidFunding.getOrganization(); orgEntity.setName(organization.getName()); OrganizationAddress address = organization.getAddress(); orgEntity.setCity(address.getCity()); orgEntity.setRegion(address.getRegion()); orgEntity.setCountry(address.getCountry().name()); if (organization.getDisambiguatedOrganization() != null && organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) { orgEntity.setOrgDisambiguated(orgDisambiguatedDao.findBySourceIdAndSourceType(organization.getDisambiguatedOrganization() .getDisambiguatedOrganizationIdentifier(), organization.getDisambiguatedOrganization().getDisambiguationSource())); } return orgManager.createUpdate(orgEntity); } return null; }
Funding reducedFunding = new Funding(); reducedFunding.setVisibility(fullOrcidFunding.getVisibility()); reducedFunding.setDescription(fullOrcidFunding.getDescription()); reducedFunding.setTitle(fullOrcidFunding.getTitle()); reducedFundings.getFundings().add(reducedFunding);