Search in sources :

Example 81 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc3.FundingSummary in project ORCID-Source by ORCID.

the class ProfileFundingManagerTest method testGetPublic.

@Test
public void testGetPublic() {
    String orcid = "0000-0000-0000-0003";
    List<FundingSummary> elements = profileFundingManager.getFundingSummaryList(orcid, System.currentTimeMillis());
    assertNotNull(elements);
    assertEquals(5, elements.size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
    for (FundingSummary element : elements) {
        if (10 == element.getPutCode()) {
            found1 = true;
        } else if (11 == element.getPutCode()) {
            found2 = true;
        } else if (12 == element.getPutCode()) {
            found3 = true;
        } else if (13 == element.getPutCode()) {
            found4 = true;
        } else if (14 == element.getPutCode()) {
            found5 = true;
        } else {
            fail("Invalid put code found: " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertTrue(found5);
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 82 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc3.FundingSummary in project ORCID-Source by ORCID.

the class ProfileFundingManagerTest method testGroupFundings_groupOnlyPublicFundings2.

@Test
public void testGroupFundings_groupOnlyPublicFundings2() {
    FundingSummary s1 = getFundingSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
    FundingSummary s2 = getFundingSummary("Limited 1", "ext-id-1", Visibility.LIMITED);
    FundingSummary s3 = getFundingSummary("Private 1", "ext-id-1", Visibility.PRIVATE);
    FundingSummary s4 = getFundingSummary("Public 2", "ext-id-1", Visibility.PUBLIC);
    FundingSummary s5 = getFundingSummary("Limited 2", "ext-id-1", Visibility.LIMITED);
    FundingSummary s6 = getFundingSummary("Private 2", "ext-id-1", Visibility.PRIVATE);
    FundingSummary s7 = getFundingSummary("Public 3", "ext-id-2", Visibility.PUBLIC);
    FundingSummary s8 = getFundingSummary("Limited 3", "ext-id-2", Visibility.LIMITED);
    FundingSummary s9 = getFundingSummary("Private 3", "ext-id-2", Visibility.PRIVATE);
    List<FundingSummary> fundingList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
    /**
         * They should be grouped as
         * 
         * Group 1: Public 1 + Public 2
         * Group 2: Public 3
         * */
    Fundings fundings = profileFundingManager.groupFundings(fundingList, true);
    assertNotNull(fundings);
    assertEquals(2, fundings.getFundingGroup().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(2, fundings.getFundingGroup().get(0).getFundingSummary().size());
    assertThat(fundings.getFundingGroup().get(0).getFundingSummary().get(0).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
    assertThat(fundings.getFundingGroup().get(0).getFundingSummary().get(1).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
    assertEquals(1, fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, fundings.getFundingGroup().get(1).getFundingSummary().size());
    assertEquals("Public 3", fundings.getFundingGroup().get(1).getFundingSummary().get(0).getTitle().getTitle().getContent());
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 83 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc3.FundingSummary in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_2GroupsOf2Fundings_Test.

/**
     * Test grouping (funding-1 and funding-2) and (funding-5 and funding-6) 
     * */
@Test
public void groupFundings_2GroupsOf2Fundings_Test() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    Map<String, FundingSummary> fundings = generateFundings();
    FundingSummary funding1 = fundings.get("funding-1");
    FundingSummary funding2 = fundings.get("funding-2");
    FundingSummary funding5 = fundings.get("funding-5");
    FundingSummary funding6 = fundings.get("funding-6");
    generator.group(funding1);
    generator.group(funding2);
    generator.group(funding5);
    generator.group(funding6);
    List<ActivitiesGroup> groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(2, groups.size());
    //Check there are two activities in each group
    assertEquals(2, groups.get(0).getActivities().size());
    assertEquals(2, groups.get(1).getActivities().size());
    //Check there are five external ids in each group
    assertEquals(5, groups.get(0).getGroupKeys().size());
    assertEquals(5, groups.get(1).getGroupKeys().size());
    //Check each funding
    checkActivityIsOnGroups(funding1, groups);
    checkActivityIsOnGroups(funding2, groups);
    checkActivityIsOnGroups(funding5, groups);
    checkActivityIsOnGroups(funding6, groups);
    //Check funding1 and funding2 are in the same group
    checkActivitiesBelongsToTheSameGroup(groups, funding1, funding2);
    //Check funding6 and funding7 are in the same group
    checkActivitiesBelongsToTheSameGroup(groups, funding5, funding6);
    //Check fundings are not mixed
    checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding5);
    checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding6);
    checkActivitiesDontBelongsToTheSameGroup(groups, funding2, funding5);
    checkActivitiesDontBelongsToTheSameGroup(groups, funding2, funding6);
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Test(org.junit.Test)

Example 84 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc3.FundingSummary in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_MergeGroupsDontAffectNotMergedGroups_Test.

/**
     * funding-1, funding-3, funding-5 and funding-8 will be in separate groups
     * then funding-4 will merge groups of funding-1 and funding-3
     * 
     * Check that after that, there are 3 groups, one with funding-1, funding-3 and funding-4, one with funding-5 and other with funding-8
     * */
@Test
public void groupFundings_MergeGroupsDontAffectNotMergedGroups_Test() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    Map<String, FundingSummary> fundings = generateFundings();
    //Group the first group
    FundingSummary funding1 = fundings.get("funding-1");
    FundingSummary funding3 = fundings.get("funding-3");
    FundingSummary funding4 = fundings.get("funding-4");
    FundingSummary funding5 = fundings.get("funding-5");
    FundingSummary funding8 = fundings.get("funding-8");
    //Respect order
    generator.group(funding1);
    generator.group(funding3);
    generator.group(funding5);
    generator.group(funding8);
    generator.group(funding4);
    List<ActivitiesGroup> groups = generator.getGroups();
    assertNotNull(groups);
    assertEquals(3, groups.size());
    //Check funding1, funding3 and funding4 belongs to the same group
    checkActivitiesBelongsToTheSameGroup(groups, funding1, funding3, funding4);
    //Check funding1, funding5 and funding8 are all in different groups
    checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding5, funding8);
    checkActivityIsOnGroups(funding1, groups);
    checkActivityIsOnGroups(funding3, groups);
    checkActivityIsOnGroups(funding4, groups);
    checkActivityIsOnGroups(funding5, groups);
    checkActivityIsOnGroups(funding8, groups);
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Test(org.junit.Test)

Example 85 with FundingSummary

use of org.orcid.jaxb.model.record.summary_rc3.FundingSummary 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

FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)72 Test (org.junit.Test)69 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)45 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)45 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)45 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)43 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)39 ClientResponse (com.sun.jersey.api.client.ClientResponse)20 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)18 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)18 Address (org.orcid.jaxb.model.record_v2.Address)18 Email (org.orcid.jaxb.model.record_v2.Email)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)18 Record (org.orcid.jaxb.model.record_v2.Record)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)18 Name (org.orcid.jaxb.model.record_v2.Name)17 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15