Search in sources :

Example 41 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary in project ORCID-Source by ORCID.

the class PeerReviewManagerTest method testGroupPeerReviews_groupOnlyPublicPeerReviews1.

@Test
public void testGroupPeerReviews_groupOnlyPublicPeerReviews1() {
    PeerReviewSummary s1 = getPeerReviewSummary("public-peer-review-group-id-1", "ext-id-1", Visibility.PUBLIC);
    PeerReviewSummary s2 = getPeerReviewSummary("limited-peer-review-group-id-1", "ext-id-2", Visibility.LIMITED);
    PeerReviewSummary s3 = getPeerReviewSummary("private-peer-review-group-id-1", "ext-id-3", Visibility.PRIVATE);
    PeerReviewSummary s4 = getPeerReviewSummary("public-peer-review-group-id-2", "ext-id-4", Visibility.PUBLIC);
    PeerReviewSummary s5 = getPeerReviewSummary("limited-peer-review-group-id-2", "ext-id-5", Visibility.LIMITED);
    PeerReviewSummary s6 = getPeerReviewSummary("private-peer-review-group-id-2", "ext-id-6", Visibility.PRIVATE);
    PeerReviewSummary s7 = getPeerReviewSummary("public-peer-review-group-id-3", "ext-id-7", Visibility.PUBLIC);
    PeerReviewSummary s8 = getPeerReviewSummary("limited-peer-review-group-id-3", "ext-id-8", Visibility.LIMITED);
    PeerReviewSummary s9 = getPeerReviewSummary("private-peer-review-group-id-3", "ext-id-9", Visibility.PRIVATE);
    List<PeerReviewSummary> workList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
    /**
     * They should be grouped as
     *
     * Group 1: Public 1
     * Group 2: Public 2
     * Group 3: Public 3
     */
    PeerReviews peerReviews = peerReviewManager.groupPeerReviews(workList, true);
    assertNotNull(peerReviews);
    assertEquals(3, peerReviews.getPeerReviewGroup().size());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertEquals("public-peer-review-group-id-1", peerReviews.getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("public-peer-review-group-id-1", peerReviews.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(1).getPeerReviewSummary().size());
    assertEquals("public-peer-review-group-id-2", peerReviews.getPeerReviewGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("public-peer-review-group-id-2", peerReviews.getPeerReviewGroup().get(1).getPeerReviewSummary().get(0).getGroupId());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(2).getPeerReviewSummary().size());
    assertEquals("public-peer-review-group-id-3", peerReviews.getPeerReviewGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("public-peer-review-group-id-3", peerReviews.getPeerReviewGroup().get(2).getPeerReviewSummary().get(0).getGroupId());
}
Also used : PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 42 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary in project ORCID-Source by ORCID.

the class PeerReviewManagerTest method testGetAllSummaries.

@Test
public void testGetAllSummaries() {
    String orcid = "0000-0000-0000-0003";
    List<PeerReviewSummary> elements = peerReviewManager.getPeerReviewSummaryList(orcid);
    boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
    for (PeerReviewSummary element : elements) {
        if (9 == element.getPutCode()) {
            found1 = true;
        } else if (10 == element.getPutCode()) {
            found2 = true;
        } else if (11 == element.getPutCode()) {
            found3 = true;
        } else if (12 == element.getPutCode()) {
            found4 = true;
        } else if (13 == element.getPutCode()) {
            found5 = true;
        } else {
            fail("Invalid element found: " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    assertTrue(found5);
}
Also used : PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 43 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary in project ORCID-Source by ORCID.

the class PeerReviewManagerTest method nonGroupableIdsGenerateEmptyIdsListTest.

@Test
public void nonGroupableIdsGenerateEmptyIdsListTest() {
    PeerReviewSummary s1 = getPeerReviewSummary("Element 1", "ext-id-1", Visibility.PUBLIC);
    PeerReviewSummary s2 = getPeerReviewSummary("Element 2", "ext-id-2", Visibility.LIMITED);
    PeerReviewSummary s3 = getPeerReviewSummary("Element 3", "ext-id-3", Visibility.PRIVATE);
    // Remove the grouping id from s1
    s1.setGroupId(null);
    List<PeerReviewSummary> peerReviewsList = Arrays.asList(s1, s2, s3);
    /**
     * They should be grouped as
     *
     * Group 1: Element 1
     * Group 2: Element 2
     * Group 3: Element 3
     */
    PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewsList, false);
    assertNotNull(peerReviews);
    assertEquals(3, peerReviews.getPeerReviewGroup().size());
    boolean foundEmptyGroup = false;
    boolean found2 = false;
    boolean found3 = false;
    for (PeerReviewGroup group : peerReviews.getPeerReviewGroup()) {
        assertEquals(1, group.getPeerReviewSummary().size());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
        if (group.getIdentifiers().getExternalIdentifier().get(0).getValue() == null) {
            assertEquals("ext-id-1", group.getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            foundEmptyGroup = true;
        } else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("Element 2")) {
            assertEquals("ext-id-2", group.getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            found2 = true;
        } else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("Element 3")) {
            assertEquals("ext-id-3", group.getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            found3 = true;
        } else {
            fail("Invalid ext id found " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(foundEmptyGroup);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 44 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary in project ORCID-Source by ORCID.

the class PeerReviewManagerReadOnlyImpl method groupPeerReviews.

/**
 * Generate a grouped list of peer reviews with the given list of peer reviews
 *
 * @param peerReviews
 *          The list of peer reviews to group
 * @param justPublic
 *          Specify if we want to group only the public elements in the given list
 * @return PeerReviews element with the PeerReviewSummary elements grouped
 */
@Override
public PeerReviews groupPeerReviews(List<PeerReviewSummary> peerReviews, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    PeerReviews result = new PeerReviews();
    for (PeerReviewSummary peerReview : peerReviews) {
        if (justPublic && !peerReview.getVisibility().equals(org.orcid.jaxb.model.common_v2.Visibility.PUBLIC)) {
        // If it is just public and the funding is not public, just
        // ignore it
        } else {
            groupGenerator.group(peerReview);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> groupKeys = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        PeerReviewGroup peerReviewGroup = new PeerReviewGroup();
        // Fill the peer review groups with the external identifiers
        if (groupKeys == null || groupKeys.isEmpty()) {
            // Initialize the ids as an empty list
            peerReviewGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble groupKey : groupKeys) {
                PeerReviewGroupKey key = (PeerReviewGroupKey) groupKey;
                ExternalID id = new ExternalID();
                // TODO: this is not nice
                id.setType(PeerReviewGroupKey.KEY_NAME);
                id.setValue(key.getGroupId());
                peerReviewGroup.getIdentifiers().getExternalIdentifier().add(id);
            }
        }
        // Fill the peer review group with the list of activities
        for (GroupableActivity activity : activities) {
            PeerReviewSummary peerReviewSummary = (PeerReviewSummary) activity;
            peerReviewGroup.getPeerReviewSummary().add(peerReviewSummary);
        }
        // Sort the peer reviews
        Collections.sort(peerReviewGroup.getPeerReviewSummary(), new GroupableActivityComparator());
        result.getPeerReviewGroup().add(peerReviewGroup);
    }
    return result;
}
Also used : PeerReviewGroupKey(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroupKey) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity) GroupableActivityComparator(org.orcid.core.utils.activities.GroupableActivityComparator) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) ActivitiesGroupGenerator(org.orcid.core.utils.activities.ActivitiesGroupGenerator) ActivitiesGroup(org.orcid.core.utils.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.record_v2.GroupAble)

Example 45 with PeerReviewSummary

use of org.orcid.jaxb.model.record.summary_rc1.PeerReviewSummary in project ORCID-Source by ORCID.

the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.

public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
    long lastModifiedTime = getLastModified(orcid);
    ActivitiesSummary activities = new ActivitiesSummary();
    // Set educations
    List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid);
    Educations educations = new Educations();
    for (EducationSummary summary : educationsList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                educations.getSummaries().add(summary);
            }
        } else {
            educations.getSummaries().add(summary);
        }
    }
    activities.setEducations(educations);
    // Set employments
    List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid);
    Employments employments = new Employments();
    for (EmploymentSummary summary : employmentList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                employments.getSummaries().add(summary);
            }
        } else {
            employments.getSummaries().add(summary);
        }
    }
    activities.setEmployments(employments);
    // Set fundings
    List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid);
    Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
    activities.setFundings(fundings);
    // Set peer reviews
    List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid);
    PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
    activities.setPeerReviews(peerReviews);
    // Set works
    List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid);
    Works works = workManager.groupWorks(workSummaries, justPublic);
    activities.setWorks(works);
    return activities;
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) 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)

Aggregations

PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)65 Test (org.junit.Test)59 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)43 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)43 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)43 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)43 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)20 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)18 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)17 Address (org.orcid.jaxb.model.record_v2.Address)16 Email (org.orcid.jaxb.model.record_v2.Email)16 Keyword (org.orcid.jaxb.model.record_v2.Keyword)16 OtherName (org.orcid.jaxb.model.record_v2.OtherName)16 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)16 Record (org.orcid.jaxb.model.record_v2.Record)16 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)16 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15 Emails (org.orcid.jaxb.model.record_v2.Emails)15