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());
}
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());
}
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;
}
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();
}
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);
}
}
Aggregations