use of org.orcid.jaxb.model.v3.dev1.record.Funding 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.record.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.v3.dev1.record.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.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getFundingMapperFacade.
public MapperFacade getFundingMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ConverterFactory converterFactory = mapperFactory.getConverterFactory();
converterFactory.registerConverter("fundingExternalIdentifiersConverterId", new JSONFundingExternalIdentifiersConverterV3());
converterFactory.registerConverter("fundingContributorsConverterId", new JsonOrikaConverter<FundingContributors>());
ClassMapBuilder<Funding, ProfileFundingEntity> fundingClassMap = mapperFactory.classMap(Funding.class, ProfileFundingEntity.class);
addV3CommonFields(fundingClassMap);
registerSourceConverters(mapperFactory, fundingClassMap);
fundingClassMap.field("type", "type");
fundingClassMap.field("organizationDefinedType.content", "organizationDefinedType");
fundingClassMap.field("title.title.content", "title");
fundingClassMap.field("title.translatedTitle.content", "translatedTitle");
fundingClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
fundingClassMap.field("description", "description");
fundingClassMap.field("amount.content", "numericAmount");
fundingClassMap.field("amount.currencyCode", "currencyCode");
fundingClassMap.field("url.value", "url");
fundingClassMap.fieldBToA("org.name", "organization.name");
fundingClassMap.fieldBToA("org.city", "organization.address.city");
fundingClassMap.fieldBToA("org.region", "organization.address.region");
fundingClassMap.fieldBToA("org.country", "organization.address.country");
fundingClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
fundingClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
fundingClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
fundingClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("fundingExternalIdentifiersConverterId").add();
fundingClassMap.fieldMap("contributors", "contributorsJson").converter("fundingContributorsConverterId").add();
fundingClassMap.register();
ClassMapBuilder<FundingSummary, ProfileFundingEntity> fundingSummaryClassMap = mapperFactory.classMap(FundingSummary.class, ProfileFundingEntity.class);
addV3CommonFields(fundingSummaryClassMap);
registerSourceConverters(mapperFactory, fundingSummaryClassMap);
fundingSummaryClassMap.field("type", "type");
fundingSummaryClassMap.field("title.title.content", "title");
fundingSummaryClassMap.field("title.translatedTitle.content", "translatedTitle");
fundingSummaryClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
fundingSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("fundingExternalIdentifiersConverterId").add();
fundingSummaryClassMap.fieldBToA("org.name", "organization.name");
fundingSummaryClassMap.fieldBToA("org.city", "organization.address.city");
fundingSummaryClassMap.fieldBToA("org.region", "organization.address.region");
fundingSummaryClassMap.fieldBToA("org.country", "organization.address.country");
fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
fundingSummaryClassMap.register();
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AffiliationsReadLimited_And_NotSource.
@Test
public void testActivitiesSummary_When_AffiliationsReadLimited_And_NotSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.AFFILIATIONS_READ_LIMITED);
DistinctionSummary d1 = createDistinctionSummary(Visibility.PUBLIC, CLIENT_2);
DistinctionSummary d2 = createDistinctionSummary(Visibility.LIMITED, CLIENT_2);
DistinctionSummary d3 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
EducationSummary e2 = createEducationSummary(Visibility.LIMITED, CLIENT_2);
EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.LIMITED, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
InvitedPositionSummary i1 = createInvitedPositionSummary(Visibility.PUBLIC, CLIENT_2);
InvitedPositionSummary i2 = createInvitedPositionSummary(Visibility.LIMITED, CLIENT_2);
InvitedPositionSummary i3 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
MembershipSummary m1 = createMembershipSummary(Visibility.PUBLIC, CLIENT_2);
MembershipSummary m2 = createMembershipSummary(Visibility.LIMITED, CLIENT_2);
MembershipSummary m3 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
QualificationSummary q1 = createQualificationSummary(Visibility.PUBLIC, CLIENT_2);
QualificationSummary q2 = createQualificationSummary(Visibility.LIMITED, CLIENT_2);
QualificationSummary q3 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
ServiceSummary s1 = createServiceSummary(Visibility.PUBLIC, CLIENT_2);
ServiceSummary s2 = createServiceSummary(Visibility.LIMITED, CLIENT_2);
ServiceSummary s3 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(e1, e2, e3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
as.setDistinctions(createDistinctions(d1, d2, d3));
as.setInvitedPositions(createInvitedPositions(i1, i2, i3));
as.setMemberships(createMemberships(m1, m2, m3));
as.setQualifications(createQualifications(q1, q2, q3));
as.setServices(createServices(s1, s2, s3));
orcidSecurityManager.checkAndFilter(ORCID_1, as);
assertNotNull(as);
// Check distinctions
assertEquals(2, as.getDistinctions().getSummaries().size());
assertTrue(as.getDistinctions().getSummaries().contains(d1));
assertTrue(as.getDistinctions().getSummaries().contains(d2));
assertFalse(as.getDistinctions().getSummaries().contains(d3));
// Check invited positions
assertEquals(2, as.getInvitedPositions().getSummaries().size());
assertTrue(as.getInvitedPositions().getSummaries().contains(i1));
assertTrue(as.getInvitedPositions().getSummaries().contains(i2));
assertFalse(as.getInvitedPositions().getSummaries().contains(i3));
// Check memberships
assertEquals(2, as.getMemberships().getSummaries().size());
assertTrue(as.getMemberships().getSummaries().contains(m1));
assertTrue(as.getMemberships().getSummaries().contains(m2));
assertFalse(as.getMemberships().getSummaries().contains(m3));
// Check qualifications
assertEquals(2, as.getQualifications().getSummaries().size());
assertTrue(as.getQualifications().getSummaries().contains(q1));
assertTrue(as.getQualifications().getSummaries().contains(q2));
assertFalse(as.getQualifications().getSummaries().contains(q3));
// Check services
assertEquals(2, as.getServices().getSummaries().size());
assertTrue(as.getServices().getSummaries().contains(s1));
assertTrue(as.getServices().getSummaries().contains(s2));
assertFalse(as.getServices().getSummaries().contains(s3));
// Check it have limited Educations
assertNotNull(as.getEducations());
assertEquals(2, as.getEducations().getSummaries().size());
assertTrue(as.getEducations().getSummaries().contains(e1));
assertTrue(as.getEducations().getSummaries().contains(e2));
assertFalse(as.getEducations().getSummaries().contains(e3));
// Check it have limited Employments
assertNotNull(as.getEmployments());
assertEquals(2, as.getEmployments().getSummaries().size());
assertTrue(as.getEmployments().getSummaries().contains(em1));
assertTrue(as.getEmployments().getSummaries().contains(em2));
assertFalse(as.getEmployments().getSummaries().contains(em3));
// Check it have only public funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getActivities().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
assertEquals(2, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
// Check it have only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
// Check it have only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getActivities().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
assertEquals(2, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
Aggregations