Search in sources :

Example 31 with WorkGroup

use of org.orcid.jaxb.model.record.summary_v2.WorkGroup in project ORCID-Source by ORCID.

the class ActivityUtilsTest method cleanWorksTest.

@Test
public void cleanWorksTest() {
    // Test it cleans empty fields
    WorkSummary s = getEmptyWorkSummary();
    Works w = new Works();
    WorkGroup g = new WorkGroup();
    g.getWorkSummary().add(s);
    w.getWorkGroup().add(g);
    assertNotNull(w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
    ActivityUtils.cleanEmptyFields(w);
    assertNull(w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
    // Test it doesn't remove non empty fields
    s = getEmptyWorkSummary();
    s.getTitle().getTranslatedTitle().setContent("test");
    s.getTitle().getTranslatedTitle().setLanguageCode("en_us");
    w = new Works();
    g = new WorkGroup();
    g.getWorkSummary().add(s);
    w.getWorkGroup().add(g);
    assertEquals("test", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
    assertEquals("en_us", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
    ActivityUtils.cleanEmptyFields(w);
    assertEquals("test", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
    assertEquals("en_us", w.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test)

Example 32 with WorkGroup

use of org.orcid.jaxb.model.record.summary_v2.WorkGroup in project ORCID-Source by ORCID.

the class ActivityUtilsTest method cleanEmptyActivitiesSummaryTest.

@Test
public void cleanEmptyActivitiesSummaryTest() {
    // Test it cleans empty fields
    WorkSummary s = getEmptyWorkSummary();
    ActivitiesSummary x = new ActivitiesSummary();
    Works w = new Works();
    WorkGroup g = new WorkGroup();
    g.getWorkSummary().add(s);
    w.getWorkGroup().add(g);
    x.setWorks(w);
    assertNotNull(x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
    ActivityUtils.cleanEmptyFields(x);
    assertNull(x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle());
    // Test it doesn't remove non empty fields
    s = getEmptyWorkSummary();
    s.getTitle().getTranslatedTitle().setContent("test");
    s.getTitle().getTranslatedTitle().setLanguageCode("en_us");
    x = new ActivitiesSummary();
    w = new Works();
    g = new WorkGroup();
    g.getWorkSummary().add(s);
    w.getWorkGroup().add(g);
    x.setWorks(w);
    assertEquals("test", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
    assertEquals("en_us", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
    ActivityUtils.cleanEmptyFields(x);
    assertEquals("test", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getContent());
    assertEquals("en_us", x.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTranslatedTitle().getLanguageCode());
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Test(org.junit.Test)

Example 33 with WorkGroup

use of org.orcid.jaxb.model.record.summary_v2.WorkGroup 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 34 with WorkGroup

use of org.orcid.jaxb.model.record.summary_v2.WorkGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testCleanEmptyFieldsOnActivities.

@Test
public void testCleanEmptyFieldsOnActivities() {
    LastModifiedDate lmd = new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis()));
    Works works = new Works();
    works.setLastModifiedDate(lmd);
    WorkGroup group = new WorkGroup();
    group.setLastModifiedDate(lmd);
    for (int i = 0; i < 5; i++) {
        WorkSummary summary = new WorkSummary();
        summary.setLastModifiedDate(lmd);
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Work " + i));
        title.setTranslatedTitle(new TranslatedTitle("", ""));
        summary.setTitle(title);
        group.getWorkSummary().add(summary);
    }
    works.getWorkGroup().add(group);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setWorks(works);
    ActivityUtils.cleanEmptyFields(as);
    assertNotNull(as);
    assertNotNull(as.getWorks());
    Utils.verifyLastModified(as.getWorks().getLastModifiedDate());
    assertNotNull(as.getWorks().getWorkGroup());
    assertEquals(1, as.getWorks().getWorkGroup().size());
    assertNotNull(as.getWorks().getWorkGroup().get(0).getWorkSummary());
    Utils.verifyLastModified(as.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertEquals(5, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    for (WorkSummary summary : as.getWorks().getWorkGroup().get(0).getWorkSummary()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        assertTrue(summary.getTitle().getTitle().getContent().startsWith("Work "));
        assertNull(summary.getTitle().getTranslatedTitle());
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Title(org.orcid.jaxb.model.common_v2.Title) Works(org.orcid.jaxb.model.record.summary_v2.Works) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 35 with WorkGroup

use of org.orcid.jaxb.model.record.summary_v2.WorkGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_WorksReadLimited_NoSource.

@Test
public void testViewActitivies_WorksReadLimited_NoSource() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.ORCID_WORKS_READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertNotNull(as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    // Only public educations
    assertNotNull(as.getEducations());
    assertEquals(1, as.getEducations().getSummaries().size());
    assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
    // Only public employments
    assertNotNull(as.getEmployments());
    assertEquals(1, as.getEmployments().getSummaries().size());
    assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
    assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
    // 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());
    // Limited works
    assertNotNull(as.getWorks());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (WorkGroup group : as.getWorks().getWorkGroup()) {
        assertEquals(1, group.getWorkSummary().size());
        WorkSummary element = group.getWorkSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(11))) {
            assertEquals(Visibility.PUBLIC, element.getVisibility());
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(14))) {
            assertEquals(Visibility.LIMITED, element.getVisibility());
            found3 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)35 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)31 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)30 ClientResponse (com.sun.jersey.api.client.ClientResponse)26 Works (org.orcid.jaxb.model.record.summary_v2.Works)17 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)14 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)13 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)13 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)13 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)12 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)12 ArrayList (java.util.ArrayList)9 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Response (javax.ws.rs.core.Response)5 ActivitiesSummary (org.orcid.jaxb.model.record.summary_rc1.ActivitiesSummary)5 WorkGroup (org.orcid.jaxb.model.record.summary_rc1.WorkGroup)5 WorkSummary (org.orcid.jaxb.model.record.summary_rc1.WorkSummary)5 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)5 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)5