use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorImpl method viewEmployment.
@Override
public Response viewEmployment(String orcid, Long putCode) {
Employment e = affiliationsManagerReadOnly.getEmploymentAffiliation(orcid, putCode);
publicAPISecurityManagerV2.checkIsPublic(e);
ActivityUtils.setPathToActivity(e, orcid);
sourceUtilsReadOnly.setSourceName(e);
return Response.ok(e).build();
}
use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.
the class AffiliationsController method addAffiliation.
/**
* Adds a new affiliations
* @param affiliationForm
* */
private void addAffiliation(AffiliationForm affiliationForm) {
Affiliation affiliation = affiliationForm.toAffiliation();
if (AffiliationType.EDUCATION.value().equals(affiliationForm.getAffiliationType().getValue())) {
affiliation = affiliationsManager.createEducationAffiliation(getCurrentUserOrcid(), (Education) affiliation, false);
} else {
affiliation = affiliationsManager.createEmploymentAffiliation(getCurrentUserOrcid(), (Employment) affiliation, false);
}
affiliationForm.setPutCode(Text.valueOf(affiliation.getPutCode()));
}
use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EmploymentsTest method testUpdateEmployment.
@Test
public void testUpdateEmployment() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
assertEquals("Employment Dept # 1", employment.getDepartmentName());
assertEquals("Researcher", employment.getRoleTitle());
Utils.verifyLastModified(employment.getLastModifiedDate());
LastModifiedDate before = employment.getLastModifiedDate();
employment.setDepartmentName("Updated department name");
employment.setRoleTitle("The updated role title");
response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
assertNotNull(response);
employment = (Employment) response.getEntity();
assertNotNull(employment);
Utils.verifyLastModified(employment.getLastModifiedDate());
assertTrue(employment.getLastModifiedDate().after(before));
assertEquals("Updated department name", employment.getDepartmentName());
assertEquals("The updated role title", employment.getRoleTitle());
// Rollback changes
employment.setDepartmentName("Employment Dept # 1");
employment.setRoleTitle("Researcher");
response = serviceDelegator.updateEmployment("4444-4444-4444-4446", 5L, employment);
assertNotNull(response);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
}
use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewPrivateEmployment.
@Test
public void testViewPrivateEmployment() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewEmployment("4444-4444-4444-4446", 5L);
assertNotNull(response);
Employment employment = (Employment) response.getEntity();
assertNotNull(employment);
Utils.verifyLastModified(employment.getLastModifiedDate());
assertEquals(Long.valueOf(5L), employment.getPutCode());
assertEquals("/4444-4444-4444-4446/employment/5", employment.getPath());
assertEquals("Employment Dept # 1", employment.getDepartmentName());
assertEquals(Visibility.PRIVATE.value(), employment.getVisibility().value());
}
use of org.orcid.jaxb.model.record_rc1.Employment in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EmploymentsTest method testViewEmploymentReadPublic.
@Test
public void testViewEmploymentReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEmployment(ORCID, 17L);
Employment element = (Employment) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/employment/17", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Aggregations