Search in sources :

Example 86 with Funding

use of org.orcid.jaxb.model.record_v2.Funding 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.record_v2.Funding)

Example 87 with Funding

use of org.orcid.jaxb.model.record_v2.Funding 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.record_v2.Funding)

Example 88 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class FundingsController method createFundingIdList.

/**
     * Create a funding id list and sorts a map associated with the list in in
     * the session
     * 
     */
private List<String> createFundingIdList(HttpServletRequest request) {
    Map<String, String> languages = lm.buildLanguageMap(getUserLocale(), false);
    String orcid = getEffectiveUserOrcid();
    List<Funding> fundings = profileFundingManager.getFundingList(orcid, profileEntityManager.getLastModified(orcid));
    HashMap<String, FundingForm> fundingsMap = new HashMap<String, FundingForm>();
    List<String> fundingIds = new ArrayList<String>();
    if (fundings != null) {
        for (Funding funding : fundings) {
            try {
                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));
                }
                if (form.getContributors() != null) {
                    for (Contributor contributor : form.getContributors()) {
                        if (!PojoUtil.isEmpty(contributor.getOrcid())) {
                            String contributorOrcid = contributor.getOrcid().getValue();
                            if (profileEntityManager.orcidExists(contributorOrcid)) {
                                // contributor is an ORCID user - visibility of user's name in record must be taken into account 
                                ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
                                String publicContributorCreditName = cacheManager.getPublicCreditName(profileEntity);
                                contributor.setCreditName(Text.valueOf(publicContributorCreditName));
                            }
                        }
                    }
                }
                form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, funding.getOrganization().getAddress().getCountry().name())));
                String putCode = String.valueOf(funding.getPutCode());
                fundingsMap.put(putCode, form);
                fundingIds.add(putCode);
            } catch (Exception e) {
                LOGGER.error("Failed to parse as Funding. Put code" + funding.getPutCode(), e);
            }
        }
        request.getSession().setAttribute(GRANT_MAP, fundingsMap);
    }
    return fundingIds;
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) HashMap(java.util.HashMap) FundingForm(org.orcid.pojo.ajaxForm.FundingForm) ArrayList(java.util.ArrayList) Contributor(org.orcid.pojo.ajaxForm.Contributor) BigDecimal(java.math.BigDecimal) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity)

Example 89 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewFunding.

@Override
public Response viewFunding(String orcid, Long putCode) {
    Funding f = profileFundingManagerReadOnly.getFunding(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, f, ScopePathType.FUNDING_READ_LIMITED);
    ActivityUtils.setPathToActivity(f, orcid);
    sourceUtils.setSourceName(f);
    contributorUtils.filterContributorPrivateData(f);
    return Response.ok(f).build();
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding)

Example 90 with Funding

use of org.orcid.jaxb.model.record_v2.Funding in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method createFunding.

@Override
public Response createFunding(String orcid, Funding funding) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.FUNDING_CREATE);
    clearSource(funding);
    Funding f = profileFundingManager.createFunding(orcid, funding, true);
    sourceUtils.setSourceName(f);
    try {
        return Response.created(new URI(String.valueOf(f.getPutCode()))).build();
    } catch (URISyntaxException e) {
        throw new RuntimeException(localeManager.resolveMessage("apiError.createfunding_response.exception"), e);
    }
}
Also used : Funding(org.orcid.jaxb.model.record_v2.Funding) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

Funding (org.orcid.jaxb.model.record_v2.Funding)82 Test (org.junit.Test)75 ClientResponse (com.sun.jersey.api.client.ClientResponse)28 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)21 ArrayList (java.util.ArrayList)19 Response (javax.ws.rs.core.Response)16 Url (org.orcid.jaxb.model.common_v2.Url)16 DBUnitTest (org.orcid.test.DBUnitTest)16 Title (org.orcid.jaxb.model.common_v2.Title)12 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)12 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)10 OtherName (org.orcid.jaxb.model.record_v2.OtherName)10 Work (org.orcid.jaxb.model.record_v2.Work)10 ProfileFundingEntity (org.orcid.persistence.jpa.entities.ProfileFundingEntity)10 List (java.util.List)9 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)9 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)8 IOException (java.io.IOException)7 BaseTest (org.orcid.core.BaseTest)7