Search in sources :

Example 1 with Education

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

the class MemberV2ApiServiceDelegatorImpl method updateEducation.

@Override
public Response updateEducation(String orcid, Long putCode, Education education) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_UPDATE);
    if (!putCode.equals(education.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(education.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(education);
    Education e = affiliationsManager.updateEducationAffiliation(orcid, education, true);
    sourceUtils.setSourceName(e);
    return Response.ok(e).build();
}
Also used : HashMap(java.util.HashMap) Education(org.orcid.jaxb.model.record_v2.Education) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 2 with Education

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

the class MemberV2ApiServiceDelegatorImpl method viewEducation.

@Override
public Response viewEducation(String orcid, Long putCode) {
    Education e = affiliationsManagerReadOnly.getEducationAffiliation(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, e, ScopePathType.AFFILIATIONS_READ_LIMITED);
    ActivityUtils.setPathToActivity(e, orcid);
    sourceUtils.setSourceName(e);
    return Response.ok(e).build();
}
Also used : Education(org.orcid.jaxb.model.record_v2.Education)

Example 3 with Education

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

the class AffiliationForm method valueOf.

public static AffiliationForm valueOf(Affiliation affiliation) {
    AffiliationForm form = new AffiliationForm();
    if (affiliation instanceof Education) {
        form.setAffiliationType(Text.valueOf(AffiliationType.EDUCATION.value()));
    } else {
        form.setAffiliationType(Text.valueOf(AffiliationType.EMPLOYMENT.value()));
    }
    form.setPutCode(Text.valueOf(affiliation.getPutCode()));
    form.setVisibility(Visibility.valueOf(affiliation.getVisibility()));
    Organization organization = affiliation.getOrganization();
    form.setDateSortString(PojoUtil.createDateSortString(affiliation.getStartDate(), affiliation.getEndDate()));
    form.setAffiliationName(Text.valueOf(organization.getName()));
    OrganizationAddress address = organization.getAddress();
    form.setCity(Text.valueOf(address.getCity()));
    if (organization.getDisambiguatedOrganization() != null) {
        if (organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier() != null) {
            form.setDisambiguatedAffiliationSourceId(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier()));
            form.setDisambiguationSource(Text.valueOf(organization.getDisambiguatedOrganization().getDisambiguationSource()));
            form.setOrgDisambiguatedId(Text.valueOf(String.valueOf(organization.getDisambiguatedOrganization().getId())));
        }
    }
    if (address.getRegion() != null) {
        form.setRegion(Text.valueOf(address.getRegion()));
    } else {
        form.setRegion(new Text());
    }
    if (address.getCountry() != null) {
        form.setCountry(Text.valueOf(address.getCountry().value()));
    } else {
        form.setCountry(new Text());
    }
    if (affiliation.getDepartmentName() != null) {
        form.setDepartmentName(Text.valueOf(affiliation.getDepartmentName()));
    } else {
        form.setDepartmentName(new Text());
    }
    if (affiliation.getRoleTitle() != null) {
        form.setRoleTitle(Text.valueOf(affiliation.getRoleTitle()));
    } else {
        form.setRoleTitle(new Text());
    }
    if (affiliation.getStartDate() != null) {
        form.setStartDate(Date.valueOf(affiliation.getStartDate()));
    }
    if (affiliation.getEndDate() != null) {
        form.setEndDate(Date.valueOf(affiliation.getEndDate()));
    }
    Source source = affiliation.getSource();
    if (source != null) {
        form.setSource(source.retrieveSourcePath());
        if (source.getSourceName() != null) {
            form.setSourceName(source.getSourceName().getContent());
        }
    }
    form.setCreatedDate(Date.valueOf(affiliation.getCreatedDate()));
    form.setLastModified(Date.valueOf(affiliation.getLastModifiedDate()));
    return form;
}
Also used : Organization(org.orcid.jaxb.model.common_v2.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.common_v2.DisambiguatedOrganization) Education(org.orcid.jaxb.model.record_v2.Education) OrganizationAddress(org.orcid.jaxb.model.common_v2.OrganizationAddress) Source(org.orcid.jaxb.model.common_v2.Source)

Example 4 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 5 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)

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