Search in sources :

Example 11 with PeerReviews

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

the class PublicAPISecurityManagerV2Test method getPeerReviews.

private PeerReviews getPeerReviews(Visibility... vs) {
    PeerReviews peerReviews = new PeerReviews();
    for (Visibility v : vs) {
        PeerReviewGroup g = new PeerReviewGroup();
        PeerReviewSummary s = new PeerReviewSummary();
        s.setVisibility(v);
        g.getPeerReviewSummary().add(s);
        peerReviews.getPeerReviewGroup().add(g);
    }
    return peerReviews;
}
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) Visibility(org.orcid.jaxb.model.common_v2.Visibility)

Example 12 with PeerReviews

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

the class OrcidSecurityManagerImpl method checkAndFilter.

@Override
public void checkAndFilter(String orcid, ActivitiesSummary activities) {
    if (activities == null) {
        return;
    }
    // Check the token
    isMyToken(orcid);
    // Educations
    if (activities.getEducations() != null) {
        checkAndFilter(orcid, activities.getEducations().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Employments
    if (activities.getEmployments() != null) {
        checkAndFilter(orcid, activities.getEmployments().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Funding
    if (activities.getFundings() != null) {
        Iterator<FundingGroup> groupIt = activities.getFundings().getFundingGroup().iterator();
        while (groupIt.hasNext()) {
            FundingGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getFundingSummary(), READ_FUNDING_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getFundingSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
    // PeerReviews
    if (activities.getPeerReviews() != null) {
        Iterator<PeerReviewGroup> groupIt = activities.getPeerReviews().getPeerReviewGroup().iterator();
        while (groupIt.hasNext()) {
            PeerReviewGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getPeerReviewSummary(), READ_PEER_REVIEWS_REQUIRED_SCOPE, true);
            if (group.getPeerReviewSummary().isEmpty()) {
                groupIt.remove();
            }
        }
    }
    // Works
    if (activities.getWorks() != null) {
        Iterator<WorkGroup> groupIt = activities.getWorks().getWorkGroup().iterator();
        while (groupIt.hasNext()) {
            WorkGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getWorkSummary(), READ_WORKS_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getWorkSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup)

Example 13 with PeerReviews

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

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

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

the class ConvertVrc3ToVrc4Test method upgradePeerReviewsToVrc3Test.

@Test
public void upgradePeerReviewsToVrc3Test() throws JAXBException {
    JAXBContext jaxbContext1 = JAXBContext.newInstance(PeerReviews.class);
    JAXBContext jaxbContext2 = JAXBContext.newInstance(org.orcid.jaxb.model.record.summary_rc4.PeerReviews.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext1.createUnmarshaller();
    InputStream rc3Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc3.xml");
    InputStream rc4Stream = ConvertVrc3ToVrc4Test.class.getClassLoader().getResourceAsStream("test-peer-reviews-2.0_rc4.xml");
    PeerReviews rc4PeerReviews = (PeerReviews) jaxbUnmarshaller.unmarshal(rc3Stream);
    jaxbUnmarshaller = jaxbContext2.createUnmarshaller();
    org.orcid.jaxb.model.record.summary_rc4.PeerReviews rc4PeerReviews1 = (org.orcid.jaxb.model.record.summary_rc4.PeerReviews) jaxbUnmarshaller.unmarshal(rc4Stream);
    V2Convertible result = versionConverterV2_0_rc3ToV2_0_rc4.upgrade(new V2Convertible(rc4PeerReviews, "v2_rc3"));
    org.orcid.jaxb.model.record.summary_rc4.PeerReviews rc4PeerReviews2 = (org.orcid.jaxb.model.record.summary_rc4.PeerReviews) result.getObjectToConvert();
    assertEquals(rc4PeerReviews1, rc4PeerReviews2);
}
Also used : V2Convertible(org.orcid.core.version.V2Convertible) InputStream(java.io.InputStream) PeerReviews(org.orcid.jaxb.model.record.summary_rc3.PeerReviews) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

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