Search in sources :

Example 6 with Amount

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;
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) FundingForm(org.orcid.pojo.ajaxForm.FundingForm) BigDecimal(java.math.BigDecimal) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 7 with Amount

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());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding)

Example 8 with Amount

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());
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding)

Example 9 with Amount

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;
}
Also used : TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) Amount(org.orcid.jaxb.model.v3.dev1.common.Amount) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) FundingContributors(org.orcid.jaxb.model.v3.dev1.record.FundingContributors) FundingContributorAttributes(org.orcid.jaxb.model.v3.dev1.record.FundingContributorAttributes) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ContributorOrcid(org.orcid.jaxb.model.v3.dev1.common.ContributorOrcid) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) Url(org.orcid.jaxb.model.v3.dev1.common.Url) OrganizationDefinedFundingSubType(org.orcid.jaxb.model.v3.dev1.common.OrganizationDefinedFundingSubType)

Aggregations

Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 Amount (org.orcid.jaxb.model.v3.dev1.common.Amount)4 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)3 FundingForm (org.orcid.pojo.ajaxForm.FundingForm)3 HashMap (java.util.HashMap)2 FuzzyDate (org.orcid.jaxb.model.v3.dev1.common.FuzzyDate)2 OrganizationDefinedFundingSubType (org.orcid.jaxb.model.v3.dev1.common.OrganizationDefinedFundingSubType)2 Title (org.orcid.jaxb.model.v3.dev1.common.Title)2 Url (org.orcid.jaxb.model.v3.dev1.common.Url)2 FundingContributor (org.orcid.jaxb.model.v3.dev1.record.FundingContributor)2 FundingContributors (org.orcid.jaxb.model.v3.dev1.record.FundingContributors)2 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Date (java.util.Date)1 List (java.util.List)1 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1