Search in sources :

Example 16 with Education

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

the class PublicV3ApiServiceDelegatorTest method testGetPublicEducationUsingToken.

// Education
@Test
public void testGetPublicEducationUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(r);
    Education e = (Education) r.getEntity();
    assertNotNull(e);
    assertNotNull(e.getLastModifiedDate());
    assertNotNull(e.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(20), e.getPutCode());
}
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 17 with Education

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

the class PublicV3ApiServiceDelegatorTest method testViewEducations.

@Test
public void testViewEducations() {
    Response response = serviceDelegator.viewEducations(ORCID);
    assertNotNull(response);
    Educations educations = (Educations) response.getEntity();
    assertNotNull(educations);
    assertEquals("/0000-0000-0000-0003/educations", educations.getPath());
    assertNotNull(educations.getLastModifiedDate());
    assertNotNull(educations.getLastModifiedDate().getValue());
    assertEquals(1, educations.getSummaries().size());
    EducationSummary education = educations.getSummaries().get(0);
    assertEquals(Long.valueOf(20), education.getPutCode());
    assertNotNull(education.getLastModifiedDate());
    assertNotNull(education.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
    assertEquals("PUBLIC Department", education.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
    assertEquals("APP-5555555555555555", education.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) Educations(org.orcid.jaxb.model.v3.dev1.record.summary.Educations) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 18 with Education

use of org.orcid.jaxb.model.v3.dev1.record.Education 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 (affiliation instanceof Distinction) {
        affiliation = affiliationsManager.createDistinctionAffiliation(getCurrentUserOrcid(), (Distinction) affiliation, false);
    } else if (affiliation instanceof Education) {
        affiliation = affiliationsManager.createEducationAffiliation(getCurrentUserOrcid(), (Education) affiliation, false);
    } else if (affiliation instanceof Employment) {
        affiliation = affiliationsManager.createEmploymentAffiliation(getCurrentUserOrcid(), (Employment) affiliation, false);
    } else if (affiliation instanceof InvitedPosition) {
        affiliation = affiliationsManager.createInvitedPositionAffiliation(getCurrentUserOrcid(), (InvitedPosition) affiliation, false);
    } else if (affiliation instanceof Membership) {
        affiliation = affiliationsManager.createMembershipAffiliation(getCurrentUserOrcid(), (Membership) affiliation, false);
    } else if (affiliation instanceof Qualification) {
        affiliation = affiliationsManager.createQualificationAffiliation(getCurrentUserOrcid(), (Qualification) affiliation, false);
    } else if (affiliation instanceof Service) {
        affiliation = affiliationsManager.createServiceAffiliation(getCurrentUserOrcid(), (Service) affiliation, false);
    } else {
        throw new IllegalArgumentException("Invalid affiliation type: " + affiliation.getClass().getName());
    }
    affiliationForm.setPutCode(Text.valueOf(affiliation.getPutCode()));
}
Also used : Qualification(org.orcid.jaxb.model.v3.dev1.record.Qualification) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Employment(org.orcid.jaxb.model.v3.dev1.record.Employment) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Affiliation(org.orcid.jaxb.model.v3.dev1.record.Affiliation)

Example 19 with Education

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

the class BlackBoxBaseV3_0_dev1 method unmarshallFromPath.

public Object unmarshallFromPath(String path, Class<?> type) {
    try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
        Object obj = unmarshall(reader, type);
        Object result = null;
        if (Address.class.equals(type)) {
            result = (Address) obj;
        } else if (Education.class.equals(type)) {
            result = (Education) obj;
        } else if (Employment.class.equals(type)) {
            result = (Employment) obj;
        } else if (Funding.class.equals(type)) {
            result = (Funding) obj;
        } else if (Keyword.class.equals(type)) {
            result = (Keyword) obj;
        } else if (Work.class.equals(type)) {
            result = (Work) obj;
        } else if (PeerReview.class.equals(type)) {
            result = (PeerReview) obj;
        } else if (ResearcherUrl.class.equals(type)) {
            result = (ResearcherUrl) obj;
        } else if (PersonalDetails.class.equals(type)) {
            result = (PersonalDetails) obj;
        } else if (OtherName.class.equals(type)) {
            result = (OtherName) obj;
        } else if (PersonExternalIdentifier.class.equals(type)) {
            result = (PersonExternalIdentifier) obj;
        } else if (Distinction.class.equals(type)) {
            result = (Distinction) obj;
        } else if (InvitedPosition.class.equals(type)) {
            result = (InvitedPosition) obj;
        } else if (Membership.class.equals(type)) {
            result = (Membership) obj;
        } else if (Qualification.class.equals(type)) {
            result = (Qualification) obj;
        } else if (Service.class.equals(type)) {
            result = (Service) obj;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) Service(org.orcid.jaxb.model.v3.dev1.record.Service) T2OAuthAPIService(org.orcid.integration.blackbox.api.v12.T2OAuthAPIService) IOException(java.io.IOException) Education(org.orcid.jaxb.model.v3.dev1.record.Education) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Example 20 with Education

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

the class MemberV3Dev1Test method testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource.

@Test
public void testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
    Education education = (Education) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/education-3.0_dev1.xml", Education.class);
    education.setPutCode(null);
    education.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV3Dev1ApiClientImpl.createEducationXml(this.getUser1OrcidId(), education, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String locationPath = postResponse.getLocation().getPath();
    assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v3.0_dev1/" + this.getUser1OrcidId() + "/education/\\d+"));
    ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Education gotEducation = getResponse.getEntity(Education.class);
    assertEquals("department-name", gotEducation.getDepartmentName());
    assertEquals("role-title", gotEducation.getRoleTitle());
    gotEducation.setDepartmentName("updated dept. name");
    gotEducation.setRoleTitle("updated role title");
    String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
    ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEducation);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Education gotAfterUpdateEducation = getAfterUpdateResponse.getEntity(Education.class);
    assertEquals("department-name", gotAfterUpdateEducation.getDepartmentName());
    assertEquals("role-title", gotAfterUpdateEducation.getRoleTitle());
    ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteEducationXml(this.getUser1OrcidId(), gotEducation.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Education(org.orcid.jaxb.model.v3.dev1.record.Education) 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