Search in sources :

Example 16 with EmploymentSummary

use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_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.record.summary_v2.Employments) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 17 with EmploymentSummary

use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testAddEmployment.

@Test
public void testAddEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4447");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    assertNotNull(summary.getEmployments());
    assertNotNull(summary.getEmployments().getSummaries());
    assertNotNull(summary.getEmployments().getSummaries().get(0));
    assertEquals(Long.valueOf(13), summary.getEmployments().getSummaries().get(0).getPutCode());
    response = serviceDelegator.createEmployment("4444-4444-4444-4447", Utils.getEmployment());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities("4444-4444-4444-4447");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    assertNotNull(summary.getEmployments());
    Utils.verifyLastModified(summary.getEmployments().getLastModifiedDate());
    assertNotNull(summary.getEmployments().getSummaries());
    boolean haveOld = false;
    boolean haveNew = false;
    for (EmploymentSummary eSummary : summary.getEmployments().getSummaries()) {
        assertNotNull(eSummary.getPutCode());
        Utils.verifyLastModified(eSummary.getLastModifiedDate());
        if (eSummary.getPutCode() == 13L) {
            assertEquals("Employment Dept # 1", eSummary.getDepartmentName());
            haveOld = true;
        } else {
            assertEquals(putCode, eSummary.getPutCode());
            assertEquals("My department name", eSummary.getDepartmentName());
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
}
Also used : Response(javax.ws.rs.core.Response) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 18 with EmploymentSummary

use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.

the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.

public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
    long lastModifiedTime = getLastModified(orcid);
    ActivitiesSummary activities = new ActivitiesSummary();
    // Set educations
    List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid, lastModifiedTime);
    Educations educations = new Educations();
    for (EducationSummary summary : educationsList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                educations.getSummaries().add(summary);
            }
        } else {
            educations.getSummaries().add(summary);
        }
    }
    activities.setEducations(educations);
    // Set employments
    List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid, lastModifiedTime);
    Employments employments = new Employments();
    for (EmploymentSummary summary : employmentList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                employments.getSummaries().add(summary);
            }
        } else {
            employments.getSummaries().add(summary);
        }
    }
    activities.setEmployments(employments);
    // Set fundings
    List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid, lastModifiedTime);
    Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
    activities.setFundings(fundings);
    // Set peer reviews
    List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid, lastModifiedTime);
    PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
    activities.setPeerReviews(peerReviews);
    // Set works
    List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid, lastModifiedTime);
    Works works = workManager.groupWorks(workSummaries, justPublic);
    activities.setWorks(works);
    return activities;
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) 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 19 with EmploymentSummary

use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.

the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AllReadLimited_And_NotSource.

@Test
public void testActivitiesSummary_When_AllReadLimited_And_NotSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.AFFILIATIONS_READ_LIMITED, ScopePathType.FUNDING_READ_LIMITED, ScopePathType.PEER_REVIEW_READ_LIMITED, ScopePathType.ORCID_WORKS_READ_LIMITED);
    EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
    EducationSummary e2 = createEducationSummary(Visibility.LIMITED, CLIENT_2);
    EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
    EmploymentSummary em2 = createEmploymentSummary(Visibility.LIMITED, CLIENT_2);
    EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
    FundingSummary f2 = createFundingSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
    FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
    PeerReviewSummary p2 = createPeerReviewSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
    PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
    WorkSummary w2 = createWorkSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
    WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setEducations(createEducations(e1, e2, e3));
    as.setEmployments(createEmployments(em1, em2, em3));
    as.setFundings(createFundings(f1, f2, f3));
    as.setPeerReviews(createPeerReviews(p1, p2, p3));
    as.setWorks(createWorks(w1, w2, w3));
    orcidSecurityManager.checkAndFilter(ORCID_1, as);
    // Check it have limited Educations
    assertNotNull(as.getEducations());
    assertEquals(2, as.getEducations().getSummaries().size());
    assertTrue(as.getEducations().getSummaries().contains(e1));
    assertTrue(as.getEducations().getSummaries().contains(e2));
    assertFalse(as.getEducations().getSummaries().contains(e3));
    // Check it have limited Employments
    assertNotNull(as.getEmployments());
    assertEquals(2, as.getEmployments().getSummaries().size());
    assertTrue(as.getEmployments().getSummaries().contains(em1));
    assertTrue(as.getEmployments().getSummaries().contains(em2));
    assertFalse(as.getEmployments().getSummaries().contains(em3));
    // Check it have limited funding
    assertNotNull(as.getFundings());
    assertEquals(1, as.getFundings().getFundingGroup().size());
    assertEquals(2, as.getFundings().getFundingGroup().get(0).getActivities().size());
    assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
    assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
    assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
    assertEquals(3, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
    assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
    assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
    assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
    // Check it have limited reviews
    assertNotNull(as.getPeerReviews());
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(2, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
    assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
    assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
    assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
    // Check it have limited works
    assertNotNull(as.getWorks());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertEquals(2, as.getWorks().getWorkGroup().get(0).getActivities().size());
    assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
    assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
    assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
    assertEquals(3, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
    assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
    assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
    assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
Also used : 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) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Example 20 with EmploymentSummary

use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.

the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AllPrivate_NoSource_ReadPublicToken.

@Test
public void testActivitiesSummary_When_AllPrivate_NoSource_ReadPublicToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    EducationSummary e1 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EducationSummary e2 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em1 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em2 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    FundingSummary f1 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
    FundingSummary f2 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
    PeerReviewSummary p2 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    WorkSummary w1 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
    WorkSummary w2 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setEducations(createEducations(e1, e2, e3));
    as.setEmployments(createEmployments(em1, em2, em3));
    as.setFundings(createFundings(f1, f2, f3));
    as.setPeerReviews(createPeerReviews(p1, p2, p3));
    as.setWorks(createWorks(w1, w2, w3));
    orcidSecurityManager.checkAndFilter(ORCID_1, as);
    assertNotNull(as);
    // Check educations
    assertEquals(0, as.getEducations().getSummaries().size());
    // Check employments
    assertEquals(0, as.getEmployments().getSummaries().size());
    // Check fundings
    assertEquals(0, as.getFundings().getFundingGroup().size());
    // Check peer reviews
    assertEquals(0, as.getPeerReviews().getPeerReviewGroup().size());
    // Check works
    assertEquals(0, as.getWorks().getWorkGroup().size());
}
Also used : 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) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)60 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)60 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)47 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)46 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)45 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)43 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)40 ClientResponse (com.sun.jersey.api.client.ClientResponse)20 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)19 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 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 Emails (org.orcid.jaxb.model.record_v2.Emails)15 Keywords (org.orcid.jaxb.model.record_v2.Keywords)15