use of org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_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());
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_EducationsTest method testAddEducation.
@Test
public void testAddEducation() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewActivities(ORCID);
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(4, summary.getEducations().getSummaries().size());
response = serviceDelegator.createEducation(ORCID, (Education) Utils.getAffiliation(AffiliationType.EDUCATION));
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(ORCID);
assertNotNull(response);
ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
assertNotNull(summaryWithNewElement);
Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
assertNotNull(summaryWithNewElement.getEducations());
Utils.verifyLastModified(summaryWithNewElement.getEducations().getLastModifiedDate());
assertNotNull(summaryWithNewElement.getEducations().getSummaries());
assertEquals(5, summaryWithNewElement.getEducations().getSummaries().size());
boolean haveNew = true;
for (EducationSummary educationSummary : summary.getEducations().getSummaries()) {
assertNotNull(educationSummary.getPutCode());
Utils.verifyLastModified(educationSummary.getLastModifiedDate());
if (educationSummary.getPutCode().equals(putCode)) {
assertEquals("My department name", educationSummary.getDepartmentName());
haveNew = true;
} else {
assertTrue(summary.getEducations().getSummaries().contains(educationSummary));
}
}
assertTrue(haveNew);
// Delete the just created element
serviceDelegator.deleteAffiliation(ORCID, putCode);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary in project ORCID-Source by ORCID.
the class PublicAPISecurityManagerV3Test method getEducations.
private Educations getEducations(Visibility... vs) {
Educations e = new Educations();
for (Visibility v : vs) {
EducationSummary s = new EducationSummary();
s.setVisibility(v);
e.getSummaries().add(s);
}
return e;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewEducations.
@Override
public Response viewEducations(String orcid) {
List<EducationSummary> educations = affiliationsManagerReadOnly.getEducationSummaryList(orcid);
Educations publicEducations = new Educations();
for (EducationSummary summary : educations) {
if (Visibility.PUBLIC.equals(summary.getVisibility())) {
ActivityUtils.setPathToActivity(summary, orcid);
sourceUtilsReadOnly.setSourceName(summary);
publicEducations.getSummaries().add(summary);
}
}
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicEducations);
ActivityUtils.setPathToAffiliations(publicEducations, orcid);
return Response.ok(publicEducations).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getEducationMapperFacade.
public MapperFacade getEducationMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<Education, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Education.class, OrgAffiliationRelationEntity.class);
ClassMapBuilder<EducationSummary, OrgAffiliationRelationEntity> summaryClassMap = mapperFactory.classMap(EducationSummary.class, OrgAffiliationRelationEntity.class);
return generateMapperFacadeForAffiliation(mapperFactory, classMap, summaryClassMap);
}
Aggregations