Search in sources :

Example 76 with FundingSummary

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

the class PublicV2ApiServiceDelegatorImpl method viewFundings.

@Override
public Response viewFundings(String orcid) {
    List<FundingSummary> fundings = profileFundingManagerReadOnly.getFundingSummaryList(orcid, getLastModifiedTime(orcid));
    Fundings publicFundings = profileFundingManagerReadOnly.groupFundings(fundings, true);
    publicAPISecurityManagerV2.filter(publicFundings);
    ActivityUtils.setPathToFundings(publicFundings, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(publicFundings);
    sourceUtilsReadOnly.setSourceName(publicFundings);
    return Response.ok(publicFundings).build();
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary)

Example 77 with FundingSummary

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

the class MemberV2ApiServiceDelegatorImpl method viewFundingSummary.

@Override
public Response viewFundingSummary(String orcid, Long putCode) {
    FundingSummary fs = profileFundingManagerReadOnly.getSummary(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, fs, ScopePathType.FUNDING_READ_LIMITED);
    ActivityUtils.setPathToActivity(fs, orcid);
    sourceUtils.setSourceName(fs);
    return Response.ok(fs).build();
}
Also used : FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary)

Example 78 with FundingSummary

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

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

the class ProfileFundingManagerTest method getFundingSummary.

private FundingSummary getFundingSummary(String titleValue, String extIdValue, Visibility visibility) {
    FundingSummary summary = new FundingSummary();
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title(titleValue));
    summary.setTitle(fundingTitle);
    summary.setVisibility(visibility);
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("doi");
    extId.setUrl(new Url("http://orcid.org"));
    extId.setValue(extIdValue);
    extIds.getExternalIdentifier().add(extId);
    summary.setExternalIdentifiers(extIds);
    Organization org = new Organization();
    org.setName("org-name");
    OrganizationAddress address = new OrganizationAddress();
    address.setCity("city");
    address.setCountry(Iso3166Country.US);
    org.setAddress(address);
    summary.setOrganization(org);
    return summary;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Organization(org.orcid.jaxb.model.common_v2.Organization) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url)

Example 80 with FundingSummary

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

the class ProfileFundingManagerTest method testGroupFundings.

@Test
public void testGroupFundings() {
    /**
         * They should be grouped as
         * 
         * Group 1: Funding 1 + Funding 4
         * Group 2: Funding 2 + Funding 5
         * Group 3: Funding 3
         * Group 4: Funding 6
         * */
    FundingSummary s1 = getFundingSummary("Funding 1", "ext-id-1", Visibility.PUBLIC);
    FundingSummary s2 = getFundingSummary("Funding 2", "ext-id-2", Visibility.LIMITED);
    FundingSummary s3 = getFundingSummary("Funding 3", "ext-id-3", Visibility.PRIVATE);
    FundingSummary s4 = getFundingSummary("Funding 4", "ext-id-1", Visibility.PRIVATE);
    FundingSummary s5 = getFundingSummary("Funding 5", "ext-id-2", Visibility.PUBLIC);
    FundingSummary s6 = getFundingSummary("Funding 6", "ext-id-4", Visibility.PRIVATE);
    List<FundingSummary> fundingList1 = Arrays.asList(s1, s2, s3, s4, s5, s6);
    Fundings fundings1 = profileFundingManager.groupFundings(fundingList1, false);
    assertNotNull(fundings1);
    assertEquals(4, fundings1.getFundingGroup().size());
    //Group 1 have all with ext-id-1
    assertEquals(2, fundings1.getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(1, fundings1.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", fundings1.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    //Group 2 have all with ext-id-2
    assertEquals(2, fundings1.getFundingGroup().get(1).getFundingSummary().size());
    assertEquals(1, fundings1.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", fundings1.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    //Group 3 have ext-id-3
    assertEquals(1, fundings1.getFundingGroup().get(2).getFundingSummary().size());
    assertEquals(1, fundings1.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-3", fundings1.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
    //Group 4 have ext-id-4
    assertEquals(1, fundings1.getFundingGroup().get(3).getFundingSummary().size());
    assertEquals(1, fundings1.getFundingGroup().get(3).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-4", fundings1.getFundingGroup().get(3).getIdentifiers().getExternalIdentifier().get(0).getValue());
    FundingSummary s7 = getFundingSummary("Funding 7", "ext-id-4", Visibility.PRIVATE);
    //Add ext-id-3 to work 7, so, it join group 3 and group 4 in a single group
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("doi");
    extId.setUrl(new Url("http://orcid.org"));
    extId.setValue("ext-id-3");
    s7.getExternalIdentifiers().getExternalIdentifier().add(extId);
    /**
         * Now, they should be grouped as
         * 
         * Group 1: Funding 1 + Funding 4
         * Group 2: Funding 2 + Funding 5
         * Group 3: Funding 3 + Funding 6 + Funding 7
         * */
    List<FundingSummary> fundingsList2 = Arrays.asList(s1, s2, s3, s4, s5, s6, s7);
    Fundings fundings2 = profileFundingManager.groupFundings(fundingsList2, false);
    assertNotNull(fundings2);
    assertEquals(3, fundings2.getFundingGroup().size());
    //Group 1 have all with ext-id-1
    assertEquals(2, fundings2.getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(1, fundings2.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", fundings2.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    //Group 2 have all with ext-id-2
    assertEquals(2, fundings2.getFundingGroup().get(1).getFundingSummary().size());
    assertEquals(1, fundings2.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", fundings2.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    //Group 3 have all with ext-id-3 and ext-id-4
    assertEquals(3, fundings2.getFundingGroup().get(2).getFundingSummary().size());
    assertEquals(2, fundings2.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertThat(fundings2.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
    assertThat(fundings2.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(1).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

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