Search in sources :

Example 1 with Fundings

use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_FundingTest method testViewFundings.

@Test
public void testViewFundings() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewFundings(ORCID);
    assertNotNull(r);
    Fundings fundings = (Fundings) r.getEntity();
    assertNotNull(fundings);
    assertEquals("/0000-0000-0000-0003/fundings", fundings.getPath());
    assertNotNull(fundings.getPath());
    Utils.verifyLastModified(fundings.getLastModifiedDate());
    assertNotNull(fundings.getFundingGroup());
    assertEquals(4, fundings.getFundingGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (FundingGroup fundingGroup : fundings.getFundingGroup()) {
        Utils.verifyLastModified(fundingGroup.getLastModifiedDate());
        assertNotNull(fundingGroup.getIdentifiers());
        assertNotNull(fundingGroup.getIdentifiers().getExternalIdentifier());
        assertEquals(1, fundingGroup.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(fundingGroup.getFundingSummary());
        assertEquals(1, fundingGroup.getFundingSummary().size());
        FundingSummary summary = fundingGroup.getFundingSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        switch(fundingGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "1":
                assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(10), summary.getPutCode());
                found1 = true;
                break;
            case "2":
                assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found2 = true;
                break;
            case "3":
                assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found3 = true;
                break;
            case "4":
                assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(13), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid external id found: " + fundingGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with Fundings

use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewFundings.

@Test
public void testViewFundings() {
    Response response = serviceDelegator.viewFundings(ORCID);
    assertNotNull(response);
    Fundings fundings = (Fundings) response.getEntity();
    assertNotNull(fundings);
    assertEquals("/0000-0000-0000-0003/fundings", fundings.getPath());
    assertNotNull(fundings.getLastModifiedDate());
    assertNotNull(fundings.getLastModifiedDate().getValue());
    assertEquals(1, fundings.getFundingGroup().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    FundingSummary funding = fundings.getFundingGroup().get(0).getFundingSummary().get(0);
    assertNotNull(funding.getTitle());
    assertNotNull(funding.getTitle().getTitle());
    assertEquals(Long.valueOf(10), funding.getPutCode());
    assertNotNull(funding.getLastModifiedDate());
    assertNotNull(funding.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/funding/10", funding.getPath());
    assertEquals("PUBLIC", funding.getTitle().getTitle().getContent());
    assertEquals(Visibility.PUBLIC.value(), funding.getVisibility().value());
    assertEquals("APP-5555555555555555", funding.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Fundings

use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testGetPublicFundings.

@Test
public void testGetPublicFundings() {
    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 4 with Fundings

use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getFundings.

private Fundings getFundings(Visibility... vs) {
    Fundings fundings = new Fundings();
    for (Visibility v : vs) {
        FundingGroup g = new FundingGroup();
        FundingSummary s = new FundingSummary();
        s.setVisibility(v);
        g.getFundingSummary().add(s);
        fundings.getFundingGroup().add(g);
    }
    return fundings;
}
Also used : Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)

Example 5 with Fundings

use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.

the class ProfileFundingManagerReadOnlyImpl method groupFundings.

/**
 * Generate a grouped list of funding with the given list of funding
 *
 * @param fundings
 *          The list of fundings to group
 * @param justPublic
 *          Specify if we want to group only the public elements in the given list
 * @return Fundings element with the FundingSummary elements grouped
 */
@Override
public Fundings groupFundings(List<FundingSummary> fundings, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    Fundings result = new Fundings();
    for (FundingSummary funding : fundings) {
        if (justPublic && !funding.getVisibility().equals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC)) {
        // If it is just public and the funding is not public, just
        // ignore it
        } else {
            groupGenerator.group(funding);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> externalIdentifiers = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        FundingGroup fundingGroup = new FundingGroup();
        // Fill the funding groups with the external identifiers
        if (externalIdentifiers == null || externalIdentifiers.isEmpty()) {
            // Initialize the ids as an empty list
            fundingGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble extId : externalIdentifiers) {
                ExternalID fundingExtId = (ExternalID) extId;
                fundingGroup.getIdentifiers().getExternalIdentifier().add(fundingExtId.clone());
            }
        }
        // Fill the funding group with the list of activities
        for (GroupableActivity activity : activities) {
            FundingSummary fundingSummary = (FundingSummary) activity;
            fundingGroup.getFundingSummary().add(fundingSummary);
        }
        // Sort the fundings
        Collections.sort(fundingGroup.getFundingSummary(), new GroupableActivityComparator());
        result.getFundingGroup().add(fundingGroup);
    }
    return result;
}
Also used : Fundings(org.orcid.jaxb.model.v3.dev1.record.summary.Fundings) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity) ActivitiesGroupGenerator(org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator) ActivitiesGroup(org.orcid.core.utils.v3.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) GroupableActivityComparator(org.orcid.core.utils.v3.activities.GroupableActivityComparator)

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