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;
}
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);
}
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);
}
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);
}
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());
}
Aggregations