Search in sources :

Example 11 with PeerReviews

use of org.orcid.jaxb.model.v3.dev1.record.summary.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);
    // Distinctions
    if (activities.getDistinctions() != null) {
        checkAndFilter(orcid, activities.getDistinctions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // 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);
    }
    // Invited positions
    if (activities.getInvitedPositions() != null) {
        checkAndFilter(orcid, activities.getInvitedPositions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Memberships
    if (activities.getMemberships() != null) {
        checkAndFilter(orcid, activities.getMemberships().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Qualifications
    if (activities.getQualifications() != null) {
        checkAndFilter(orcid, activities.getQualifications().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Services
    if (activities.getServices() != null) {
        checkAndFilter(orcid, activities.getServices().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.v3.dev1.record.summary.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)

Example 12 with PeerReviews

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

the class ActivityManagerImpl method pubPeerReviewsMap.

public LinkedHashMap<Long, PeerReview> pubPeerReviewsMap(String orcid) {
    List<PeerReview> peerReviews = peerReviewManager.findPeerReviews(orcid);
    LinkedHashMap<Long, PeerReview> peerReviewMap = new LinkedHashMap<>();
    if (peerReviews != null) {
        if (!peerReviews.isEmpty()) {
            for (PeerReview peerReview : peerReviews) {
                if (peerReview.getVisibility().equals(Visibility.PUBLIC)) {
                    peerReviewMap.put(peerReview.getPutCode(), peerReview);
                }
            }
        }
    }
    return peerReviewMap;
}
Also used : PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with PeerReviews

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

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testViewPeerReviews.

@Test
public void testViewPeerReviews() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewPeerReviews(ORCID);
    assertNotNull(r);
    PeerReviews peerReviews = (PeerReviews) r.getEntity();
    assertNotNull(peerReviews);
    assertEquals("/0000-0000-0000-0003/peer-reviews", peerReviews.getPath());
    Utils.verifyLastModified(peerReviews.getLastModifiedDate());
    assertNotNull(peerReviews.getPeerReviewGroup());
    assertEquals(4, peerReviews.getPeerReviewGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (PeerReviewGroup group : peerReviews.getPeerReviewGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        assertNotNull(group.getIdentifiers());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(group.getPeerReviewSummary());
        assertEquals(1, group.getPeerReviewSummary().size());
        PeerReviewSummary summary = group.getPeerReviewSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        switch(group.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "issn:0000009":
                assertEquals("issn:0000009", summary.getGroupId());
                assertEquals(Long.valueOf(9), summary.getPutCode());
                found1 = true;
                break;
            case "issn:0000010":
                assertEquals("issn:0000010", summary.getGroupId());
                assertEquals(Long.valueOf(10), summary.getPutCode());
                found2 = true;
                break;
            case "issn:0000011":
                assertEquals("issn:0000011", summary.getGroupId());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found3 = true;
                break;
            case "issn:0000012":
                assertEquals("issn:0000012", summary.getGroupId());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid group id found: " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
                break;
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 14 with PeerReviews

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

the class PublicV3ApiServiceDelegatorTest method testGetPublicPeerReviews.

@Test
public void testGetPublicPeerReviews() {
    Response r = serviceDelegator.viewPeerReviews(ORCID);
    assertNotNull(r);
    PeerReviews p = (PeerReviews) r.getEntity();
    assertNotNull(p);
    assertNotNull(p.getLastModifiedDate());
    assertNotNull(p.getLastModifiedDate().getValue());
    assertNotNull(p.getPeerReviewGroup());
    assertEquals(1, p.getPeerReviewGroup().size());
    assertNotNull(p.getPeerReviewGroup().get(0).getPeerReviewSummary());
    assertEquals(1, p.getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertEquals(Long.valueOf(9), p.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertNotNull(p.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate());
    assertNotNull(p.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate().getValue());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 15 with PeerReviews

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

the class PublicV3ApiServiceDelegatorTest method testViewPeerReviews.

@Test
public void testViewPeerReviews() {
    Response response = serviceDelegator.viewPeerReviews(ORCID);
    assertNotNull(response);
    PeerReviews peerReviews = (PeerReviews) response.getEntity();
    assertNotNull(peerReviews);
    assertEquals("/0000-0000-0000-0003/peer-reviews", peerReviews.getPath());
    assertNotNull(peerReviews.getLastModifiedDate());
    assertNotNull(peerReviews.getLastModifiedDate().getValue());
    assertEquals(1, peerReviews.getPeerReviewGroup().size());
    assertEquals(1, peerReviews.getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    PeerReviewSummary peerReview = peerReviews.getPeerReviewGroup().get(0).getPeerReviewSummary().get(0);
    assertEquals(Long.valueOf(9), peerReview.getPutCode());
    assertNotNull(peerReview.getLastModifiedDate());
    assertNotNull(peerReview.getLastModifiedDate().getValue());
    assertEquals("02", peerReview.getCompletionDate().getDay().getValue());
    assertEquals("02", peerReview.getCompletionDate().getMonth().getValue());
    assertEquals("2016", peerReview.getCompletionDate().getYear().getValue());
    assertNotNull(peerReview.getExternalIdentifiers());
    assertNotNull(peerReview.getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, peerReview.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals("/0000-0000-0000-0003/peer-review/9", peerReview.getPath());
    assertEquals("work:external-identifier-id#1", peerReview.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(Visibility.PUBLIC.value(), peerReview.getVisibility().value());
    assertEquals("APP-5555555555555555", peerReview.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) PeerReviews(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

PeerReviews (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviews)19 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)15 Test (org.junit.Test)12 PeerReviewGroup (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup)9 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)5 Response (javax.ws.rs.core.Response)4 BaseTest (org.orcid.core.BaseTest)4 FundingGroup (org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)4 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)4 DBUnitTest (org.orcid.test.DBUnitTest)4 ArrayList (java.util.ArrayList)3 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)3 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)3 Educations (org.orcid.jaxb.model.v3.dev1.record.summary.Educations)3 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)3 Employments (org.orcid.jaxb.model.v3.dev1.record.summary.Employments)3 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)3 Fundings (org.orcid.jaxb.model.v3.dev1.record.summary.Fundings)3 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)3 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)3