Search in sources :

Example 16 with Employments

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

the class MemberV2ApiServiceDelegatorImpl 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.setPathToEmployments(employments, orcid);
    sourceUtils.setSourceName(employments);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(employments);
    return Response.ok(employments).build();
}
Also used : Employments(org.orcid.jaxb.model.record.summary_v2.Employments) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)

Example 17 with Employments

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

Example 18 with Employments

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

the class PublicV2ApiServiceDelegatorTest method testGetPublicEmployments.

@Test
public void testGetPublicEmployments() {
    Response r = serviceDelegator.viewEmployments(ORCID);
    assertNotNull(r);
    Employments employments = (Employments) r.getEntity();
    assertNotNull(employments);
    assertNotNull(employments.getLastModifiedDate());
    assertNotNull(employments.getLastModifiedDate().getValue());
    assertNotNull(employments.getSummaries());
    assertEquals(1, employments.getSummaries().size());
    assertEquals(Long.valueOf(17), employments.getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, employments.getSummaries().get(0).getVisibility());
    assertNotNull(employments.getSummaries().get(0).getLastModifiedDate());
    assertNotNull(employments.getSummaries().get(0).getLastModifiedDate().getValue());
}
Also used : Response(javax.ws.rs.core.Response) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 19 with Employments

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

the class PublicV2ApiServiceDelegatorTest method testViewEmployments.

@Test
public void testViewEmployments() {
    Response response = serviceDelegator.viewEmployments(ORCID);
    assertNotNull(response);
    Employments employments = (Employments) response.getEntity();
    assertNotNull(employments);
    assertEquals("/0000-0000-0000-0003/employments", employments.getPath());
    assertNotNull(employments.getLastModifiedDate());
    assertNotNull(employments.getLastModifiedDate().getValue());
    assertEquals(1, employments.getSummaries().size());
    EmploymentSummary employment = employments.getSummaries().get(0);
    assertEquals(Long.valueOf(17), employment.getPutCode());
    assertNotNull(employment.getLastModifiedDate());
    assertNotNull(employment.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/employment/17", employment.getPath());
    assertEquals("PUBLIC Department", employment.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), employment.getVisibility().value());
    assertEquals("APP-5555555555555555", employment.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 20 with Employments

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

the class PublicAPISecurityManagerV2Test method filterEmploymentsTest.

@Test
public void filterEmploymentsTest() {
    Employments e = getEmployments(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertEquals(3, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getEmployments(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertEquals(2, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getEmployments(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertEquals(1, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getEmployments(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertTrue(e.getSummaries().isEmpty());
}
Also used : Employments(org.orcid.jaxb.model.record.summary_v2.Employments) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)27 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)20 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)14 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)8 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)8 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)8 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)8 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)8 Works (org.orcid.jaxb.model.record.summary_v2.Works)8 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)6 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)6 Response (javax.ws.rs.core.Response)5 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)5 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)5 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)5 InputStream (java.io.InputStream)4 JAXBContext (javax.xml.bind.JAXBContext)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 BaseTest (org.orcid.core.BaseTest)4