Search in sources :

Example 1 with Memberships

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

the class MemberV3ApiServiceDelegatorImpl method viewMemberships.

@Override
public Response viewMemberships(String orcid) {
    List<MembershipSummary> membershipsList = affiliationsManagerReadOnly.getMembershipSummaryList(orcid);
    // Lets copy the list so we don't modify the cached collection
    List<MembershipSummary> filteredList = null;
    if (membershipsList != null) {
        filteredList = new ArrayList<MembershipSummary>(membershipsList);
    }
    membershipsList = filteredList;
    orcidSecurityManager.checkAndFilter(orcid, membershipsList, ScopePathType.AFFILIATIONS_READ_LIMITED);
    Memberships memberships = new Memberships(membershipsList);
    ActivityUtils.setPathToAffiliations(memberships, orcid);
    sourceUtils.setSourceName(memberships);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(memberships);
    return Response.ok(memberships).build();
}
Also used : Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)

Example 2 with Memberships

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMembershipsReadPublic.

@Test
public void testViewMembershipsReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewMemberships(ORCID);
    Memberships element = (Memberships) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/memberships", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Memberships

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testViewMemberships.

@Test
public void testViewMemberships() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewMemberships(ORCID);
    assertNotNull(r);
    Memberships memberships = (Memberships) r.getEntity();
    assertNotNull(memberships);
    assertEquals("/0000-0000-0000-0003/memberships", memberships.getPath());
    Utils.verifyLastModified(memberships.getLastModifiedDate());
    assertNotNull(memberships.getSummaries());
    assertEquals(4, memberships.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (MembershipSummary summary : memberships.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(37).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(38).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(39).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(40).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid membership found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Memberships

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

the class PublicV3ApiServiceDelegatorTest method testGetPublicMembershipsUsingToken.

@Test
public void testGetPublicMembershipsUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewMemberships(ORCID);
    assertNotNull(r);
    Memberships memberships = (Memberships) r.getEntity();
    assertNotNull(memberships);
    assertNotNull(memberships.getLastModifiedDate());
    assertNotNull(memberships.getLastModifiedDate().getValue());
    assertNotNull(memberships.getSummaries());
    assertEquals(1, memberships.getSummaries().size());
    assertEquals(Long.valueOf(37), memberships.getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, memberships.getSummaries().get(0).getVisibility());
    assertNotNull(memberships.getSummaries().get(0).getLastModifiedDate());
    assertNotNull(memberships.getSummaries().get(0).getLastModifiedDate().getValue());
}
Also used : Response(javax.ws.rs.core.Response) Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Memberships

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

the class PublicAPISecurityManagerV3Test method filterMembershipsTest.

@Test
public void filterMembershipsTest() {
    Memberships e = getMemberships(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV3.filter(e);
    assertEquals(3, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getMemberships(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV3.filter(e);
    assertEquals(2, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getMemberships(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV3.filter(e);
    assertEquals(1, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getMemberships(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV3.filter(e);
    assertTrue(e.getSummaries().isEmpty());
}
Also used : Memberships(org.orcid.jaxb.model.v3.dev1.record.summary.Memberships) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)43 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)40 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)34 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)34 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)34 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)34 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)34 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)34 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)34 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)34 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)34 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)33 Memberships (org.orcid.jaxb.model.v3.dev1.record.summary.Memberships)16 Address (org.orcid.jaxb.model.v3.dev1.record.Address)15 Email (org.orcid.jaxb.model.v3.dev1.record.Email)15 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)15 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)15 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)15 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)14 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14