use of org.orcid.jaxb.model.record.summary_v2.EmploymentSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method viewEmploymentSummary.
@Override
public Response viewEmploymentSummary(String orcid, Long putCode) {
EmploymentSummary es = affiliationsManagerReadOnly.getEmploymentSummary(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, es, ScopePathType.AFFILIATIONS_READ_LIMITED);
ActivityUtils.setPathToActivity(es, orcid);
sourceUtils.setSourceName(es);
return Response.ok(es).build();
}
use of org.orcid.jaxb.model.record.summary_v2.EmploymentSummary 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_v2.EmploymentSummary 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_v2.EmploymentSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testActivities.
private void testActivities(ActivitiesSummary as, String orcid) {
boolean found1 = false, found2 = false, found3 = false;
// This is more an utility that will work only for 0000-0000-0000-0003
assertEquals("0000-0000-0000-0003", orcid);
assertNotNull(as);
assertNotNull(as.getPath());
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
assertNotNull(as.getEducations());
assertEquals(3, as.getEducations().getSummaries().size());
for (EducationSummary element : as.getEducations().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(20))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(21))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(22))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getEmployments());
assertEquals(3, as.getEmployments().getSummaries().size());
for (EmploymentSummary element : as.getEmployments().getSummaries()) {
if (element.getPutCode().equals(Long.valueOf(17))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(18))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(19))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = 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))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = 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))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(10))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
assertNotNull(as.getWorks());
assertEquals(3, as.getWorks().getWorkGroup().size());
for (WorkGroup group : as.getWorks().getWorkGroup()) {
assertEquals(1, group.getWorkSummary().size());
WorkSummary element = group.getWorkSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(11))) {
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
found1 = found2 = found3 = false;
}
use of org.orcid.jaxb.model.record.summary_v2.EmploymentSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_AffiliationsReadLimited_NoSource.
@Test
public void testViewActitivies_AffiliationsReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.AFFILIATIONS_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Limited educations
boolean found1 = false, found2 = false, found3 = false;
assertNotNull(as.getEducations());
assertEquals(3, as.getEducations().getSummaries().size());
for (EducationSummary education : as.getEducations().getSummaries()) {
Long putCode = education.getPutCode();
if (putCode == 20L) {
assertEquals(Visibility.PUBLIC, education.getVisibility());
found1 = true;
} else if (putCode == 21L) {
assertEquals(Visibility.LIMITED, education.getVisibility());
found2 = true;
} else if (putCode == 25L) {
assertEquals(Visibility.LIMITED, education.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + putCode);
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Limited employments
found1 = found2 = found3 = false;
assertNotNull(as.getEmployments());
assertEquals(3, as.getEmployments().getSummaries().size());
for (EmploymentSummary employment : as.getEmployments().getSummaries()) {
Long putCode = employment.getPutCode();
if (putCode == 17L) {
assertEquals(Visibility.PUBLIC, employment.getVisibility());
found1 = true;
} else if (putCode == 18L) {
assertEquals(Visibility.LIMITED, employment.getVisibility());
found2 = true;
} else if (putCode == 23L) {
assertEquals(Visibility.LIMITED, employment.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + putCode);
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// 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());
// 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());
}
Aggregations