use of org.orcid.jaxb.model.record.summary_rc3.Employments in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl 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.setPathToEmployments(employments, orcid);
sourceUtils.setSourceName(employments);
Api2_0_LastModifiedDatesHelper.calculateLastModified(employments);
return Response.ok(employments).build();
}
use of org.orcid.jaxb.model.record.summary_rc3.Employments in project ORCID-Source by ORCID.
the class SourceUtils method setSourceName.
public void setSourceName(ActivitiesSummary as) {
if (as == null) {
return;
}
if (as.getEducations() != null) {
Educations educations = as.getEducations();
List<EducationSummary> list = educations.getSummaries();
if (list != null) {
for (EducationSummary summary : list) {
setSourceName(summary);
}
}
}
if (as.getEmployments() != null) {
Employments employments = as.getEmployments();
List<EmploymentSummary> list = employments.getSummaries();
if (list != null) {
for (EmploymentSummary summary : list) {
setSourceName(summary);
}
}
}
if (as.getFundings() != null) {
Fundings fundings = as.getFundings();
List<FundingGroup> groups = fundings.getFundingGroup();
if (groups != null) {
for (FundingGroup group : groups) {
List<FundingSummary> summaryList = group.getFundingSummary();
if (summaryList != null) {
for (FundingSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
if (as.getPeerReviews() != null) {
PeerReviews peerReviews = as.getPeerReviews();
List<PeerReviewGroup> groups = peerReviews.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup group : groups) {
List<PeerReviewSummary> summaryList = group.getPeerReviewSummary();
if (summaryList != null) {
for (PeerReviewSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
if (as.getWorks() != null) {
Works works = as.getWorks();
List<WorkGroup> groups = works.getWorkGroup();
if (groups != null) {
for (WorkGroup group : groups) {
List<WorkSummary> summaryList = group.getWorkSummary();
if (summaryList != null) {
for (WorkSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
}
use of org.orcid.jaxb.model.record.summary_rc3.Employments in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testGetPublicEmployments.
@Test
public void testGetPublicEmployments() {
Response r = serviceDelegator.viewEmployments(ORCID);
assertNotNull(r);
Employments employments = (Employments) r.getEntity();
assertNotNull(employments);
assertNotNull(employments.getLastModifiedDate());
assertNotNull(employments.getLastModifiedDate().getValue());
assertNotNull(employments.getSummaries());
assertEquals(1, employments.getSummaries().size());
assertEquals(Long.valueOf(17), employments.getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, employments.getSummaries().get(0).getVisibility());
assertNotNull(employments.getSummaries().get(0).getLastModifiedDate());
assertNotNull(employments.getSummaries().get(0).getLastModifiedDate().getValue());
}
use of org.orcid.jaxb.model.record.summary_rc3.Employments in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method testViewEmployments.
@Test
public void testViewEmployments() {
Response response = serviceDelegator.viewEmployments(ORCID);
assertNotNull(response);
Employments employments = (Employments) response.getEntity();
assertNotNull(employments);
assertEquals("/0000-0000-0000-0003/employments", employments.getPath());
assertNotNull(employments.getLastModifiedDate());
assertNotNull(employments.getLastModifiedDate().getValue());
assertEquals(1, employments.getSummaries().size());
EmploymentSummary employment = employments.getSummaries().get(0);
assertEquals(Long.valueOf(17), employment.getPutCode());
assertNotNull(employment.getLastModifiedDate());
assertNotNull(employment.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/employment/17", employment.getPath());
assertEquals("PUBLIC Department", employment.getDepartmentName());
assertEquals(Visibility.PUBLIC.value(), employment.getVisibility().value());
assertEquals("APP-5555555555555555", employment.getSource().retrieveSourcePath());
}
use of org.orcid.jaxb.model.record.summary_rc3.Employments in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV2Test method filterEmploymentsTest.
@Test
public void filterEmploymentsTest() {
Employments e = getEmployments(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV2.filter(e);
assertEquals(3, e.getSummaries().size());
assertContainerContainsOnlyPublicElements(e);
e = getEmployments(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV2.filter(e);
assertEquals(2, e.getSummaries().size());
assertContainerContainsOnlyPublicElements(e);
e = getEmployments(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV2.filter(e);
assertEquals(1, e.getSummaries().size());
assertContainerContainsOnlyPublicElements(e);
e = getEmployments(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
assertEquals(3, e.getSummaries().size());
publicAPISecurityManagerV2.filter(e);
assertTrue(e.getSummaries().isEmpty());
}
Aggregations