use of org.orcid.jaxb.model.record.summary_v2.FundingSummary in project ORCID-Source by ORCID.
the class SourceUtils method setSourceName.
public void setSourceName(ActivitiesSummary as) {
if (as == null) {
return;
}
if (as.getEducations() != null) {
Educations educations = as.getEducations();
List<EducationSummary> list = educations.getSummaries();
if (list != null) {
for (EducationSummary summary : list) {
setSourceName(summary);
}
}
}
if (as.getEmployments() != null) {
Employments employments = as.getEmployments();
List<EmploymentSummary> list = employments.getSummaries();
if (list != null) {
for (EmploymentSummary summary : list) {
setSourceName(summary);
}
}
}
if (as.getFundings() != null) {
Fundings fundings = as.getFundings();
List<FundingGroup> groups = fundings.getFundingGroup();
if (groups != null) {
for (FundingGroup group : groups) {
List<FundingSummary> summaryList = group.getFundingSummary();
if (summaryList != null) {
for (FundingSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
if (as.getPeerReviews() != null) {
PeerReviews peerReviews = as.getPeerReviews();
List<PeerReviewGroup> groups = peerReviews.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup group : groups) {
List<PeerReviewSummary> summaryList = group.getPeerReviewSummary();
if (summaryList != null) {
for (PeerReviewSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
if (as.getWorks() != null) {
Works works = as.getWorks();
List<WorkGroup> groups = works.getWorkGroup();
if (groups != null) {
for (WorkGroup group : groups) {
List<WorkSummary> summaryList = group.getWorkSummary();
if (summaryList != null) {
for (WorkSummary summary : summaryList) {
setSourceName(summary);
}
}
}
}
}
}
use of org.orcid.jaxb.model.record.summary_v2.FundingSummary in project ORCID-Source by ORCID.
the class JpaJaxbFundingAdapterTest method fromFundingEntityToSummaryTest.
@Test
public void fromFundingEntityToSummaryTest() throws JAXBException {
ProfileFundingEntity entity = getProfileFundingEntity();
assertNotNull(entity);
assertEquals("123456", entity.getNumericAmount().toString());
FundingSummary summary = jpaJaxbFundingAdapter.toFundingSummary(entity);
assertNotNull(summary);
assertEquals(Long.valueOf(12345), summary.getPutCode());
assertNotNull(summary.getStartDate());
assertEquals("01", summary.getStartDate().getDay().getValue());
assertEquals("01", summary.getStartDate().getMonth().getValue());
assertEquals("2000", summary.getStartDate().getYear().getValue());
assertNotNull(summary.getEndDate());
assertEquals("01", summary.getEndDate().getDay().getValue());
assertEquals("01", summary.getEndDate().getMonth().getValue());
assertEquals("2020", summary.getEndDate().getYear().getValue());
assertEquals("funding:title", summary.getTitle().getTitle().getContent());
assertEquals(FundingType.SALARY_AWARD, summary.getType());
assertEquals(Visibility.PRIVATE, summary.getVisibility());
}
use of org.orcid.jaxb.model.record.summary_v2.FundingSummary in project ORCID-Source by ORCID.
the class ProfileFundingManagerTest method testGroupFundings_groupOnlyPublicFundings1.
@Test
public void testGroupFundings_groupOnlyPublicFundings1() {
FundingSummary s1 = getFundingSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
FundingSummary s2 = getFundingSummary("Limited 1", "ext-id-2", Visibility.LIMITED);
FundingSummary s3 = getFundingSummary("Private 1", "ext-id-3", Visibility.PRIVATE);
FundingSummary s4 = getFundingSummary("Public 2", "ext-id-4", Visibility.PUBLIC);
FundingSummary s5 = getFundingSummary("Limited 2", "ext-id-5", Visibility.LIMITED);
FundingSummary s6 = getFundingSummary("Private 2", "ext-id-6", Visibility.PRIVATE);
FundingSummary s7 = getFundingSummary("Public 3", "ext-id-7", Visibility.PUBLIC);
FundingSummary s8 = getFundingSummary("Limited 3", "ext-id-8", Visibility.LIMITED);
FundingSummary s9 = getFundingSummary("Private 3", "ext-id-9", Visibility.PRIVATE);
List<FundingSummary> fundingList = 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
* */
Fundings fundings = profileFundingManager.groupFundings(fundingList, true);
assertNotNull(fundings);
assertEquals(3, fundings.getFundingGroup().size());
assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
assertEquals("ext-id-1", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("Public 1", fundings.getFundingGroup().get(0).getFundingSummary().get(0).getTitle().getTitle().getContent());
assertEquals(1, fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().size());
assertEquals(1, fundings.getFundingGroup().get(1).getFundingSummary().size());
assertEquals("ext-id-4", fundings.getFundingGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("Public 2", fundings.getFundingGroup().get(1).getFundingSummary().get(0).getTitle().getTitle().getContent());
assertEquals(1, fundings.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().size());
assertEquals(1, fundings.getFundingGroup().get(2).getFundingSummary().size());
assertEquals("ext-id-7", fundings.getFundingGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
assertEquals("Public 3", fundings.getFundingGroup().get(2).getFundingSummary().get(0).getTitle().getTitle().getContent());
}
use of org.orcid.jaxb.model.record.summary_v2.FundingSummary in project ORCID-Source by ORCID.
the class PublicV2Test method checkFunding.
private void checkFunding(String readPublicToken) throws JSONException, InterruptedException, URISyntaxException {
Funding fundingToCreate = (Funding) unmarshallFromPath("/record_2.0_rc1/samples/funding-2.0_rc1.xml", Funding.class);
fundingToCreate.setPutCode(null);
fundingToCreate.setVisibility(org.orcid.jaxb.model.common_rc1.Visibility.PUBLIC);
String accessToken = getAccessToken();
ClientResponse postResponse = memberV2ApiClient.createFundingXml(getUser1OrcidId(), fundingToCreate, accessToken);
assertNotNull(postResponse);
assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
String path = postResponse.getLocation().getPath();
String putCode = path.substring(path.lastIndexOf('/') + 1, path.length());
ClientResponse getFundingResponse = null;
if (readPublicToken != null) {
getFundingResponse = publicV2ApiClient.viewFundingXml(getUser1OrcidId(), putCode, readPublicToken);
} else {
getFundingResponse = publicV2ApiClient.viewFundingXml(getUser1OrcidId(), putCode);
}
assertNotNull(getFundingResponse);
checkResponse(getFundingResponse);
Funding funding = getFundingResponse.getEntity(Funding.class);
assertNotNull(funding);
assertEquals("common:title", funding.getTitle().getTitle().getContent());
ClientResponse getFundingSummaryResponse = null;
if (readPublicToken != null) {
getFundingSummaryResponse = publicV2ApiClient.viewFundingSummaryXml(getUser1OrcidId(), putCode, readPublicToken);
} else {
getFundingSummaryResponse = publicV2ApiClient.viewFundingSummaryXml(getUser1OrcidId(), putCode);
}
assertNotNull(getFundingSummaryResponse);
checkResponse(getFundingSummaryResponse);
FundingSummary summary = getFundingSummaryResponse.getEntity(FundingSummary.class);
assertNotNull(summary);
assertEquals("common:title", summary.getTitle().getTitle().getContent());
}
use of org.orcid.jaxb.model.record.summary_v2.FundingSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method viewFundingSummary.
@Override
public Response viewFundingSummary(String orcid, Long putCode) {
FundingSummary fs = profileFundingManagerReadOnly.getSummary(orcid, putCode);
orcidSecurityManager.checkAndFilter(orcid, fs, ScopePathType.FUNDING_READ_LIMITED);
ActivityUtils.setPathToActivity(fs, orcid);
sourceUtils.setSourceName(fs);
return Response.ok(fs).build();
}
Aggregations