Search in sources :

Example 36 with Works

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

the class MemberV2ApiServiceDelegator_FundingTest method testReadPublicScope_Funding.

@Test
public void testReadPublicScope_Funding() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(r);
    assertEquals(Funding.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewFundingSummary(ORCID, 10L);
    assertNotNull(r);
    assertEquals(FundingSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited that am the source of should work
    serviceDelegator.viewFunding(ORCID, 11L);
    serviceDelegator.viewFundingSummary(ORCID, 11L);
    // Limited that am not the source of should fail
    try {
        serviceDelegator.viewFunding(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewFundingSummary(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Private that am the source of should work
    serviceDelegator.viewFunding(ORCID, 12L);
    serviceDelegator.viewFundingSummary(ORCID, 12L);
    // Private am not the source of should fail
    try {
        serviceDelegator.viewFunding(ORCID, 14L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewFundingSummary(ORCID, 14L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) Funding(org.orcid.jaxb.model.record_v2.Funding) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 37 with Works

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

the class MemberV2ApiServiceDelegator_PeerReviewsTest method testReadPublicScope_PeerReview.

@Test
public void testReadPublicScope_PeerReview() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    // Public works
    Response r = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(r);
    assertEquals(PeerReview.class.getName(), r.getEntity().getClass().getName());
    r = serviceDelegator.viewPeerReviewSummary(ORCID, 9L);
    assertNotNull(r);
    assertEquals(PeerReviewSummary.class.getName(), r.getEntity().getClass().getName());
    // Limited where am the source of should work
    serviceDelegator.viewPeerReview(ORCID, 10L);
    serviceDelegator.viewPeerReviewSummary(ORCID, 10L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewPeerReview(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewPeerReviewSummary(ORCID, 12L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    // Limited where am the source of should work
    serviceDelegator.viewPeerReview(ORCID, 11L);
    serviceDelegator.viewPeerReviewSummary(ORCID, 11L);
    // Limited where am not the source of should fail
    try {
        serviceDelegator.viewPeerReview(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
    try {
        serviceDelegator.viewPeerReviewSummary(ORCID, 13L);
        fail();
    } catch (OrcidAccessControlException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) NoResultException(javax.persistence.NoResultException) VisibilityMismatchException(org.orcid.core.exception.VisibilityMismatchException) WrongSourceException(org.orcid.core.exception.WrongSourceException) ActivityIdentifierValidationException(org.orcid.core.exception.ActivityIdentifierValidationException) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException) OrcidVisibilityException(org.orcid.core.exception.OrcidVisibilityException) OrcidUnauthorizedException(org.orcid.core.exception.OrcidUnauthorizedException) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 38 with Works

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

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

the class WorkManagerTest method testGroupWorks_groupOnlyPublicWorks1.

@Test
public void testGroupWorks_groupOnlyPublicWorks1() {
    WorkSummary s1 = getWorkSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s2 = getWorkSummary("Limited 1", "ext-id-2", Visibility.LIMITED);
    WorkSummary s3 = getWorkSummary("Private 1", "ext-id-3", Visibility.PRIVATE);
    WorkSummary s4 = getWorkSummary("Public 2", "ext-id-4", Visibility.PUBLIC);
    WorkSummary s5 = getWorkSummary("Limited 2", "ext-id-5", Visibility.LIMITED);
    WorkSummary s6 = getWorkSummary("Private 2", "ext-id-6", Visibility.PRIVATE);
    WorkSummary s7 = getWorkSummary("Public 3", "ext-id-7", Visibility.PUBLIC);
    WorkSummary s8 = getWorkSummary("Limited 3", "ext-id-8", Visibility.LIMITED);
    WorkSummary s9 = getWorkSummary("Private 3", "ext-id-9", Visibility.PRIVATE);
    List<WorkSummary> 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
         * */
    Works works = workManager.groupWorks(workList, true);
    assertNotNull(works);
    assertEquals(3, works.getWorkGroup().size());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
    assertEquals("ext-id-1", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 1", works.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTitle().getContent());
    assertEquals(1, works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, works.getWorkGroup().get(1).getWorkSummary().size());
    assertEquals("ext-id-4", works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 2", works.getWorkGroup().get(1).getWorkSummary().get(0).getTitle().getTitle().getContent());
    assertEquals(1, works.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, works.getWorkGroup().get(2).getWorkSummary().size());
    assertEquals("ext-id-7", works.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 3", works.getWorkGroup().get(2).getWorkSummary().get(0).getTitle().getTitle().getContent());
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 40 with Works

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

the class WorkManagerTest method testGroupWorks_groupOnlyPublicWorks2.

@Test
public void testGroupWorks_groupOnlyPublicWorks2() {
    WorkSummary s1 = getWorkSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s2 = getWorkSummary("Limited 1", "ext-id-1", Visibility.LIMITED);
    WorkSummary s3 = getWorkSummary("Private 1", "ext-id-1", Visibility.PRIVATE);
    WorkSummary s4 = getWorkSummary("Public 2", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s5 = getWorkSummary("Limited 2", "ext-id-1", Visibility.LIMITED);
    WorkSummary s6 = getWorkSummary("Private 2", "ext-id-1", Visibility.PRIVATE);
    WorkSummary s7 = getWorkSummary("Public 3", "ext-id-2", Visibility.PUBLIC);
    WorkSummary s8 = getWorkSummary("Limited 3", "ext-id-2", Visibility.LIMITED);
    WorkSummary s9 = getWorkSummary("Private 3", "ext-id-2", Visibility.PRIVATE);
    List<WorkSummary> workList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
    /**
         * They should be grouped as
         * 
         * Group 1: Public 1 + Public 2
         * Group 2: Public 3
         * */
    Works works = workManager.groupWorks(workList, true);
    assertNotNull(works);
    assertEquals(2, works.getWorkGroup().size());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(2, works.getWorkGroup().get(0).getWorkSummary().size());
    assertThat(works.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
    assertThat(works.getWorkGroup().get(0).getWorkSummary().get(1).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
    assertEquals(1, works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, works.getWorkGroup().get(1).getWorkSummary().size());
    assertEquals("Public 3", works.getWorkGroup().get(1).getWorkSummary().get(0).getTitle().getTitle().getContent());
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Test (org.junit.Test)84 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)65 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)48 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)42 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)41 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)41 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)40 Works (org.orcid.jaxb.model.record.summary_v2.Works)26 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)19 Address (org.orcid.jaxb.model.record_v2.Address)19 Email (org.orcid.jaxb.model.record_v2.Email)19 Keyword (org.orcid.jaxb.model.record_v2.Keyword)19 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)19 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)19 Record (org.orcid.jaxb.model.record_v2.Record)18 Biography (org.orcid.jaxb.model.record_v2.Biography)17 Name (org.orcid.jaxb.model.record_v2.Name)17 OtherName (org.orcid.jaxb.model.record_v2.OtherName)17 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)17 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15