Search in sources :

Example 31 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc2.FundingGroup in project ORCID-Source by ORCID.

the class ProfileFundingManagerTest method nonGroupableIdsGenerateEmptyIdsListTest.

@Test
public void nonGroupableIdsGenerateEmptyIdsListTest() {
    FundingSummary s1 = getFundingSummary("Element 1", "ext-id-1", Visibility.PUBLIC);
    FundingSummary s2 = getFundingSummary("Element 2", "ext-id-2", Visibility.LIMITED);
    FundingSummary s3 = getFundingSummary("Element 3", "ext-id-3", Visibility.PRIVATE);
    // s1 will be a part of identifier, so, it will go in its own group
    s1.getExternalIdentifiers().getExternalIdentifier().get(0).setRelationship(Relationship.PART_OF);
    List<FundingSummary> fundingList = Arrays.asList(s1, s2, s3);
    /**
         * They should be grouped as
         * 
         * Group 1: Element 1
         * Group 2: Element 2
         * Group 3: Element 3
         * */
    Fundings fundings = profileFundingManager.groupFundings(fundingList, false);
    assertNotNull(fundings);
    assertEquals(3, fundings.getFundingGroup().size());
    boolean foundEmptyGroup = false;
    boolean found2 = false;
    boolean found3 = false;
    for (FundingGroup group : fundings.getFundingGroup()) {
        assertEquals(1, group.getFundingSummary().size());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            assertEquals("Element 1", group.getFundingSummary().get(0).getTitle().getTitle().getContent());
            assertEquals("ext-id-1", group.getFundingSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            foundEmptyGroup = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            assertThat(group.getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-2"), is("ext-id-3")));
            if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("ext-id-2")) {
                assertEquals("Element 2", group.getFundingSummary().get(0).getTitle().getTitle().getContent());
                assertEquals("ext-id-2", group.getFundingSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                found2 = true;
            } else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("ext-id-3")) {
                assertEquals("Element 3", group.getFundingSummary().get(0).getTitle().getTitle().getContent());
                assertEquals("ext-id-3", group.getFundingSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                found3 = true;
            } else {
                fail("Invalid ext id found " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
            }
        }
    }
    assertTrue(foundEmptyGroup);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 32 with FundingGroup

use of org.orcid.jaxb.model.record.summary_rc2.FundingGroup in project ORCID-Source by ORCID.

the class SourceUtils method setSourceName.

public void setSourceName(ActivitiesSummary as) {
    if (as == null) {
        return;
    }
    if (as.getEducations() != null) {
        Educations educations = as.getEducations();
        List<EducationSummary> list = educations.getSummaries();
        if (list != null) {
            for (EducationSummary summary : list) {
                setSourceName(summary);
            }
        }
    }
    if (as.getEmployments() != null) {
        Employments employments = as.getEmployments();
        List<EmploymentSummary> list = employments.getSummaries();
        if (list != null) {
            for (EmploymentSummary summary : list) {
                setSourceName(summary);
            }
        }
    }
    if (as.getFundings() != null) {
        Fundings fundings = as.getFundings();
        List<FundingGroup> groups = fundings.getFundingGroup();
        if (groups != null) {
            for (FundingGroup group : groups) {
                List<FundingSummary> summaryList = group.getFundingSummary();
                if (summaryList != null) {
                    for (FundingSummary summary : summaryList) {
                        setSourceName(summary);
                    }
                }
            }
        }
    }
    if (as.getPeerReviews() != null) {
        PeerReviews peerReviews = as.getPeerReviews();
        List<PeerReviewGroup> groups = peerReviews.getPeerReviewGroup();
        if (groups != null) {
            for (PeerReviewGroup group : groups) {
                List<PeerReviewSummary> summaryList = group.getPeerReviewSummary();
                if (summaryList != null) {
                    for (PeerReviewSummary summary : summaryList) {
                        setSourceName(summary);
                    }
                }
            }
        }
    }
    if (as.getWorks() != null) {
        Works works = as.getWorks();
        List<WorkGroup> groups = works.getWorkGroup();
        if (groups != null) {
            for (WorkGroup group : groups) {
                List<WorkSummary> summaryList = group.getWorkSummary();
                if (summaryList != null) {
                    for (WorkSummary summary : summaryList) {
                        setSourceName(summary);
                    }
                }
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Aggregations

Test (org.junit.Test)22 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)20 ClientResponse (com.sun.jersey.api.client.ClientResponse)19 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)18 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)13 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)13 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)12 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)12 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)12 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)12 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)9 ArrayList (java.util.ArrayList)7 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)7 Response (javax.ws.rs.core.Response)5 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)5 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)5 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)5 Works (org.orcid.jaxb.model.record.summary_v2.Works)5 Address (org.orcid.jaxb.model.record_v2.Address)5 Email (org.orcid.jaxb.model.record_v2.Email)5