Search in sources :

Example 26 with Fundings

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);
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) ProfileFundingEntity(org.orcid.persistence.jpa.entities.ProfileFundingEntity) OrgEntity(org.orcid.persistence.jpa.entities.OrgEntity) Transactional(org.springframework.transaction.annotation.Transactional)

Example 27 with Fundings

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

Example 28 with Fundings

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());
}
Also used : Response(javax.ws.rs.core.Response) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 29 with Fundings

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());
}
Also used : Response(javax.ws.rs.core.Response) Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 30 with Fundings

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

Aggregations

FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)45 Test (org.junit.Test)44 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)28 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)28 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)28 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)27 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)27 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)27 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)27 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)27 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)27 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)26 Fundings (org.orcid.jaxb.model.v3.dev1.record.summary.Fundings)20 Name (org.orcid.jaxb.model.v3.dev1.record.Name)15 Address (org.orcid.jaxb.model.v3.dev1.record.Address)14 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)14 Email (org.orcid.jaxb.model.v3.dev1.record.Email)14 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)14 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)14 Person (org.orcid.jaxb.model.v3.dev1.record.Person)14