Search in sources :

Example 16 with Educations

use of org.orcid.jaxb.model.record.summary_rc2.Educations 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);
                    }
                }
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Example 17 with Educations

use of org.orcid.jaxb.model.record.summary_rc2.Educations in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_EducationsTest method testViewEducationsReadPublic.

@Test
public void testViewEducationsReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewEducations(ORCID);
    Educations element = (Educations) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/educations", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 18 with Educations

use of org.orcid.jaxb.model.record.summary_rc2.Educations in project ORCID-Source by ORCID.

the class ConvertVrc4ToV2Test method upgradeEducationsToVrc3Test.

@Test
public void upgradeEducationsToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(Educations.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_v2.Educations.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc3Stream = ConvertVrc4ToV2Test.class.getClassLoader().getResourceAsStream("test-educations-2.0_rc4.xml");
    InputStream rc4Stream = ConvertVrc4ToV2Test.class.getClassLoader().getResourceAsStream("test-educations-2.0.xml");
    Educations rc4Educations = (Educations) jaxbUnmarshaller.unmarshal(rc3Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.record.summary_v2.Educations rc4Educations1 = (org.orcid.jaxb.model.record.summary_v2.Educations) jaxbUnmarshaller.unmarshal(rc4Stream);
    V2Convertible result = versionConverterV2_0_rc4ToV2_0.upgrade(new V2Convertible(rc4Educations, "v2_rc4"));
    org.orcid.jaxb.model.record.summary_v2.Educations rc4Educations2 = (org.orcid.jaxb.model.record.summary_v2.Educations) result.getObjectToConvert();
    assertEquals(rc4Educations1, rc4Educations2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) JAXBContext(javax.xml.bind.JAXBContext) Educations(org.orcid.jaxb.model.record.summary_rc4.Educations) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 19 with Educations

use of org.orcid.jaxb.model.record.summary_rc2.Educations in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV2Test method filterEducationsTest.

@Test
public void filterEducationsTest() {
    Educations e = getEducations(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertEquals(3, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getEducations(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertEquals(2, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getEducations(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertEquals(1, e.getSummaries().size());
    assertContainerContainsOnlyPublicElements(e);
    e = getEducations(Visibility.LIMITED, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, e.getSummaries().size());
    publicAPISecurityManagerV2.filter(e);
    assertTrue(e.getSummaries().isEmpty());
}
Also used : Educations(org.orcid.jaxb.model.record.summary_v2.Educations) Test(org.junit.Test)

Example 20 with Educations

use of org.orcid.jaxb.model.record.summary_rc2.Educations in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorTest method testViewEducations.

@Test
public void testViewEducations() {
    Response response = serviceDelegator.viewEducations(ORCID);
    assertNotNull(response);
    Educations educations = (Educations) response.getEntity();
    assertNotNull(educations);
    assertEquals("/0000-0000-0000-0003/educations", educations.getPath());
    assertNotNull(educations.getLastModifiedDate());
    assertNotNull(educations.getLastModifiedDate().getValue());
    assertEquals(1, educations.getSummaries().size());
    EducationSummary education = educations.getSummaries().get(0);
    assertEquals(Long.valueOf(20), education.getPutCode());
    assertNotNull(education.getLastModifiedDate());
    assertNotNull(education.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/education/20", education.getPath());
    assertEquals("PUBLIC Department", education.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), education.getVisibility().value());
    assertEquals("APP-5555555555555555", education.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)27 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)20 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)14 ClientResponse (com.sun.jersey.api.client.ClientResponse)10 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)8 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)8 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)8 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)8 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)8 Works (org.orcid.jaxb.model.record.summary_v2.Works)8 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)6 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)6 InputStream (java.io.InputStream)5 Response (javax.ws.rs.core.Response)5 JAXBContext (javax.xml.bind.JAXBContext)5 Unmarshaller (javax.xml.bind.Unmarshaller)5 BaseTest (org.orcid.core.BaseTest)5 V2Convertible (org.orcid.core.version.V2Convertible)5 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)5 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)5