use of org.orcid.jaxb.model.record_rc2.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();
}
use of org.orcid.jaxb.model.record_rc2.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();
}
use of org.orcid.jaxb.model.record_rc2.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;
}
use of org.orcid.jaxb.model.record_rc2.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;
}
use of org.orcid.jaxb.model.record_rc2.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());
}
Aggregations