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();
}
}
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();
}
}
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);
}
}
}
}
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());
}
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());
}
Aggregations