Search in sources :

Example 6 with Employment

use of org.orcid.jaxb.model.record_v2.Employment in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewEmployment.

@Override
public Response viewEmployment(String orcid, Long putCode) {
    Employment e = affiliationsManagerReadOnly.getEmploymentAffiliation(orcid, putCode);
    publicAPISecurityManagerV2.checkIsPublic(e);
    ActivityUtils.setPathToActivity(e, orcid);
    sourceUtilsReadOnly.setSourceName(e);
    return Response.ok(e).build();
}
Also used : Employment(org.orcid.jaxb.model.record_v2.Employment)

Example 7 with Employment

use of org.orcid.jaxb.model.record_v2.Employment in project ORCID-Source by ORCID.

the class AffiliationsController method addAffiliation.

/**
     * Adds a new affiliations
     * @param affiliationForm
     * */
private void addAffiliation(AffiliationForm affiliationForm) {
    Affiliation affiliation = affiliationForm.toAffiliation();
    if (AffiliationType.EDUCATION.value().equals(affiliationForm.getAffiliationType().getValue())) {
        affiliation = affiliationsManager.createEducationAffiliation(getCurrentUserOrcid(), (Education) affiliation, false);
    } else {
        affiliation = affiliationsManager.createEmploymentAffiliation(getCurrentUserOrcid(), (Employment) affiliation, false);
    }
    affiliationForm.setPutCode(Text.valueOf(affiliation.getPutCode()));
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Affiliation(org.orcid.jaxb.model.record_v2.Affiliation)

Example 8 with Employment

use of org.orcid.jaxb.model.record_v2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmployment.

@Test
public void testUpdateEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    assertEquals("Employment Dept # 1", employment.getDepartmentName());
    assertEquals("Researcher", employment.getRoleTitle());
    Utils.verifyLastModified(employment.getLastModifiedDate());
    LastModifiedDate before = employment.getLastModifiedDate();
    employment.setDepartmentName("Updated department name");
    employment.setRoleTitle("The updated role title");
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertTrue(employment.getLastModifiedDate().after(before));
    assertEquals("Updated department name", employment.getDepartmentName());
    assertEquals("The updated role title", employment.getRoleTitle());
    // Rollback changes
    employment.setDepartmentName("Employment Dept # 1");
    employment.setRoleTitle("Researcher");
    response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 9 with Employment

use of org.orcid.jaxb.model.record_v2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewPrivateEmployment.

@Test
public void testViewPrivateEmployment() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    Utils.verifyLastModified(employment.getLastModifiedDate());
    assertEquals(Long.valueOf(5L), employment.getPutCode());
    assertEquals("/4444-4444-4444-4446/employment/5", employment.getPath());
    assertEquals("Employment Dept # 1", employment.getDepartmentName());
    assertEquals(Visibility.PRIVATE.value(), employment.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with Employment

use of org.orcid.jaxb.model.record_v2.Employment in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewEmploymentReadPublic.

@Test
public void testViewEmploymentReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEmployment(ORCID, 17L);
    Employment element = (Employment) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/employment/17", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) Employment(org.orcid.jaxb.model.record_v2.Employment) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)43 Employment (org.orcid.jaxb.model.record_v2.Employment)38 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)14 DBUnitTest (org.orcid.test.DBUnitTest)14 Education (org.orcid.jaxb.model.record_v2.Education)10 OtherName (org.orcid.jaxb.model.record_v2.OtherName)9 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)9 Employment (org.orcid.jaxb.model.record_rc1.Employment)8 Funding (org.orcid.jaxb.model.record_v2.Funding)8 Work (org.orcid.jaxb.model.record_v2.Work)8 ArrayList (java.util.ArrayList)6 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)6 Address (org.orcid.jaxb.model.record_v2.Address)6 Keyword (org.orcid.jaxb.model.record_v2.Keyword)6 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)6 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)5 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)5 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)5 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)5