Search in sources :

Example 1 with Employments

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

the class MemberV3ApiServiceDelegatorImpl method viewEmployments.

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

Example 2 with Employments

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

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_PeerReviewReadLimited_NoSource.

@Test
public void testViewActitivies_PeerReviewReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.PEER_REVIEW_READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertNotNull(as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    // Only public educations
    assertNotNull(as.getEducations());
    assertEquals(1, as.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
    // Only public employments
    assertNotNull(as.getEmployments());
    assertEquals(1, as.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
    // Only public funding
    assertNotNull(as.getFundings());
    assertEquals(1, as.getFundings().getFundingGroup().size());
    assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
    // Limited peer reviews
    boolean found1 = false, found2 = false, found3 = false;
    assertNotNull(as.getPeerReviews());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
        assertEquals(1, group.getPeerReviewSummary().size());
        PeerReviewSummary element = group.getPeerReviewSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(9))) {
            assertEquals(Visibility.PUBLIC, element.getVisibility());
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(10))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    // Only public works
    assertNotNull(as.getWorks());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Employments

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

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_FundingReadLimited_NoSource.

@Test
public void testViewActitivies_FundingReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.FUNDING_READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertNotNull(as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    // Only public educations
    assertNotNull(as.getEducations());
    assertEquals(1, as.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
    // Only public employments
    assertNotNull(as.getEmployments());
    assertEquals(1, as.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
    // Limited funding
    boolean found1 = false, found2 = false, found3 = false;
    assertNotNull(as.getFundings());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    for (FundingGroup group : as.getFundings().getFundingGroup()) {
        assertEquals(1, group.getFundingSummary().size());
        FundingSummary element = group.getFundingSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(10))) {
            assertEquals(Visibility.PUBLIC, element.getVisibility());
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(11))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(13))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    // Only public peer reviews
    assertNotNull(as.getPeerReviews());
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
    // Only public works
    assertNotNull(as.getWorks());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Employments

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmployments.

@Test
public void testViewEmployments() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewEmployments(ORCID);
    assertNotNull(r);
    Employments employments = (Employments) r.getEntity();
    assertNotNull(employments);
    assertEquals("/0000-0000-0000-0003/employments", employments.getPath());
    Utils.verifyLastModified(employments.getLastModifiedDate());
    assertNotNull(employments.getSummaries());
    assertEquals(4, employments.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (EmploymentSummary summary : employments.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(17).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(18).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(19).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(23).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid education found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) Employments(org.orcid.jaxb.model.v3.dev1.record.summary.Employments) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with Employments

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

the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmploymentsReadPublic.

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

Aggregations

Test (org.junit.Test)48 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)42 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)39 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)36 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)36 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)36 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)35 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)34 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)34 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)34 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)34 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)34 Employments (org.orcid.jaxb.model.v3.dev1.record.summary.Employments)17 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