Search in sources :

Example 1 with Education

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

the class MemberV3ApiServiceDelegatorImpl method createEducation.

@Override
public Response createEducation(String orcid, Education education) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_CREATE, ScopePathType.AFFILIATIONS_UPDATE);
    clearSource(education);
    Education e = affiliationsManager.createEducationAffiliation(orcid, education, true);
    sourceUtils.setSourceName(e);
    try {
        return Response.created(new URI(String.valueOf(e.getPutCode()))).build();
    } catch (URISyntaxException ex) {
        throw new RuntimeException(localeManager.resolveMessage("apiError.createeducation_response.exception"), ex);
    }
}
Also used : Education(org.orcid.jaxb.model.v3.dev1.record.Education) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with Education

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

the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducationChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateEducationChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals(Visibility.PUBLIC, education.getVisibility());
    education.setVisibility(Visibility.PRIVATE);
    response = serviceDelegator.updateEducation(ORCID, 20L, education);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.v3.dev1.record.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with Education

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

the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducationLeavingVisibilityNullTest.

@Test
public void testUpdateEducationLeavingVisibilityNullTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals(Visibility.PUBLIC, education.getVisibility());
    education.setVisibility(null);
    response = serviceDelegator.updateEducation(ORCID, 20L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals(Visibility.PUBLIC, education.getVisibility());
}
Also used : Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.v3.dev1.record.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with Education

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

the class MemberV3ApiServiceDelegator_EducationsTest method testViewEducationSummaryReadPublic.

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

Example 5 with Education

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

the class MemberV3ApiServiceDelegator_EducationsTest method testUpdateEducation.

@Test
public void testUpdateEducation() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    assertEquals("PUBLIC Department", education.getDepartmentName());
    assertEquals("PUBLIC", education.getRoleTitle());
    Utils.verifyLastModified(education.getLastModifiedDate());
    LastModifiedDate before = education.getLastModifiedDate();
    education.setDepartmentName("Updated department name");
    education.setRoleTitle("The updated role title");
    // disambiguated org is required in API v3
    DisambiguatedOrganization disambiguatedOrg = new DisambiguatedOrganization();
    disambiguatedOrg.setDisambiguatedOrganizationIdentifier("abc456");
    disambiguatedOrg.setDisambiguationSource("WDB");
    education.getOrganization().setDisambiguatedOrganization(disambiguatedOrg);
    response = serviceDelegator.updateEducation(ORCID, 20L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    education = (Education) response.getEntity();
    assertNotNull(education);
    Utils.verifyLastModified(education.getLastModifiedDate());
    assertTrue(education.getLastModifiedDate().after(before));
    assertEquals("Updated department name", education.getDepartmentName());
    assertEquals("The updated role title", education.getRoleTitle());
    // Rollback changes
    education.setDepartmentName("PUBLIC Department");
    education.setRoleTitle("PUBLIC");
    response = serviceDelegator.updateEducation(ORCID, 20L, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) Education(org.orcid.jaxb.model.v3.dev1.record.Education) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Education (org.orcid.jaxb.model.v3.dev1.record.Education)54 Test (org.junit.Test)46 DBUnitTest (org.orcid.test.DBUnitTest)23 Response (javax.ws.rs.core.Response)22 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)12 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)9 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)8 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)8 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)7 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)6 Work (org.orcid.jaxb.model.v3.dev1.record.Work)6 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)6 Address (org.orcid.jaxb.model.v3.dev1.record.Address)5 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)5 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)5