use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method viewFunding.
@Override
public Response viewFunding(String orcid, Long putCode) {
Funding f = profileFundingManagerReadOnly.getFunding(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, f, ScopePathType.FUNDING_READ_LIMITED);
ActivityUtils.setPathToActivity(f, orcid);
ActivityUtils.cleanEmptyFields(f);
sourceUtils.setSourceName(f);
contributorUtils.filterContributorPrivateData(f);
return Response.ok(f).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegatorImpl method createFunding.
@Override
public Response createFunding(String orcid, Funding funding) {
orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.FUNDING_CREATE, ScopePathType.FUNDING_UPDATE);
clearSource(funding);
Funding f = profileFundingManager.createFunding(orcid, funding, true);
sourceUtils.setSourceName(f);
try {
return Response.created(new URI(String.valueOf(f.getPutCode()))).build();
} catch (URISyntaxException e) {
throw new RuntimeException(localeManager.resolveMessage("apiError.createfunding_response.exception"), e);
}
}
use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_PeerReviewReadLimited_NoSource.
@Test
public void testViewActitivies_PeerReviewReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.PEER_REVIEW_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Only public educations
assertNotNull(as.getEducations());
assertEquals(1, as.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
// Only public employments
assertNotNull(as.getEmployments());
assertEquals(1, as.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
// Only public funding
assertNotNull(as.getFundings());
assertEquals(1, as.getFundings().getFundingGroup().size());
assertEquals(1, as.getFundings().getFundingGroup().get(0).getFundingSummary().size());
assertEquals(Long.valueOf(10), as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getVisibility());
// Limited peer reviews
boolean found1 = false, found2 = false, found3 = false;
assertNotNull(as.getPeerReviews());
assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
assertEquals(1, group.getPeerReviewSummary().size());
PeerReviewSummary element = group.getPeerReviewSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(9))) {
assertEquals(Visibility.PUBLIC, element.getVisibility());
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(10))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(12))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies_FundingReadLimited_NoSource.
@Test
public void testViewActitivies_FundingReadLimited_NoSource() {
SecurityContextTestUtils.setUpSecurityContext(ORCID, "APP-5555555555555556", ScopePathType.FUNDING_READ_LIMITED);
Response response = serviceDelegator.viewActivities(ORCID);
ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
assertNotNull(as);
assertNotNull(as.getPath());
Utils.verifyLastModified(as.getLastModifiedDate());
// Only public educations
assertNotNull(as.getEducations());
assertEquals(1, as.getEducations().getSummaries().size());
assertEquals(Long.valueOf(20), as.getEducations().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEducations().getSummaries().get(0).getVisibility());
// Only public employments
assertNotNull(as.getEmployments());
assertEquals(1, as.getEmployments().getSummaries().size());
assertEquals(Long.valueOf(17), as.getEmployments().getSummaries().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getEmployments().getSummaries().get(0).getVisibility());
// Limited funding
boolean found1 = false, found2 = false, found3 = false;
assertNotNull(as.getFundings());
assertEquals(3, as.getFundings().getFundingGroup().size());
for (FundingGroup group : as.getFundings().getFundingGroup()) {
assertEquals(1, group.getFundingSummary().size());
FundingSummary element = group.getFundingSummary().get(0);
if (element.getPutCode().equals(Long.valueOf(10))) {
assertEquals(Visibility.PUBLIC, element.getVisibility());
found1 = true;
} else if (element.getPutCode().equals(Long.valueOf(11))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found2 = true;
} else if (element.getPutCode().equals(Long.valueOf(13))) {
assertEquals(Visibility.LIMITED, element.getVisibility());
found3 = true;
} else {
fail("Invalid put code " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
// Only public peer reviews
assertNotNull(as.getPeerReviews());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().size());
assertEquals(1, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
assertEquals(Long.valueOf(9), as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
// Only public works
assertNotNull(as.getWorks());
assertEquals(1, as.getWorks().getWorkGroup().size());
assertEquals(1, as.getWorks().getWorkGroup().get(0).getWorkSummary().size());
assertEquals(Long.valueOf(11), as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getPutCode());
assertEquals(Visibility.PUBLIC, as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.Funding in project ORCID-Source by ORCID.
the class MemberV3ApiServiceDelegator_FundingTest method testUpdateFundingYouAreNotTheSourceOf.
@Test(expected = WrongSourceException.class)
public void testUpdateFundingYouAreNotTheSourceOf() {
SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
Response response = serviceDelegator.viewFunding("4444-4444-4444-4446", 5L);
assertNotNull(response);
Funding funding = (Funding) response.getEntity();
assertNotNull(funding);
funding.getTitle().getTitle().setContent("Updated funding title");
ExternalID fExtId = new ExternalID();
fExtId.setRelationship(Relationship.PART_OF);
fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
fExtId.setUrl(new Url("http://fundingExtId.com"));
fExtId.setValue("new-funding-ext-id");
ExternalIDs fExtIds = new ExternalIDs();
fExtIds.getExternalIdentifier().add(fExtId);
funding.setExternalIdentifiers(fExtIds);
serviceDelegator.updateFunding("4444-4444-4444-4446", 5L, funding);
fail();
}
Aggregations