Search in sources :

Example 26 with Education

use of org.orcid.jaxb.model.v3.dev1.record.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 Distinction) {
        form.setAffiliationType(Text.valueOf(AffiliationType.DISTINCTION.value()));
    } else if (affiliation instanceof Education) {
        form.setAffiliationType(Text.valueOf(AffiliationType.EDUCATION.value()));
    } else if (affiliation instanceof Employment) {
        form.setAffiliationType(Text.valueOf(AffiliationType.EMPLOYMENT.value()));
    } else if (affiliation instanceof InvitedPosition) {
        form.setAffiliationType(Text.valueOf(AffiliationType.INVITED_POSITION.value()));
    } else if (affiliation instanceof Membership) {
        form.setAffiliationType(Text.valueOf(AffiliationType.MEMBERSHIP.value()));
    } else if (affiliation instanceof Qualification) {
        form.setAffiliationType(Text.valueOf(AffiliationType.QUALIFICATION.value()));
    } else if (affiliation instanceof Service) {
        form.setAffiliationType(Text.valueOf(AffiliationType.SERVICE.value()));
    }
    form.setPutCode(Text.valueOf(affiliation.getPutCode()));
    form.setVisibility(Visibility.valueOf(affiliation.getVisibility()));
    Organization organization = affiliation.getOrganization();
    form.setDateSortString(PojoUtil.createDateSortString(affiliation));
    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());
        }
    }
    if (affiliation.getUrl() != null) {
        form.setUrl(Text.valueOf(affiliation.getUrl().getValue()));
    } else {
        form.setUrl(new Text());
    }
    if (affiliation.getExternalIDs() != null) {
        List<AffiliationExternalIdentifier> affiliationExternalIdentifiers = new ArrayList<>();
        for (ExternalID externalID : affiliation.getExternalIDs().getExternalIdentifier()) {
            affiliationExternalIdentifiers.add(AffiliationExternalIdentifier.valueOf(externalID));
        }
        form.setAffiliationExternalIdentifiers(affiliationExternalIdentifiers);
    }
    form.setCreatedDate(Date.valueOf(affiliation.getCreatedDate()));
    form.setLastModified(Date.valueOf(affiliation.getLastModifiedDate()));
    return form;
}
Also used : Organization(org.orcid.jaxb.model.v3.dev1.common.Organization) DisambiguatedOrganization(org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) OrganizationAddress(org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Source(org.orcid.jaxb.model.v3.dev1.common.Source) 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) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Example 27 with Education

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

the class ActivityValidatorTest method validateEducationWithoutDisambiguatedOrgId.

@Test(expected = InvalidDisambiguatedOrgException.class)
public void validateEducationWithoutDisambiguatedOrgId() {
    Education e = getEducation();
    e.getOrganization().getDisambiguatedOrganization().setDisambiguatedOrganizationIdentifier(null);
    activityValidator.validateAffiliation(e, null, false, true, Visibility.PUBLIC);
}
Also used : Education(org.orcid.jaxb.model.v3.dev1.record.Education) Test(org.junit.Test)

Example 28 with Education

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

the class ActivityValidatorTest method validateEducationWithoutOrg.

@Test(expected = InvalidOrgException.class)
public void validateEducationWithoutOrg() {
    Education e = getEducation();
    e.setOrganization(null);
    activityValidator.validateAffiliation(e, null, false, true, Visibility.PUBLIC);
}
Also used : Education(org.orcid.jaxb.model.v3.dev1.record.Education) Test(org.junit.Test)

Example 29 with Education

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

the class ActivityValidatorTest method validateEducationWithoutDisambiguatedOrg.

@Test(expected = InvalidDisambiguatedOrgException.class)
public void validateEducationWithoutDisambiguatedOrg() {
    Education e = getEducation();
    e.getOrganization().setDisambiguatedOrganization(null);
    activityValidator.validateAffiliation(e, null, false, true, Visibility.PUBLIC);
}
Also used : Education(org.orcid.jaxb.model.v3.dev1.record.Education) Test(org.junit.Test)

Example 30 with Education

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

the class AffiliationsManagerTest method testAddEducationToUnclaimedRecordPreserveEducationVisibility.

@Test
public void testAddEducationToUnclaimedRecordPreserveEducationVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Education element = getEducation();
    element = affiliationsManager.createEducationAffiliation(unclaimedOrcid, element, true);
    element = affiliationsManager.getEducationAffiliation(unclaimedOrcid, element.getPutCode());
    assertNotNull(element);
    assertEquals(Visibility.PUBLIC, element.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Education(org.orcid.jaxb.model.v3.dev1.record.Education) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

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