use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_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.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EmploymentsTest method testAddEmployment.
@Test
public void testAddEmployment() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4447", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities("4444-4444-4444-4447");
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
assertNotNull(summary.getEmployments());
assertNotNull(summary.getEmployments().getSummaries());
assertNotNull(summary.getEmployments().getSummaries().get(0));
assertEquals(Long.valueOf(13), summary.getEmployments().getSummaries().get(0).getPutCode());
response = serviceDelegator.createEmployment("4444-4444-4444-4447", Utils.getEmployment());
assertNotNull(response);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
Map<?, ?> map = response.getMetadata();
assertNotNull(map);
assertTrue(map.containsKey("Location"));
List<?> resultWithPutCode = (List<?>) map.get("Location");
Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
response = serviceDelegator.viewActivities("4444-4444-4444-4447");
assertNotNull(response);
summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getEmployments());
Utils.verifyLastModified(summary.getEmployments().getLastModifiedDate());
assertNotNull(summary.getEmployments().getSummaries());
boolean haveOld = false;
boolean haveNew = false;
for (EmploymentSummary eSummary : summary.getEmployments().getSummaries()) {
assertNotNull(eSummary.getPutCode());
Utils.verifyLastModified(eSummary.getLastModifiedDate());
if (eSummary.getPutCode() == 13L) {
assertEquals("Employment Dept # 1", eSummary.getDepartmentName());
haveOld = true;
} else {
assertEquals(putCode, eSummary.getPutCode());
assertEquals("My department name", eSummary.getDepartmentName());
haveNew = true;
}
}
assertTrue(haveOld);
assertTrue(haveNew);
}
use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.
the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.
public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
long lastModifiedTime = getLastModified(orcid);
ActivitiesSummary activities = new ActivitiesSummary();
// Set educations
List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid, lastModifiedTime);
Educations educations = new Educations();
for (EducationSummary summary : educationsList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
educations.getSummaries().add(summary);
}
} else {
educations.getSummaries().add(summary);
}
}
activities.setEducations(educations);
// Set employments
List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid, lastModifiedTime);
Employments employments = new Employments();
for (EmploymentSummary summary : employmentList) {
if (justPublic) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
employments.getSummaries().add(summary);
}
} else {
employments.getSummaries().add(summary);
}
}
activities.setEmployments(employments);
// Set fundings
List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid, lastModifiedTime);
Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
activities.setFundings(fundings);
// Set peer reviews
List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid, lastModifiedTime);
PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
activities.setPeerReviews(peerReviews);
// Set works
List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid, lastModifiedTime);
Works works = workManager.groupWorks(workSummaries, justPublic);
activities.setWorks(works);
return activities;
}
use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.
the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AllReadLimited_And_NotSource.
@Test
public void testActivitiesSummary_When_AllReadLimited_And_NotSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.AFFILIATIONS_READ_LIMITED, ScopePathType.FUNDING_READ_LIMITED, ScopePathType.PEER_REVIEW_READ_LIMITED, ScopePathType.ORCID_WORKS_READ_LIMITED);
EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
EducationSummary e2 = createEducationSummary(Visibility.LIMITED, CLIENT_2);
EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.LIMITED, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(e1, e2, e3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
orcidSecurityManager.checkAndFilter(ORCID_1, as);
// Check it have limited Educations
assertNotNull(as.getEducations());
assertEquals(2, as.getEducations().getSummaries().size());
assertTrue(as.getEducations().getSummaries().contains(e1));
assertTrue(as.getEducations().getSummaries().contains(e2));
assertFalse(as.getEducations().getSummaries().contains(e3));
// Check it have limited Employments
assertNotNull(as.getEmployments());
assertEquals(2, as.getEmployments().getSummaries().size());
assertTrue(as.getEmployments().getSummaries().contains(em1));
assertTrue(as.getEmployments().getSummaries().contains(em2));
assertFalse(as.getEmployments().getSummaries().contains(em3));
// Check it have limited funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(2, as.getFundings().getFundingGroup().get(0).getActivities().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
assertEquals(3, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
// Check it have limited reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(2, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
// Check it have limited works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(2, as.getWorks().getWorkGroup().get(0).getActivities().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
assertEquals(3, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
use of org.orcid.jaxb.model.record.summary_rc1.EmploymentSummary in project ORCID-Source by ORCID.
the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AllPrivate_NoSource_ReadPublicToken.
@Test
public void testActivitiesSummary_When_AllPrivate_NoSource_ReadPublicToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
EducationSummary e1 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e2 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(e1, e2, e3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
orcidSecurityManager.checkAndFilter(ORCID_1, as);
assertNotNull(as);
// Check educations
assertEquals(0, as.getEducations().getSummaries().size());
// Check employments
assertEquals(0, as.getEmployments().getSummaries().size());
// Check fundings
assertEquals(0, as.getFundings().getFundingGroup().size());
// Check peer reviews
assertEquals(0, as.getPeerReviews().getPeerReviewGroup().size());
// Check works
assertEquals(0, as.getWorks().getWorkGroup().size());
}
Aggregations