Search in sources :

Example 31 with EducationSummary

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());
}
Also used : Response(javax.ws.rs.core.Response) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 32 with EducationSummary

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);
}
Also used : Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.v3.dev1.record.Education) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) List(java.util.List) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 33 with EducationSummary

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;
}
Also used : EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) Educations(org.orcid.jaxb.model.v3.dev1.record.summary.Educations) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility)

Example 34 with EducationSummary

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();
}
Also used : EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) Educations(org.orcid.jaxb.model.v3.dev1.record.summary.Educations)

Example 35 with EducationSummary

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);
}
Also used : Education(org.orcid.jaxb.model.v3.dev1.record.Education) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)

Aggregations

EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)57 Test (org.junit.Test)43 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)41 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)40 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)40 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)39 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)37 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)35 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)35 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)35 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)35 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)35 Address (org.orcid.jaxb.model.v3.dev1.record.Address)15 Email (org.orcid.jaxb.model.v3.dev1.record.Email)15 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)15 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)15 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)15 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)15 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14