Search in sources :

Example 6 with Employment

use of org.orcid.jaxb.model.record_rc3.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_rc3.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_rc3.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_rc3.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_rc3.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)41 Employment (org.orcid.jaxb.model.record_v2.Employment)38 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)13 DBUnitTest (org.orcid.test.DBUnitTest)13 Employment (org.orcid.jaxb.model.record_rc1.Employment)8 ArrayList (java.util.ArrayList)6 Education (org.orcid.jaxb.model.record_v2.Education)6 Funding (org.orcid.jaxb.model.record_v2.Funding)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4 Work (org.orcid.jaxb.model.record_v2.Work)4 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)3 Address (org.orcid.jaxb.model.record_v2.Address)3 Keyword (org.orcid.jaxb.model.record_v2.Keyword)3 OtherName (org.orcid.jaxb.model.record_v2.OtherName)3 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)3 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)3 IOException (java.io.IOException)2 InputStreamReader (java.io.InputStreamReader)2 Reader (java.io.Reader)2