use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies.
@Test
public void testViewActitivies() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
boolean found1 = false, found2 = false, found3 = false, found4 = false;
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertEquals("/0000-0000-0000-0003/activities", as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
assertNotNull(as.getEducations());
assertEquals(4, 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 if (element.getPutCode().equals(Long.valueOf(25))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getEmployments());
assertEquals(4, 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 if (element.getPutCode().equals(Long.valueOf(23))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getFundings());
assertEquals(4, 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 if (element.getPutCode().equals(Long.valueOf(13))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getPeerReviews());
assertEquals(4, 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 if (element.getPutCode().equals(Long.valueOf(12))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
found1 = found2 = found3 = found4 = false;
assertNotNull(as.getWorks());
assertEquals(4, 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 if (element.getPutCode().equals(Long.valueOf(14))) {
found4 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EducationsTest method testViewEducations.
@Test
public void testViewEducations() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
Response r = serviceDelegator.viewEducations(ORCID);
assertNotNull(r);
Educations educations = (Educations) r.getEntity();
assertNotNull(educations);
assertEquals("/0000-0000-0000-0003/educations", educations.getPath());
Utils.verifyLastModified(educations.getLastModifiedDate());
assertNotNull(educations.getSummaries());
assertEquals(4, educations.getSummaries().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false;
for (EducationSummary summary : educations.getSummaries()) {
Utils.verifyLastModified(summary.getLastModifiedDate());
if (Long.valueOf(20).equals(summary.getPutCode())) {
assertEquals("PUBLIC Department", summary.getDepartmentName());
found1 = true;
} else if (Long.valueOf(21).equals(summary.getPutCode())) {
assertEquals("LIMITED Department", summary.getDepartmentName());
found2 = true;
} else if (Long.valueOf(22).equals(summary.getPutCode())) {
assertEquals("PRIVATE Department", summary.getDepartmentName());
found3 = true;
} else if (Long.valueOf(25).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.EducationSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EducationsTest method testAddEducation.
@Test
public void testAddEducation() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4442", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities("4444-4444-4444-4442");
assertNotNull(response);
ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getEducations());
Utils.verifyLastModified(summary.getEducations().getLastModifiedDate());
assertNotNull(summary.getEducations().getSummaries());
assertNotNull(summary.getEducations().getSummaries().get(0));
Utils.verifyLastModified(summary.getEducations().getSummaries().get(0).getLastModifiedDate());
assertEquals(Long.valueOf(1), summary.getEducations().getSummaries().get(0).getPutCode());
response = serviceDelegator.createEducation("4444-4444-4444-4442", Utils.getEducation());
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-4442");
assertNotNull(response);
summary = (ActivitiesSummary) response.getEntity();
assertNotNull(summary);
Utils.verifyLastModified(summary.getLastModifiedDate());
assertNotNull(summary.getEducations());
Utils.verifyLastModified(summary.getEducations().getLastModifiedDate());
assertNotNull(summary.getEducations().getSummaries());
boolean haveOld = false;
boolean haveNew = false;
for (EducationSummary educationSummary : summary.getEducations().getSummaries()) {
assertNotNull(educationSummary.getPutCode());
Utils.verifyLastModified(educationSummary.getLastModifiedDate());
if (educationSummary.getPutCode() == 1L) {
assertEquals("A Department", educationSummary.getDepartmentName());
haveOld = true;
} else {
assertEquals(putCode, educationSummary.getPutCode());
assertEquals("My department name", educationSummary.getDepartmentName());
haveNew = true;
}
}
assertTrue(haveOld);
assertTrue(haveNew);
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegator_EducationsTest method testViewEducationSummaryReadPublic.
@Test
public void testViewEducationSummaryReadPublic() {
SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
Response r = serviceDelegator.viewEducationSummary(ORCID, 20L);
EducationSummary element = (EducationSummary) r.getEntity();
assertNotNull(element);
assertEquals("/0000-0000-0000-0003/education/20", element.getPath());
Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
use of org.orcid.jaxb.model.record.summary_rc1.EducationSummary 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;
}
Aggregations