use of org.orcid.jaxb.model.v3.dev1.record.summary.Employments in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewEmployments.
@Override
public Response viewEmployments(String orcid) {
List<EmploymentSummary> employmentsList = affiliationsManagerReadOnly.getEmploymentSummaryList(orcid);
// Lets copy the list so we don't modify the cached collection
List<EmploymentSummary> filteredList = null;
if (employmentsList != null) {
filteredList = new ArrayList<EmploymentSummary>(employmentsList);
}
employmentsList = filteredList;
orcidSecurityManager.checkAndFilter(orcid, employmentsList, ScopePathType.AFFILIATIONS_READ_LIMITED);
Employments employments = new Employments(employmentsList);
ActivityUtils.setPathToAffiliations(employments, orcid);
sourceUtils.setSourceName(employments);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(employments);
return Response.ok(employments).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Employments in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_PeerReviewReadLimited_NoSource.
@Test
public void testViewActitivies_PeerReviewReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.PEER_REVIEW_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Only public educations
assertNotNull(as.getEducations());
assertEquals(1, as.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
// Only public employments
assertNotNull(as.getEmployments());
assertEquals(1, as.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
// Only public funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
// Limited peer reviews
boolean found1 = false, found2 = false, found3 = false;
assertNotNull(as.getPeerReviews());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
assertEquals(1, group.getPeerReviewSummary().size());
PeerReviewSummary element = group.getPeerReviewSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(9))) {
assertEquals(Visibility.PUBLIC, element.getVisibility());
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(10))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Employments in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_FundingReadLimited_NoSource.
@Test
public void testViewActitivies_FundingReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.FUNDING_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Only public educations
assertNotNull(as.getEducations());
assertEquals(1, as.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
// Only public employments
assertNotNull(as.getEmployments());
assertEquals(1, as.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
// Limited funding
boolean found1 = false, found2 = false, found3 = false;
assertNotNull(as.getFundings());
assertEquals(3, as.getFundings().getFundingGroup().size());
for (FundingGroup group : as.getFundings().getFundingGroup()) {
assertEquals(1, group.getFundingSummary().size());
FundingSummary element = group.getFundingSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(10))) {
assertEquals(Visibility.PUBLIC, element.getVisibility());
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
// Only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Employments in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmployments.
@Test
public void testViewEmployments() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEmployments(ORCID);
assertNotNull(r);
Employments employments = (Employments) r.getEntity();
assertNotNull(employments);
assertEquals("/0000-0000-0000-0003/employments", employments.getPath());
Utils.verifyLastModified(employments.getLastModifiedDate());
assertNotNull(employments.getSummaries());
assertEquals(4, employments.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (EmploymentSummary summary : employments.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(17).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(18).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(19).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(23).equals(summary.getPutCode())) {
assertEquals("SELF LIMITED Department", summary.getDepartmentName());
found4 = true;
} else {
fail("Invalid education found: " + summary.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Employments in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EmploymentsTest method testViewEmploymentsReadPublic.
@Test
public void testViewEmploymentsReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEmployments(ORCID);
Employments element = (Employments) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/employments", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Aggregations