use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class PublicV3ApiServiceDelegatorImpl method viewFundings.
@Override
public Response viewFundings(String orcid) {
List<FundingSummary> fundings = profileFundingManagerReadOnly.getFundingSummaryList(orcid);
Fundings publicFundings = profileFundingManagerReadOnly.groupFundings(fundings, true);
publicAPISecurityManagerV3.filter(publicFundings);
ActivityUtils.setPathToFundings(publicFundings, orcid);
Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicFundings);
sourceUtilsReadOnly.setSourceName(publicFundings);
return Response.ok(publicFundings).build();
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_4GroupsOf1Funding_Test.
@Test
public void groupFundings_4GroupsOf1Funding_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, FundingSummary> fundings = generateFundings();
// Group the first group
// funding-2 -> C, D, E
FundingSummary funding2 = fundings.get("funding-2");
generator.group(funding2);
// There should be one group, and the ext ids should be A, B and C
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(1, groups.size());
ActivitiesGroup g1 = groups.get(0);
assertNotNull(g1);
assertNotNull(g1.getActivities());
assertEquals(1, g1.getActivities().size());
assertTrue(g1.getActivities().contains(funding2));
assertNotNull(g1.getGroupKeys());
assertEquals(3, g1.getGroupKeys().size());
checkExternalIdentifiers(funding2, g1);
// Add another funding to the groups
// funding-5 -> M, N, O
FundingSummary funding5 = fundings.get("funding-5");
generator.group(funding5);
// There should be two groups, one for each funding
groups = generator.getGroups();
assertNotNull(groups);
assertEquals(2, groups.size());
// There should be one activity in each group
assertEquals(1, groups.get(0).getActivities().size());
assertEquals(1, groups.get(1).getActivities().size());
// There should be 3 ext ids in each group
assertEquals(3, groups.get(0).getGroupKeys().size());
assertEquals(3, groups.get(1).getGroupKeys().size());
// Check funding in groups
checkActivityIsOnGroups(funding5, groups);
// Add another funding to the groups
// funding-7 -> 1, 2, B
FundingSummary funding7 = fundings.get("funding-7");
generator.group(funding7);
groups = generator.getGroups();
assertNotNull(groups);
assertEquals(3, groups.size());
// There should be one activity in each group
assertEquals(1, groups.get(0).getActivities().size());
assertEquals(1, groups.get(1).getActivities().size());
assertEquals(1, groups.get(2).getActivities().size());
// There should be 3 ext ids in each group
assertEquals(3, groups.get(0).getGroupKeys().size());
assertEquals(3, groups.get(1).getGroupKeys().size());
assertEquals(3, groups.get(2).getGroupKeys().size());
// Check funding in groups
checkActivityIsOnGroups(funding7, groups);
// Add another funding to the groups
// funding-8 -> No external identifiers
FundingSummary funding8 = fundings.get("funding-8");
generator.group(funding8);
groups = generator.getGroups();
assertNotNull(groups);
assertEquals(4, groups.size());
// There should be one activity in each group
assertEquals(1, groups.get(0).getActivities().size());
assertEquals(1, groups.get(1).getActivities().size());
assertEquals(1, groups.get(2).getActivities().size());
assertEquals(1, groups.get(3).getActivities().size());
// There should be 3 ext ids in each group, except for one group that doesnt have any ext id
boolean funding8found = false;
for (int i = 0; i < 4; i++) {
if (groups.get(i).getGroupKeys().size() == 0) {
funding8found = true;
} else {
assertEquals(3, groups.get(i).getGroupKeys().size());
}
}
assertTrue("FundingSummary without ext ids was not found", funding8found);
// Check funding in groups
checkActivityIsOnGroups(funding8, groups);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_MergeGroupsDontAffectNotMergedGroups_Test.
/**
* funding-1, funding-3, funding-5 and funding-8 will be in separate groups
* then funding-4 will merge groups of funding-1 and funding-3
*
* Check that after that, there are 3 groups, one with funding-1, funding-3 and funding-4, one with funding-5 and other with funding-8
*/
@Test
public void groupFundings_MergeGroupsDontAffectNotMergedGroups_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, FundingSummary> fundings = generateFundings();
// Group the first group
FundingSummary funding1 = fundings.get("funding-1");
FundingSummary funding3 = fundings.get("funding-3");
FundingSummary funding4 = fundings.get("funding-4");
FundingSummary funding5 = fundings.get("funding-5");
FundingSummary funding8 = fundings.get("funding-8");
// Respect order
generator.group(funding1);
generator.group(funding3);
generator.group(funding5);
generator.group(funding8);
generator.group(funding4);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(3, groups.size());
// Check funding1, funding3 and funding4 belongs to the same group
checkActivitiesBelongsToTheSameGroup(groups, funding1, funding3, funding4);
// Check funding1, funding5 and funding8 are all in different groups
checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding5, funding8);
checkActivityIsOnGroups(funding1, groups);
checkActivityIsOnGroups(funding3, groups);
checkActivityIsOnGroups(funding4, groups);
checkActivityIsOnGroups(funding5, groups);
checkActivityIsOnGroups(funding8, groups);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingFundingsTest method groupFundings_MergeTwoGroups_Test.
/**
* funding-1 and funding-3 will be in different groups
* then funding-2 will go to the same group as funding-1
* then funding-4 contains Y and B so, the two groups should be merged
*/
@Test
public void groupFundings_MergeTwoGroups_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, FundingSummary> fundings = generateFundings();
// Group the first group
FundingSummary funding1 = fundings.get("funding-1");
FundingSummary funding2 = fundings.get("funding-2");
FundingSummary funding3 = fundings.get("funding-3");
FundingSummary funding4 = fundings.get("funding-4");
generator.group(funding1);
generator.group(funding2);
generator.group(funding3);
/**
* At this point there are two groups
* G1 with funding1 and funding2
* G2 with funding3
*/
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(2, groups.size());
checkActivitiesBelongsToTheSameGroup(groups, funding1, funding2);
checkActivitiesDontBelongsToTheSameGroup(groups, funding1, funding3);
checkActivitiesDontBelongsToTheSameGroup(groups, funding2, funding3);
// group funding4, which should merge the two groups
generator.group(funding4);
groups = generator.getGroups();
assertNotNull(groups);
assertEquals(1, groups.size());
assertEquals(4, groups.get(0).getActivities().size());
assertEquals(9, groups.get(0).getGroupKeys().size());
checkActivityIsOnGroups(funding1, groups);
checkActivityIsOnGroups(funding2, groups);
checkActivityIsOnGroups(funding3, groups);
checkActivityIsOnGroups(funding4, groups);
checkActivitiesBelongsToTheSameGroup(groups, funding1, funding2, funding3, funding4);
}
use of org.orcid.jaxb.model.v3.dev1.record.summary.Fundings in project ORCID-Source by ORCID.
the class GetMyDataControllerTest method before.
@Before
public void before() {
MockitoAnnotations.initMocks(this);
TargetProxyHelper.injectIntoProxy(getMyDataController, "batchSize", 50);
TargetProxyHelper.injectIntoProxy(getMyDataController, "personDetailsManager", mockPersonDetailsManager);
TargetProxyHelper.injectIntoProxy(getMyDataController, "workEntityCacheManager", mockWorkEntityCacheManager);
TargetProxyHelper.injectIntoProxy(getMyDataController, "affiliationManagerReadOnly", mockAffiliationManagerReadOnly);
TargetProxyHelper.injectIntoProxy(getMyDataController, "profileFundingManagerReadOnly", mockProfileFundingManagerReadOnly);
TargetProxyHelper.injectIntoProxy(getMyDataController, "peerReviewManagerReadOnly", mockPeerReviewManagerReadOnly);
TargetProxyHelper.injectIntoProxy(getMyDataController, "workManagerReadOnly", mockWorkManagerReadOnly);
when(mockPersonDetailsManager.getPersonDetails(anyString())).thenAnswer(new Answer<Person>() {
@Override
public Person answer(InvocationOnMock invocation) throws Throwable {
Person p = new Person();
p.setBiography(new Biography("Biography", Visibility.LIMITED));
Name name = new Name();
name.setVisibility(Visibility.LIMITED);
name.setFamilyName(new FamilyName("Family Name"));
name.setGivenNames(new GivenNames("Given Names"));
name.setCreditName(new CreditName("Credit Name"));
p.setName(name);
return p;
}
});
when(mockAffiliationManagerReadOnly.getAffiliations(anyString())).thenAnswer(new Answer<List<Affiliation>>() {
@Override
public List<Affiliation> answer(InvocationOnMock invocation) throws Throwable {
List<Affiliation> affs = new ArrayList<Affiliation>();
FuzzyDate startDate = new FuzzyDate(new Year(2018), new Month(1), new Day(1));
FuzzyDate endDate = new FuzzyDate(new Year(2018), new Month(12), new Day(31));
Distinction d = new Distinction();
d.setDepartmentName("distinction");
d.setEndDate(endDate);
d.setStartDate(startDate);
d.setPutCode(1L);
setOrg(d);
affs.add(d);
Education e = new Education();
e.setDepartmentName("education");
e.setEndDate(endDate);
e.setStartDate(startDate);
e.setPutCode(2L);
setOrg(e);
affs.add(e);
Employment emp = new Employment();
emp.setDepartmentName("employment");
emp.setEndDate(endDate);
emp.setStartDate(startDate);
emp.setPutCode(3L);
setOrg(emp);
affs.add(emp);
InvitedPosition i = new InvitedPosition();
i.setDepartmentName("invited position");
i.setEndDate(endDate);
i.setStartDate(startDate);
i.setPutCode(4L);
setOrg(i);
affs.add(i);
Membership m = new Membership();
m.setDepartmentName("membership");
m.setEndDate(endDate);
m.setStartDate(startDate);
m.setPutCode(5L);
setOrg(m);
affs.add(m);
Qualification q = new Qualification();
q.setDepartmentName("qualification");
q.setEndDate(endDate);
q.setStartDate(startDate);
q.setPutCode(6L);
setOrg(q);
affs.add(q);
Service s = new Service();
s.setDepartmentName("service");
s.setEndDate(endDate);
s.setStartDate(startDate);
s.setPutCode(7L);
setOrg(s);
affs.add(s);
return affs;
}
});
when(mockProfileFundingManagerReadOnly.getFundingList(anyString())).thenAnswer(new Answer<List<Funding>>() {
@Override
public List<Funding> answer(InvocationOnMock invocation) throws Throwable {
List<Funding> fundings = new ArrayList<Funding>();
Funding f = new Funding();
Amount a = new Amount();
a.setContent("1000");
a.setCurrencyCode("$");
f.setAmount(a);
FundingTitle t = new FundingTitle();
t.setTitle(new Title("title"));
f.setTitle(t);
setOrg(f);
f.setPutCode(1L);
fundings.add(f);
return fundings;
}
});
when(mockPeerReviewManagerReadOnly.findPeerReviews(anyString())).thenAnswer(new Answer<List<PeerReview>>() {
@Override
public List<PeerReview> answer(InvocationOnMock invocation) throws Throwable {
List<PeerReview> peerReviews = new ArrayList<PeerReview>();
PeerReview p = new PeerReview();
setOrg(p);
p.setPutCode(1L);
peerReviews.add(p);
return peerReviews;
}
});
when(mockWorkManagerReadOnly.findWorks(anyString(), any())).thenAnswer(new Answer<List<Work>>() {
@Override
public List<Work> answer(InvocationOnMock invocation) throws Throwable {
List<Work> works = new ArrayList<Work>();
Work w = new Work();
WorkTitle t = new WorkTitle();
t.setTitle(new Title("title"));
w.setPutCode(1L);
works.add(w);
return works;
}
});
when(mockWorkManagerReadOnly.getLastModified(anyString())).thenReturn(0L);
when(mockWorkEntityCacheManager.retrieveWorkLastModifiedList(anyString(), anyLong())).thenAnswer(new Answer<List<WorkLastModifiedEntity>>() {
@Override
public List<WorkLastModifiedEntity> answer(InvocationOnMock invocation) throws Throwable {
List<WorkLastModifiedEntity> works = new ArrayList<WorkLastModifiedEntity>();
WorkLastModifiedEntity w = new WorkLastModifiedEntity();
w.setId(1L);
w.setOrcid(ORCID);
w.setLastModified(new Date());
works.add(w);
return works;
}
});
}
Aggregations