use of org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingFundingsTest method generateFundings.
/**
* funding-1 -> A, B, C
* funding-2 -> C, D, E
* funding-3 -> X, Y, Z
* funding-4 -> Y, B, 1
* funding-5 -> M, N, O
* funding-6 -> O, P, Q
* funding-7 -> 1, 2, B
* funding-8 -> No external identifiers
* funding-9 -> No external identifiers
*/
private Map<String, FundingSummary> generateFundings() {
Map<String, FundingSummary> result = new HashMap<String, FundingSummary>();
for (int i = 1; i < 10; i++) {
String name = "funding-" + i;
FundingSummary funding = new FundingSummary();
FundingTitle title = new FundingTitle();
title.setTitle(new Title(name));
funding.setTitle(title);
ExternalIDs fei = new ExternalIDs();
switch(i) {
case 1:
ExternalID f1 = new ExternalID();
f1.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f1.setValue("A");
ExternalID f2 = new ExternalID();
f2.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f2.setValue("B");
ExternalID f3 = new ExternalID();
f3.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f3.setValue("C");
fei.getExternalIdentifier().add(f1);
fei.getExternalIdentifier().add(f2);
fei.getExternalIdentifier().add(f3);
break;
case 2:
ExternalID f4 = new ExternalID();
f4.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f4.setValue("C");
ExternalID f5 = new ExternalID();
f5.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f5.setValue("D");
ExternalID f6 = new ExternalID();
f6.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f6.setValue("E");
fei.getExternalIdentifier().add(f4);
fei.getExternalIdentifier().add(f5);
fei.getExternalIdentifier().add(f6);
break;
case 3:
ExternalID f7 = new ExternalID();
f7.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f7.setValue("X");
ExternalID f8 = new ExternalID();
f8.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f8.setValue("Y");
ExternalID f9 = new ExternalID();
f9.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f9.setValue("Z");
fei.getExternalIdentifier().add(f7);
fei.getExternalIdentifier().add(f8);
fei.getExternalIdentifier().add(f9);
break;
case 4:
ExternalID f10 = new ExternalID();
f10.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f10.setValue("Y");
ExternalID f11 = new ExternalID();
f11.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f11.setValue("B");
ExternalID f12 = new ExternalID();
f12.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f12.setValue("1");
fei.getExternalIdentifier().add(f10);
fei.getExternalIdentifier().add(f11);
fei.getExternalIdentifier().add(f12);
break;
case 5:
ExternalID f13 = new ExternalID();
f13.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f13.setValue("M");
ExternalID f14 = new ExternalID();
f14.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f14.setValue("N");
ExternalID f15 = new ExternalID();
f15.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f15.setValue("O");
fei.getExternalIdentifier().add(f13);
fei.getExternalIdentifier().add(f14);
fei.getExternalIdentifier().add(f15);
break;
case 6:
ExternalID f16 = new ExternalID();
f16.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f16.setValue("O");
ExternalID f17 = new ExternalID();
f17.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f17.setValue("P");
ExternalID f18 = new ExternalID();
f18.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f18.setValue("Q");
fei.getExternalIdentifier().add(f16);
fei.getExternalIdentifier().add(f17);
fei.getExternalIdentifier().add(f18);
break;
case 7:
ExternalID f19 = new ExternalID();
f19.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f19.setValue("1");
ExternalID f20 = new ExternalID();
f20.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f20.setValue("2");
ExternalID f21 = new ExternalID();
f21.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
f21.setValue("B");
fei.getExternalIdentifier().add(f19);
fei.getExternalIdentifier().add(f20);
fei.getExternalIdentifier().add(f21);
break;
}
funding.setExternalIdentifiers(fei);
result.put(name, funding);
}
return result;
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getFundingMapperFacade.
public MapperFacade getFundingMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ConverterFactory converterFactory = mapperFactory.getConverterFactory();
converterFactory.registerConverter("fundingExternalIdentifiersConverterId", new JSONFundingExternalIdentifiersConverterV3());
converterFactory.registerConverter("fundingContributorsConverterId", new JsonOrikaConverter<FundingContributors>());
ClassMapBuilder<Funding, ProfileFundingEntity> fundingClassMap = mapperFactory.classMap(Funding.class, ProfileFundingEntity.class);
addV3CommonFields(fundingClassMap);
registerSourceConverters(mapperFactory, fundingClassMap);
fundingClassMap.field("type", "type");
fundingClassMap.field("organizationDefinedType.content", "organizationDefinedType");
fundingClassMap.field("title.title.content", "title");
fundingClassMap.field("title.translatedTitle.content", "translatedTitle");
fundingClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
fundingClassMap.field("description", "description");
fundingClassMap.field("amount.content", "numericAmount");
fundingClassMap.field("amount.currencyCode", "currencyCode");
fundingClassMap.field("url.value", "url");
fundingClassMap.fieldBToA("org.name", "organization.name");
fundingClassMap.fieldBToA("org.city", "organization.address.city");
fundingClassMap.fieldBToA("org.region", "organization.address.region");
fundingClassMap.fieldBToA("org.country", "organization.address.country");
fundingClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
fundingClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
fundingClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
fundingClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("fundingExternalIdentifiersConverterId").add();
fundingClassMap.fieldMap("contributors", "contributorsJson").converter("fundingContributorsConverterId").add();
fundingClassMap.register();
ClassMapBuilder<FundingSummary, ProfileFundingEntity> fundingSummaryClassMap = mapperFactory.classMap(FundingSummary.class, ProfileFundingEntity.class);
addV3CommonFields(fundingSummaryClassMap);
registerSourceConverters(mapperFactory, fundingSummaryClassMap);
fundingSummaryClassMap.field("type", "type");
fundingSummaryClassMap.field("title.title.content", "title");
fundingSummaryClassMap.field("title.translatedTitle.content", "translatedTitle");
fundingSummaryClassMap.field("title.translatedTitle.languageCode", "translatedTitleLanguageCode");
fundingSummaryClassMap.fieldMap("externalIdentifiers", "externalIdentifiersJson").converter("fundingExternalIdentifiersConverterId").add();
fundingSummaryClassMap.fieldBToA("org.name", "organization.name");
fundingSummaryClassMap.fieldBToA("org.city", "organization.address.city");
fundingSummaryClassMap.fieldBToA("org.region", "organization.address.region");
fundingSummaryClassMap.fieldBToA("org.country", "organization.address.country");
fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceId", "organization.disambiguatedOrganization.disambiguatedOrganizationIdentifier");
fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.sourceType", "organization.disambiguatedOrganization.disambiguationSource");
fundingSummaryClassMap.fieldBToA("org.orgDisambiguated.id", "organization.disambiguatedOrganization.id");
fundingSummaryClassMap.register();
mapperFactory.classMap(FuzzyDate.class, StartDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
mapperFactory.classMap(FuzzyDate.class, EndDateEntity.class).field("year.value", "year").field("month.value", "month").field("day.value", "day").register();
return mapperFactory.getMapperFacade();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary in project ORCID-Source by ORCID.
the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_SomePrivate_NoSource_ReadLimitedToken.
@Test
public void testActivitiesSummary_When_SomePrivate_NoSource_ReadLimitedToken() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.ACTIVITIES_READ_LIMITED);
DistinctionSummary d1 = createDistinctionSummary(Visibility.PUBLIC, CLIENT_2);
DistinctionSummary d2 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
DistinctionSummary d3 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
EducationSummary e2 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
InvitedPositionSummary i1 = createInvitedPositionSummary(Visibility.PUBLIC, CLIENT_2);
InvitedPositionSummary i2 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
InvitedPositionSummary i3 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
MembershipSummary m1 = createMembershipSummary(Visibility.PUBLIC, CLIENT_2);
MembershipSummary m2 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
MembershipSummary m3 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
QualificationSummary q1 = createQualificationSummary(Visibility.PUBLIC, CLIENT_2);
QualificationSummary q2 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
QualificationSummary q3 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
ServiceSummary s1 = createServiceSummary(Visibility.PUBLIC, CLIENT_2);
ServiceSummary s2 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
ServiceSummary s3 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(e1, e2, e3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
as.setDistinctions(createDistinctions(d1, d2, d3));
as.setInvitedPositions(createInvitedPositions(i1, i2, i3));
as.setMemberships(createMemberships(m1, m2, m3));
as.setQualifications(createQualifications(q1, q2, q3));
as.setServices(createServices(s1, s2, s3));
orcidSecurityManager.checkAndFilter(ORCID_1, as);
assertNotNull(as);
// Check distinctions
assertEquals(1, as.getDistinctions().getSummaries().size());
assertTrue(as.getDistinctions().getSummaries().contains(d1));
assertFalse(as.getDistinctions().getSummaries().contains(d2));
assertFalse(as.getDistinctions().getSummaries().contains(d3));
// Check invited positions
assertEquals(1, as.getInvitedPositions().getSummaries().size());
assertTrue(as.getInvitedPositions().getSummaries().contains(i1));
assertFalse(as.getInvitedPositions().getSummaries().contains(i2));
assertFalse(as.getInvitedPositions().getSummaries().contains(i3));
// Check memberships
assertEquals(1, as.getMemberships().getSummaries().size());
assertTrue(as.getMemberships().getSummaries().contains(m1));
assertFalse(as.getMemberships().getSummaries().contains(m2));
assertFalse(as.getMemberships().getSummaries().contains(m3));
// Check qualifications
assertEquals(1, as.getQualifications().getSummaries().size());
assertTrue(as.getQualifications().getSummaries().contains(q1));
assertFalse(as.getQualifications().getSummaries().contains(q2));
assertFalse(as.getQualifications().getSummaries().contains(q3));
// Check services
assertEquals(1, as.getServices().getSummaries().size());
assertTrue(as.getServices().getSummaries().contains(s1));
assertFalse(as.getServices().getSummaries().contains(s2));
assertFalse(as.getServices().getSummaries().contains(s3));
// Check educations
assertEquals(1, as.getEducations().getSummaries().size());
assertTrue(as.getEducations().getSummaries().contains(e1));
assertFalse(as.getEducations().getSummaries().contains(e2));
assertFalse(as.getEducations().getSummaries().contains(e3));
// Check employments
assertEquals(1, as.getEmployments().getSummaries().size());
assertTrue(as.getEmployments().getSummaries().contains(em1));
assertFalse(as.getEmployments().getSummaries().contains(em2));
assertFalse(as.getEmployments().getSummaries().contains(em3));
// Check fundings
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getActivities().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
assertEquals(2, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
// Check peer reviews
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
// Check works
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getActivities().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
assertEquals(2, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary in project ORCID-Source by ORCID.
the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AffiliationsReadLimited_And_NotSource.
@Test
public void testActivitiesSummary_When_AffiliationsReadLimited_And_NotSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.AFFILIATIONS_READ_LIMITED);
DistinctionSummary d1 = createDistinctionSummary(Visibility.PUBLIC, CLIENT_2);
DistinctionSummary d2 = createDistinctionSummary(Visibility.LIMITED, CLIENT_2);
DistinctionSummary d3 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
EducationSummary e2 = createEducationSummary(Visibility.LIMITED, CLIENT_2);
EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.LIMITED, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
InvitedPositionSummary i1 = createInvitedPositionSummary(Visibility.PUBLIC, CLIENT_2);
InvitedPositionSummary i2 = createInvitedPositionSummary(Visibility.LIMITED, CLIENT_2);
InvitedPositionSummary i3 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
MembershipSummary m1 = createMembershipSummary(Visibility.PUBLIC, CLIENT_2);
MembershipSummary m2 = createMembershipSummary(Visibility.LIMITED, CLIENT_2);
MembershipSummary m3 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
QualificationSummary q1 = createQualificationSummary(Visibility.PUBLIC, CLIENT_2);
QualificationSummary q2 = createQualificationSummary(Visibility.LIMITED, CLIENT_2);
QualificationSummary q3 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
ServiceSummary s1 = createServiceSummary(Visibility.PUBLIC, CLIENT_2);
ServiceSummary s2 = createServiceSummary(Visibility.LIMITED, CLIENT_2);
ServiceSummary s3 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(e1, e2, e3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
as.setDistinctions(createDistinctions(d1, d2, d3));
as.setInvitedPositions(createInvitedPositions(i1, i2, i3));
as.setMemberships(createMemberships(m1, m2, m3));
as.setQualifications(createQualifications(q1, q2, q3));
as.setServices(createServices(s1, s2, s3));
orcidSecurityManager.checkAndFilter(ORCID_1, as);
assertNotNull(as);
// Check distinctions
assertEquals(2, as.getDistinctions().getSummaries().size());
assertTrue(as.getDistinctions().getSummaries().contains(d1));
assertTrue(as.getDistinctions().getSummaries().contains(d2));
assertFalse(as.getDistinctions().getSummaries().contains(d3));
// Check invited positions
assertEquals(2, as.getInvitedPositions().getSummaries().size());
assertTrue(as.getInvitedPositions().getSummaries().contains(i1));
assertTrue(as.getInvitedPositions().getSummaries().contains(i2));
assertFalse(as.getInvitedPositions().getSummaries().contains(i3));
// Check memberships
assertEquals(2, as.getMemberships().getSummaries().size());
assertTrue(as.getMemberships().getSummaries().contains(m1));
assertTrue(as.getMemberships().getSummaries().contains(m2));
assertFalse(as.getMemberships().getSummaries().contains(m3));
// Check qualifications
assertEquals(2, as.getQualifications().getSummaries().size());
assertTrue(as.getQualifications().getSummaries().contains(q1));
assertTrue(as.getQualifications().getSummaries().contains(q2));
assertFalse(as.getQualifications().getSummaries().contains(q3));
// Check services
assertEquals(2, as.getServices().getSummaries().size());
assertTrue(as.getServices().getSummaries().contains(s1));
assertTrue(as.getServices().getSummaries().contains(s2));
assertFalse(as.getServices().getSummaries().contains(s3));
// Check it have limited Educations
assertNotNull(as.getEducations());
assertEquals(2, as.getEducations().getSummaries().size());
assertTrue(as.getEducations().getSummaries().contains(e1));
assertTrue(as.getEducations().getSummaries().contains(e2));
assertFalse(as.getEducations().getSummaries().contains(e3));
// Check it have limited Employments
assertNotNull(as.getEmployments());
assertEquals(2, as.getEmployments().getSummaries().size());
assertTrue(as.getEmployments().getSummaries().contains(em1));
assertTrue(as.getEmployments().getSummaries().contains(em2));
assertFalse(as.getEmployments().getSummaries().contains(em3));
// Check it have only public funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getActivities().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
assertEquals(2, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
// Check it have only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
// Check it have only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getActivities().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
assertEquals(2, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary in project ORCID-Source by ORCID.
the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AllReadLimited_And_NotSource.
@Test
public void testActivitiesSummary_When_AllReadLimited_And_NotSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.AFFILIATIONS_READ_LIMITED, ScopePathType.FUNDING_READ_LIMITED, ScopePathType.PEER_REVIEW_READ_LIMITED, ScopePathType.ORCID_WORKS_READ_LIMITED);
DistinctionSummary d1 = createDistinctionSummary(Visibility.PUBLIC, CLIENT_2);
DistinctionSummary d2 = createDistinctionSummary(Visibility.LIMITED, CLIENT_2);
DistinctionSummary d3 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
EducationSummary e1 = createEducationSummary(Visibility.PUBLIC, CLIENT_2);
EducationSummary e2 = createEducationSummary(Visibility.LIMITED, CLIENT_2);
EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
EmploymentSummary em1 = createEmploymentSummary(Visibility.PUBLIC, CLIENT_2);
EmploymentSummary em2 = createEmploymentSummary(Visibility.LIMITED, CLIENT_2);
EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
InvitedPositionSummary i1 = createInvitedPositionSummary(Visibility.PUBLIC, CLIENT_2);
InvitedPositionSummary i2 = createInvitedPositionSummary(Visibility.LIMITED, CLIENT_2);
InvitedPositionSummary i3 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
MembershipSummary m1 = createMembershipSummary(Visibility.PUBLIC, CLIENT_2);
MembershipSummary m2 = createMembershipSummary(Visibility.LIMITED, CLIENT_2);
MembershipSummary m3 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
QualificationSummary q1 = createQualificationSummary(Visibility.PUBLIC, CLIENT_2);
QualificationSummary q2 = createQualificationSummary(Visibility.LIMITED, CLIENT_2);
QualificationSummary q3 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
ServiceSummary s1 = createServiceSummary(Visibility.PUBLIC, CLIENT_2);
ServiceSummary s2 = createServiceSummary(Visibility.LIMITED, CLIENT_2);
ServiceSummary s3 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
FundingSummary f1 = createFundingSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
FundingSummary f2 = createFundingSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
PeerReviewSummary p2 = createPeerReviewSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
WorkSummary w1 = createWorkSummary(Visibility.PUBLIC, CLIENT_2, EXTID_1);
WorkSummary w2 = createWorkSummary(Visibility.LIMITED, CLIENT_2, EXTID_2);
WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
ActivitiesSummary as = new ActivitiesSummary();
as.setEducations(createEducations(e1, e2, e3));
as.setEmployments(createEmployments(em1, em2, em3));
as.setFundings(createFundings(f1, f2, f3));
as.setPeerReviews(createPeerReviews(p1, p2, p3));
as.setWorks(createWorks(w1, w2, w3));
as.setDistinctions(createDistinctions(d1, d2, d3));
as.setInvitedPositions(createInvitedPositions(i1, i2, i3));
as.setMemberships(createMemberships(m1, m2, m3));
as.setQualifications(createQualifications(q1, q2, q3));
as.setServices(createServices(s1, s2, s3));
orcidSecurityManager.checkAndFilter(ORCID_1, as);
// Check distinctions
assertEquals(2, as.getDistinctions().getSummaries().size());
assertTrue(as.getDistinctions().getSummaries().contains(d1));
assertTrue(as.getDistinctions().getSummaries().contains(d2));
assertFalse(as.getDistinctions().getSummaries().contains(d3));
// Check invited positions
assertEquals(2, as.getInvitedPositions().getSummaries().size());
assertTrue(as.getInvitedPositions().getSummaries().contains(i1));
assertTrue(as.getInvitedPositions().getSummaries().contains(i2));
assertFalse(as.getInvitedPositions().getSummaries().contains(i3));
// Check memberships
assertEquals(2, as.getMemberships().getSummaries().size());
assertTrue(as.getMemberships().getSummaries().contains(m1));
assertTrue(as.getMemberships().getSummaries().contains(m2));
assertFalse(as.getMemberships().getSummaries().contains(m3));
// Check qualifications
assertEquals(2, as.getQualifications().getSummaries().size());
assertTrue(as.getQualifications().getSummaries().contains(q1));
assertTrue(as.getQualifications().getSummaries().contains(q2));
assertFalse(as.getQualifications().getSummaries().contains(q3));
// Check services
assertEquals(2, as.getServices().getSummaries().size());
assertTrue(as.getServices().getSummaries().contains(s1));
assertTrue(as.getServices().getSummaries().contains(s2));
assertFalse(as.getServices().getSummaries().contains(s3));
// Check it have limited Educations
assertNotNull(as.getEducations());
assertEquals(2, as.getEducations().getSummaries().size());
assertTrue(as.getEducations().getSummaries().contains(e1));
assertTrue(as.getEducations().getSummaries().contains(e2));
assertFalse(as.getEducations().getSummaries().contains(e3));
// Check it have limited Employments
assertNotNull(as.getEmployments());
assertEquals(2, as.getEmployments().getSummaries().size());
assertTrue(as.getEmployments().getSummaries().contains(em1));
assertTrue(as.getEmployments().getSummaries().contains(em2));
assertFalse(as.getEmployments().getSummaries().contains(em3));
// Check it have limited funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(2, as.getFundings().getFundingGroup().get(0).getActivities().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f1));
assertTrue(as.getFundings().getFundingGroup().get(0).getActivities().contains(f2));
assertFalse(as.getFundings().getFundingGroup().get(0).getActivities().contains(f3));
assertEquals(3, as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getFundings().getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
// Check it have limited reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(2, as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p1));
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p2));
assertFalse(as.getPeerReviews().getPeerReviewGroup().get(0).getActivities().contains(p3));
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED, "peer-review")));
// Check it have limited works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(2, as.getWorks().getWorkGroup().get(0).getActivities().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w1));
assertTrue(as.getWorks().getWorkGroup().get(0).getActivities().contains(w2));
assertFalse(as.getWorks().getWorkGroup().get(0).getActivities().contains(w3));
assertEquals(3, as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_1)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_2)));
assertFalse(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_3)));
assertTrue(as.getWorks().getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().contains(getExtId(EXTID_SHARED)));
}
Aggregations