use of org.orcid.jaxb.model.v3.dev1.common.Amount in project ORCID-Source by ORCID.
the class FundingsController method getFundingJson.
/**
* List fundings associated with a profile
*/
@RequestMapping(value = "/getFunding.json", method = RequestMethod.GET)
@ResponseBody
public FundingForm getFundingJson(@RequestParam(value = "fundingId") Long fundingId) {
if (fundingId == null)
return null;
Map<String, String> languages = lm.buildLanguageMap(getUserLocale(), false);
Funding funding = profileFundingManager.getFunding(getEffectiveUserOrcid(), fundingId);
FundingForm form = FundingForm.valueOf(funding);
if (funding.getType() != null) {
form.setFundingTypeForDisplay(getMessage(buildInternationalizationKey(org.orcid.jaxb.model.message.FundingType.class, funding.getType().value())));
}
// Set translated title language name
if (!(funding.getTitle().getTranslatedTitle() == null) && !StringUtils.isEmpty(funding.getTitle().getTranslatedTitle().getLanguageCode())) {
String languageName = languages.get(funding.getTitle().getTranslatedTitle().getLanguageCode());
form.getFundingTitle().getTranslatedTitle().setLanguageName(languageName);
}
// Set the formatted amount
if (funding.getAmount() != null && StringUtils.isNotBlank(funding.getAmount().getContent())) {
BigDecimal bigDecimal = new BigDecimal(funding.getAmount().getContent());
String formattedAmount = formatAmountString(bigDecimal);
form.setAmount(Text.valueOf(formattedAmount));
}
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, funding.getOrganization().getAddress().getCountry().name())));
return form;
}
use of org.orcid.jaxb.model.v3.dev1.common.Amount in project ORCID-Source by ORCID.
the class FundingsController method addFunding.
private void addFunding(FundingForm fundingForm) throws Exception {
// Set the right value for the amount
setAmountWithTheCorrectFormat(fundingForm);
// Set default type for external identifiers
setTypeToExternalIdentifiers(fundingForm);
// Add to database
Funding funding = fundingForm.toFunding();
funding = profileFundingManager.createFunding(getEffectiveUserOrcid(), funding, false);
// Send the new funding sub type for indexing
if (fundingForm.getOrganizationDefinedFundingSubType() != null && !PojoUtil.isEmpty(fundingForm.getOrganizationDefinedFundingSubType().getSubtype()) && !fundingForm.getOrganizationDefinedFundingSubType().isAlreadyIndexed())
profileFundingManager.addFundingSubType(fundingForm.getOrganizationDefinedFundingSubType().getSubtype().getValue(), getEffectiveUserOrcid());
}
use of org.orcid.jaxb.model.v3.dev1.common.Amount in project ORCID-Source by ORCID.
the class FundingsController method editFunding.
private void editFunding(FundingForm fundingForm) throws Exception {
// Set the right value for the amount
setAmountWithTheCorrectFormat(fundingForm);
// Set the credit name
setTypeToExternalIdentifiers(fundingForm);
// Add to database
Funding funding = fundingForm.toFunding();
funding = profileFundingManager.updateFunding(getEffectiveUserOrcid(), funding, false);
// Send the new funding sub type for indexing
if (fundingForm.getOrganizationDefinedFundingSubType() != null && !PojoUtil.isEmpty(fundingForm.getOrganizationDefinedFundingSubType().getSubtype()) && !fundingForm.getOrganizationDefinedFundingSubType().isAlreadyIndexed())
profileFundingManager.addFundingSubType(fundingForm.getOrganizationDefinedFundingSubType().getSubtype().getValue(), getEffectiveUserOrcid());
}
use of org.orcid.jaxb.model.v3.dev1.common.Amount in project ORCID-Source by ORCID.
the class ActivityValidatorTest method getFunding.
public Funding getFunding() {
Funding funding = new Funding();
Amount amount = new Amount();
amount.setContent("1000");
amount.setCurrencyCode("$");
funding.setAmount(amount);
FundingContributor contributor = new FundingContributor();
FundingContributorAttributes attributes = new FundingContributorAttributes();
attributes.setContributorRole(FundingContributorRole.LEAD);
ContributorOrcid contributorOrcid = new ContributorOrcid();
contributorOrcid.setHost("http://test.orcid.org");
contributorOrcid.setPath("0000-0000-0000-0000");
contributorOrcid.setUri("https://test.orcid.org/0000-0000-0000-0000");
contributor.setContributorAttributes(attributes);
contributor.setContributorOrcid(contributorOrcid);
FundingContributors contributors = new FundingContributors();
contributors.getContributor().add(contributor);
funding.setContributors(contributors);
funding.setDescription("description");
funding.setEndDate(getFuzzyDate());
funding.setExternalIdentifiers(getExternalIDs());
funding.setOrganization(getOrganization());
funding.setOrganizationDefinedType(new OrganizationDefinedFundingSubType("subtype"));
funding.setStartDate(getFuzzyDate());
FundingTitle title = new FundingTitle();
title.setTitle(new Title("title"));
title.setTranslatedTitle(new TranslatedTitle("translated title", "en"));
funding.setTitle(title);
funding.setType(FundingType.AWARD);
funding.setUrl(new Url("http://test.orcid.org"));
funding.setVisibility(Visibility.PUBLIC);
return funding;
}
Aggregations