Search in sources :

Example 51 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary 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 52 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary 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)

Example 53 with WorkSummary

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

the class PublicV3ApiServiceDelegatorTest method testViewWorks.

@Test
public void testViewWorks() {
    Response response = serviceDelegator.viewWorks(ORCID);
    assertNotNull(response);
    Works works = (Works) response.getEntity();
    assertNotNull(works);
    assertEquals("/0000-0000-0000-0003/works", works.getPath());
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertEquals(1, works.getWorkGroup().size());
    assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
    WorkSummary work = works.getWorkGroup().get(0).getWorkSummary().get(0);
    assertEquals(Long.valueOf(11), work.getPutCode());
    assertNotNull(work.getLastModifiedDate());
    assertNotNull(work.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/work/11", work.getPath());
    assertEquals(WorkType.JOURNAL_ARTICLE, work.getType());
    assertEquals("APP-5555555555555555", work.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 54 with WorkSummary

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

the class PublicV3ApiServiceDelegatorImpl method viewWorks.

@Override
public Response viewWorks(String orcid) {
    List<WorkSummary> works = workManagerReadOnly.getWorksSummaryList(orcid);
    Works publicWorks = workManagerReadOnly.groupWorks(works, true);
    publicAPISecurityManagerV3.filter(publicWorks);
    ActivityUtils.cleanEmptyFields(publicWorks);
    ActivityUtils.setPathToWorks(publicWorks, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicWorks);
    sourceUtilsReadOnly.setSourceName(publicWorks);
    return Response.ok(publicWorks).build();
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works)

Example 55 with WorkSummary

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

the class WorkManagerReadOnlyImpl method groupWorks.

/**
 * Generate a grouped list of works with the given list of works
 *
 * @param works
 *            The list of works to group
 * @param justPublic
 *            Specify if we want to group only the public elements in the
 *            given list
 * @return Works element with the WorkSummary elements grouped
 */
@Override
public Works groupWorks(List<WorkSummary> works, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    Works result = new Works();
    // Group all works
    for (WorkSummary work : works) {
        if (justPublic && !work.getVisibility().equals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC)) {
        // If it is just public and the work is not public, just ignore
        // it
        } else {
            groupGenerator.group(work);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> externalIdentifiers = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        WorkGroup workGroup = new WorkGroup();
        // Fill the work groups with the external identifiers
        if (externalIdentifiers == null || externalIdentifiers.isEmpty()) {
            // Initialize the ids as an empty list
            workGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble extId : externalIdentifiers) {
                ExternalID workExtId = (ExternalID) extId;
                workGroup.getIdentifiers().getExternalIdentifier().add(workExtId.clone());
            }
        }
        // Fill the work group with the list of activities
        for (GroupableActivity activity : activities) {
            WorkSummary workSummary = (WorkSummary) activity;
            workGroup.getWorkSummary().add(workSummary);
        }
        // Sort the works
        workGroup.getWorkSummary().sort(WorkComparators.ALL);
        result.getWorkGroup().add(workGroup);
    }
    // Sort the groups!
    result.getWorkGroup().sort(WorkComparators.GROUP);
    return result;
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity) ActivitiesGroupGenerator(org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesGroup(org.orcid.core.utils.v3.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Aggregations

WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)85 Test (org.junit.Test)64 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)42 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)40 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)40 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)40 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)39 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 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)27 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)23 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