Search in sources :

Example 21 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class WorksPaginatorTest method getLimitedWorkGroup.

private WorkGroup getLimitedWorkGroup(int i) {
    WorkGroup workGroup = new WorkGroup();
    workGroup.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis())));
    for (int x = 0; x < 10; x++) {
        WorkSummary workSummary = new WorkSummary();
        workSummary.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis())));
        workSummary.setTitle(getTitle(i));
        workSummary.setVisibility(Visibility.LIMITED);
        workSummary.setDisplayIndex(Integer.toString(x));
        workSummary.setPutCode(Long.valueOf(new StringBuilder(i).append(x).toString()));
        workSummary.setSource(getSource());
        workSummary.setType(WorkType.EDITED_BOOK);
        workGroup.getWorkSummary().add(workSummary);
    }
    return workGroup;
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate)

Example 22 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class WorksPaginatorTest method getPublicWorkGroup.

private WorkGroup getPublicWorkGroup(int i) {
    WorkGroup workGroup = new WorkGroup();
    workGroup.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis())));
    for (int x = 0; x < 10; x++) {
        WorkSummary workSummary = new WorkSummary();
        workSummary.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(System.currentTimeMillis())));
        workSummary.setPublicationDate(new PublicationDate(new FuzzyDate(new Year(2017), new Month(x), new Day(x))));
        workSummary.setTitle(getTitle(i));
        workSummary.setVisibility(Visibility.PUBLIC);
        workSummary.setDisplayIndex(Integer.toString(x));
        workSummary.setPutCode(Long.valueOf(new StringBuilder(i).append(x).toString()));
        workSummary.setSource(getSource());
        workSummary.setType(WorkType.EDITED_BOOK);
        workGroup.getWorkSummary().add(workSummary);
    }
    return workGroup;
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) LastModifiedDate(org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate) Month(org.orcid.jaxb.model.v3.dev1.common.Month) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) PublicationDate(org.orcid.jaxb.model.v3.dev1.common.PublicationDate) Year(org.orcid.jaxb.model.v3.dev1.common.Year) CreatedDate(org.orcid.jaxb.model.v3.dev1.common.CreatedDate) FuzzyDate(org.orcid.jaxb.model.v3.dev1.common.FuzzyDate) Day(org.orcid.jaxb.model.v3.dev1.common.Day)

Example 23 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_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.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 24 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_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.v3.dev1.common.LastModifiedDate) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 25 with WorkGroup

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup in project ORCID-Source by ORCID.

the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testActivities.

private void testActivities(ActivitiesSummary as, String orcid) {
    boolean found1 = false, found2 = false, found3 = false;
    // This is more an utility that will work only for 0000-0000-0000-0003
    assertEquals("0000-0000-0000-0003", orcid);
    assertNotNull(as);
    assertNotNull(as.getPath());
    assertEquals("/0000-0000-0000-0003/activities", as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    assertNotNull(as.getEducations());
    assertEquals(3, 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 {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    found1 = found2 = found3 = false;
    assertNotNull(as.getEmployments());
    assertEquals(3, 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 {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    found1 = found2 = found3 = false;
    assertNotNull(as.getFundings());
    assertEquals(3, 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 {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    found1 = found2 = found3 = false;
    assertNotNull(as.getPeerReviews());
    assertEquals(3, 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 {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    found1 = found2 = found3 = false;
    assertNotNull(as.getWorks());
    assertEquals(3, 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 {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    found1 = found2 = found3 = false;
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)

Aggregations

WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)28 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)28 Test (org.junit.Test)17 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)17 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)10 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)9 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)9 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)8 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)8 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)8 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)8 ArrayList (java.util.ArrayList)6 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)6 DBUnitTest (org.orcid.test.DBUnitTest)6 ClientResponse (com.sun.jersey.api.client.ClientResponse)5 Response (javax.ws.rs.core.Response)5 Work (org.orcid.jaxb.model.v3.dev1.record.Work)5 LastModifiedDate (org.orcid.jaxb.model.v3.dev1.common.LastModifiedDate)4 Title (org.orcid.jaxb.model.v3.dev1.common.Title)4 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)4