use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class ProfileFundingManagerImpl method createFunding.
/**
* Add a new funding to the given user
* @param orcid
* The user to add the funding
* @param funding
* The funding to add
* @return the added funding
*/
@Override
@Transactional
public Funding createFunding(String orcid, Funding funding, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
activityValidator.validateFunding(funding, sourceEntity, true, isApiRequest, null);
// Check for duplicates
List<ProfileFundingEntity> existingFundings = profileFundingDao.getByUser(orcid, getLastModified(orcid));
List<Funding> fundings = jpaJaxbFundingAdapter.toFunding(existingFundings);
if (fundings != null && isApiRequest) {
for (Funding exstingFunding : fundings) {
activityValidator.checkFundingExternalIdentifiersForDuplicates(funding.getExternalIdentifiers(), exstingFunding.getExternalIdentifiers(), exstingFunding.getSource(), sourceEntity);
}
}
ProfileFundingEntity profileFundingEntity = jpaJaxbFundingAdapter.toProfileFundingEntity(funding);
// Updates the give organization with the latest organization from database
OrgEntity updatedOrganization = orgManager.getOrgEntity(funding);
profileFundingEntity.setOrg(updatedOrganization);
// Set the source
if (sourceEntity.getSourceProfile() != null) {
profileFundingEntity.setSourceId(sourceEntity.getSourceProfile().getId());
}
if (sourceEntity.getSourceClient() != null) {
profileFundingEntity.setClientSourceId(sourceEntity.getSourceClient().getId());
}
ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
profileFundingEntity.setProfile(profile);
setIncomingWorkPrivacy(profileFundingEntity, profile);
DisplayIndexCalculatorHelper.setDisplayIndexOnNewEntity(profileFundingEntity, isApiRequest);
profileFundingDao.persist(profileFundingEntity);
profileFundingDao.flush();
if (isApiRequest) {
notificationManager.sendAmendEmail(orcid, AmendedSection.FUNDING, createItemList(profileFundingEntity));
}
return jpaJaxbFundingAdapter.toFunding(profileFundingEntity);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class ActivityManagerImpl method fundingMap.
public LinkedHashMap<Long, Funding> fundingMap(String orcid) {
List<Funding> fundings = profileFundingManager.getFundingList(orcid);
LinkedHashMap<Long, Funding> fundingMap = new LinkedHashMap<>();
if (fundings != null) {
for (Funding funding : fundings) {
if (funding.getVisibility().equals(Visibility.PUBLIC))
fundingMap.put(Long.valueOf(funding.getPutCode()), funding);
}
}
return fundingMap;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_NoReadLimited_NoSource.
@Test
public void testViewActitivies_NoReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.READ_PUBLIC);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Only public educations
assertNotNull(as.getEducations());
assertEquals("/0000-0000-0000-0003/educations", as.getEducations().getPath());
assertEquals(1, as.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
// Only public employments
assertNotNull(as.getEmployments());
assertEquals("/0000-0000-0000-0003/employments", as.getEmployments().getPath());
assertEquals(1, as.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
// Only public funding
assertNotNull(as.getFundings());
assertEquals("/0000-0000-0000-0003/fundings", as.getFundings().getPath());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
// Only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals("/0000-0000-0000-0003/peer-reviews", as.getPeerReviews().getPath());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
// Only public works
assertNotNull(as.getWorks());
assertEquals("/0000-0000-0000-0003/works", as.getWorks().getPath());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorTest method testGetPublicFundingsUsingToken.
@Test
public void testGetPublicFundingsUsingToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewFundings(ORCID);
assertNotNull(r);
Fundings fundings = (Fundings) r.getEntity();
assertNotNull(fundings);
assertNotNull(fundings.getLastModifiedDate());
assertNotNull(fundings.getLastModifiedDate().getValue());
assertNotNull(fundings.getFundingGroup());
assertEquals(1, fundings.getFundingGroup().size());
assertNotNull(fundings.getFundingGroup().get(0).getIdentifiers());
assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals("http://test.orcid.org/1.com", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
assertNotNull(fundings.getFundingGroup().get(0).getFundingSummary());
assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), fundings.getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertNotNull(fundings.getFundingGroup().get(0).getFundingSummary().get(0).getLastModifiedDate());
assertNotNull(fundings.getFundingGroup().get(0).getFundingSummary().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method filterFundingsTest.
@Test
public void filterFundingsTest() {
Fundings f = getFundings(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV3.filter(f);
assertEquals(3, f.getFundingGroup().size());
assertGroupContainsOnlyPublicElements(f);
f = getFundings(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV3.filter(f);
assertEquals(2, f.getFundingGroup().size());
assertGroupContainsOnlyPublicElements(f);
f = getFundings(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV3.filter(f);
assertEquals(1, f.getFundingGroup().size());
assertGroupContainsOnlyPublicElements(f);
f = getFundings(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, f.getFundingGroup().size());
publicAPISecurityManagerV3.filter(f);
assertTrue(f.getFundingGroup().isEmpty());
}
Aggregations