Search in sources :

Example 6 with Education

use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.

the class AffiliationForm method toAffiliation.

public Affiliation toAffiliation() {
    Affiliation affiliation = null;
    if (AffiliationType.EDUCATION.value().equals(affiliationType.getValue())) {
        affiliation = new Education();
    } else {
        affiliation = new Employment();
    }
    if (!PojoUtil.isEmpty(putCode)) {
        affiliation.setPutCode(Long.valueOf(putCode.getValue()));
    }
    if (visibility != null && visibility.getVisibility() != null) {
        affiliation.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(visibility.getVisibility().value()));
    }
    Organization organization = new Organization();
    affiliation.setOrganization(organization);
    organization.setName(affiliationName.getValue());
    OrganizationAddress organizationAddress = new OrganizationAddress();
    organization.setAddress(organizationAddress);
    organizationAddress.setCity(city.getValue());
    if (!PojoUtil.isEmpty(region)) {
        organizationAddress.setRegion(region.getValue());
    }
    if (!PojoUtil.isEmpty(disambiguatedAffiliationSourceId)) {
        organization.setDisambiguatedOrganization(new DisambiguatedOrganization());
        organization.getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(disambiguatedAffiliationSourceId.getValue());
        organization.getDisambiguatedOrganization().setDisambiguationSource(disambiguationSource.getValue());
    }
    organizationAddress.setCountry(Iso3166Country.fromValue(country.getValue()));
    if (!PojoUtil.isEmpty(roleTitle)) {
        affiliation.setRoleTitle(roleTitle.getValue());
    }
    if (!PojoUtil.isEmpty(departmentName)) {
        affiliation.setDepartmentName(departmentName.getValue());
    }
    if (!PojoUtil.isEmpty(startDate)) {
        affiliation.setStartDate(startDate.toFuzzyDate());
    }
    if (!PojoUtil.isEmpty(endDate)) {
        affiliation.setEndDate(endDate.toFuzzyDate());
    }
    return affiliation;
}
Also used : Organization(org.orcid.jaxb.model.common_v2.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) Affiliation(org.orcid.jaxb.model.record_v2.Affiliation)

Example 7 with Education

use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.

the class SourceInActivitiesTest method sourceDoesntChange_Affiliation_Test.

@Test
public void sourceDoesntChange_Affiliation_Test() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ProfileEntity(userOrcid)));
    Education education1 = getEducation(userOrcid);
    assertNotNull(education1);
    assertEquals(userOrcid, education1.retrieveSourcePath());
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Education education2 = getEducation(userOrcid);
    assertNotNull(education2);
    assertEquals(CLIENT_1_ID, education2.retrieveSourcePath());
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_2_ID)));
    Education education3 = getEducation(userOrcid);
    assertNotNull(education3);
    assertEquals(CLIENT_2_ID, education3.retrieveSourcePath());
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ProfileEntity(userOrcid)));
    Education education4 = getEducation(userOrcid);
    assertNotNull(education4);
    assertEquals(userOrcid, education4.retrieveSourcePath());
    Education fromDb1 = affiliationsManager.getEducationAffiliation(userOrcid, education1.getPutCode());
    assertNotNull(fromDb1);
    assertEquals(userOrcid, fromDb1.retrieveSourcePath());
    Education fromDb2 = affiliationsManager.getEducationAffiliation(userOrcid, education2.getPutCode());
    assertNotNull(fromDb2);
    assertEquals(CLIENT_1_ID, fromDb2.retrieveSourcePath());
    Education fromDb3 = affiliationsManager.getEducationAffiliation(userOrcid, education3.getPutCode());
    assertNotNull(fromDb3);
    assertEquals(CLIENT_2_ID, fromDb3.retrieveSourcePath());
    Education fromDb4 = affiliationsManager.getEducationAffiliation(userOrcid, education4.getPutCode());
    assertNotNull(fromDb4);
    assertEquals(userOrcid, fromDb4.retrieveSourcePath());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Education(org.orcid.jaxb.model.record_v2.Education) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Test(org.junit.Test)

Example 8 with Education

use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.

the class AccessTokenSecurityChecksTest method testTokenIssuedForOneUserFailForOtherUsers_20API.

@Test
public void testTokenIssuedForOneUserFailForOtherUsers_20API() throws JSONException, InterruptedException, URISyntaxException {
    String accessToken = getNonCachedAccessTokens(getUser2OrcidId(), getUser2Password(), getScopes(), getClient1ClientId(), getClient1ClientSecret(), getClient1RedirectUri());
    String orcid = getUser1OrcidId();
    Long putCode = 1L;
    Address address = (Address) unmarshallFromPath("/record_2.0/samples/read_samples/address-2.0.xml", Address.class);
    evaluateResponse(memberV2ApiClient.createAddress(orcid, address, accessToken));
    Education education = (Education) unmarshallFromPath("/record_2.0/samples/read_samples/education-2.0.xml", Education.class);
    evaluateResponse(memberV2ApiClient.createEducationJson(orcid, education, accessToken));
    evaluateResponse(memberV2ApiClient.createEducationXml(orcid, education, accessToken));
    Employment employment = (Employment) unmarshallFromPath("/record_2.0/samples/read_samples/employment-2.0.xml", Employment.class);
    evaluateResponse(memberV2ApiClient.createEmploymentJson(orcid, employment, accessToken));
    evaluateResponse(memberV2ApiClient.createEmploymentXml(orcid, employment, accessToken));
    PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) unmarshallFromPath("/record_2.0/samples/read_samples/external-identifier-2.0.xml", PersonExternalIdentifier.class);
    evaluateResponse(memberV2ApiClient.createExternalIdentifier(orcid, externalIdentifier, accessToken));
    Funding funding = (Funding) unmarshallFromPath("/record_2.0/samples/read_samples/funding-2.0.xml", Funding.class);
    evaluateResponse(memberV2ApiClient.createFundingJson(orcid, funding, accessToken));
    evaluateResponse(memberV2ApiClient.createFundingXml(orcid, funding, accessToken));
    Keyword keyword = (Keyword) unmarshallFromPath("/record_2.0/samples/read_samples/keyword-2.0.xml", Keyword.class);
    evaluateResponse(memberV2ApiClient.createKeyword(orcid, keyword, accessToken));
    OtherName otherName = (OtherName) unmarshallFromPath("/record_2.0/samples/read_samples/other-name-2.0.xml", OtherName.class);
    evaluateResponse(memberV2ApiClient.createOtherName(orcid, otherName, accessToken));
    PeerReview peerReview = (PeerReview) unmarshallFromPath("/record_2.0/samples/read_samples/peer-review-2.0.xml", PeerReview.class);
    evaluateResponse(memberV2ApiClient.createPeerReviewJson(orcid, peerReview, accessToken));
    evaluateResponse(memberV2ApiClient.createPeerReviewXml(orcid, peerReview, accessToken));
    ResearcherUrl rUrl = (ResearcherUrl) unmarshallFromPath("/record_2.0/samples/read_samples/researcher-url-2.0.xml", ResearcherUrl.class);
    evaluateResponse(memberV2ApiClient.createResearcherUrls(orcid, rUrl, accessToken));
    Work work = (Work) unmarshallFromPath("/record_2.0/samples/read_samples/work-2.0.xml", Work.class);
    evaluateResponse(memberV2ApiClient.createWorkJson(orcid, work, accessToken));
    evaluateResponse(memberV2ApiClient.createWorkXml(orcid, work, accessToken));
    evaluateResponse(memberV2ApiClient.deleteAddress(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteEducationXml(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteEmploymentXml(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteExternalIdentifier(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteFundingXml(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteKeyword(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteOtherName(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deletePeerReviewXml(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteResearcherUrl(orcid, putCode, accessToken));
    evaluateResponse(memberV2ApiClient.deleteWorkXml(orcid, putCode, accessToken));
    address.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateAddress(orcid, address, accessToken));
    education.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateEducation(orcid, education, accessToken));
    employment.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateEmployment(orcid, employment, accessToken));
    externalIdentifier.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateExternalIdentifier(orcid, externalIdentifier, accessToken));
    funding.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateFunding(orcid, funding, accessToken));
    keyword.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateKeyword(orcid, keyword, accessToken));
    otherName.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateOtherName(orcid, otherName, accessToken));
    peerReview.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updatePeerReview(orcid, peerReview, accessToken));
    rUrl.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateResearcherUrls(orcid, rUrl, accessToken));
    work.setPutCode(putCode);
    evaluateResponse(memberV2ApiClient.updateWork(orcid, work, accessToken));
    evaluateResponse(memberV2ApiClient.getResearcherUrls(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewAddresses(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewExternalIdentifiers(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewKeywords(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewOtherNames(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewBiography(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewPersonalDetailsXML(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewActivities(orcid, accessToken));
    evaluateResponse(memberV2ApiClient.viewPerson(orcid, accessToken));
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Funding(org.orcid.jaxb.model.record_v2.Funding) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Work(org.orcid.jaxb.model.record_v2.Work) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Test(org.junit.Test)

Example 9 with Education

use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.

the class BlackBoxBaseRC4 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;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) Education(org.orcid.jaxb.model.record_rc4.Education) Funding(org.orcid.jaxb.model.record_rc4.Funding) Work(org.orcid.jaxb.model.record_rc4.Work) OtherName(org.orcid.jaxb.model.record_rc4.OtherName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl) IOException(java.io.IOException)

Example 10 with Education

use of org.orcid.jaxb.model.record_rc1.Education in project ORCID-Source by ORCID.

the class MemberV2Test method testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource.

@Test
public void testUpdateEducationWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
    Education education = (Education) unmarshallFromPath("/record_2.0_rc4/samples/education-2.0_rc4.xml", Education.class);
    education.setPutCode(null);
    education.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.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(".*/v2.0_rc4/" + this.getUser1OrcidId() + "/education/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Education gotEducation = getResponse.getEntity(Education.class);
    assertEquals("education:department-name", gotEducation.getDepartmentName());
    assertEquals("education: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 = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotEducation);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Education gotAfterUpdateEducation = getAfterUpdateResponse.getEntity(Education.class);
    assertEquals("education:department-name", gotAfterUpdateEducation.getDepartmentName());
    assertEquals("education:role-title", gotAfterUpdateEducation.getRoleTitle());
    ClientResponse deleteResponse = memberV2ApiClient.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.record_rc4.Education) Test(org.junit.Test)

Aggregations

Education (org.orcid.jaxb.model.record_v2.Education)45 Test (org.junit.Test)41 ClientResponse (com.sun.jersey.api.client.ClientResponse)22 Response (javax.ws.rs.core.Response)13 DBUnitTest (org.orcid.test.DBUnitTest)13 Funding (org.orcid.jaxb.model.record_v2.Funding)8 Work (org.orcid.jaxb.model.record_v2.Work)8 IOException (java.io.IOException)7 InputStreamReader (java.io.InputStreamReader)7 Reader (java.io.Reader)7 Education (org.orcid.jaxb.model.record_rc1.Education)7 ArrayList (java.util.ArrayList)6 Employment (org.orcid.jaxb.model.record_v2.Employment)6 OtherName (org.orcid.jaxb.model.record_v2.OtherName)5 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)5 OrcidError (org.orcid.jaxb.model.error_rc1.OrcidError)4 Education (org.orcid.jaxb.model.record_rc2.Education)4 Education (org.orcid.jaxb.model.record_rc3.Education)4 Education (org.orcid.jaxb.model.record_rc4.Education)4 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)4