use of org.orcid.jaxb.model.record.summary_rc3.WorkSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingWorksTest method groupWorks_2GroupsOf2Works_Test.
/**
* Test grouping (work-1 and work-2) and (work-6 and work-7)
* */
@Test
public void groupWorks_2GroupsOf2Works_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, WorkSummary> works = generateWorks();
WorkSummary work1 = works.get("work-1");
WorkSummary work2 = works.get("work-2");
WorkSummary work6 = works.get("work-6");
WorkSummary work7 = works.get("work-7");
generator.group(work1);
generator.group(work2);
generator.group(work6);
generator.group(work7);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(2, groups.size());
//Check there are two activities in each group
assertEquals(2, groups.get(0).getActivities().size());
assertEquals(2, groups.get(1).getActivities().size());
//Check there are five external ids in each group
assertEquals(5, groups.get(0).getGroupKeys().size());
assertEquals(5, groups.get(1).getGroupKeys().size());
//Check each work
checkActivityIsOnGroups(work1, groups);
checkActivityIsOnGroups(work2, groups);
checkActivityIsOnGroups(work6, groups);
checkActivityIsOnGroups(work7, groups);
//Check work1 and work2 are in the same group
checkActivitiesBelongsToTheSameGroup(groups, work1, work2);
//Check work6 and work7 are in the same group
checkActivitiesBelongsToTheSameGroup(groups, work6, work7);
//Check works are not mixed
checkActivitiesDontBelongsToTheSameGroup(groups, work1, work6);
checkActivitiesDontBelongsToTheSameGroup(groups, work1, work7);
checkActivitiesDontBelongsToTheSameGroup(groups, work2, work6);
checkActivitiesDontBelongsToTheSameGroup(groups, work2, work7);
}
use of org.orcid.jaxb.model.record.summary_rc3.WorkSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingWorksTest method groupWorks_MergeGroupsDontAffectNotMergedGroups_Test.
/**
* work-1, work-3, work-5 and work-8 will be in separate groups
* then work-4 will merge groups of work-1 and work-3
*
* Check that after that, there are 3 groups, one with work-1, work-3 and work-4, one with work-5 and other with work-8
* */
@Test
public void groupWorks_MergeGroupsDontAffectNotMergedGroups_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, WorkSummary> works = generateWorks();
//Group the first group
WorkSummary work1 = works.get("work-1");
WorkSummary work3 = works.get("work-3");
WorkSummary work4 = works.get("work-4");
WorkSummary work5 = works.get("work-5");
WorkSummary work8 = works.get("work-8");
//Respect order
generator.group(work1);
generator.group(work3);
generator.group(work5);
generator.group(work8);
generator.group(work4);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(3, groups.size());
//Check work1, work3 and work4 belongs to the same group
checkActivitiesBelongsToTheSameGroup(groups, work1, work3, work4);
//Check work1, work5 and work8 are all in different groups
checkActivitiesDontBelongsToTheSameGroup(groups, work1, work5, work8);
checkActivityIsOnGroups(work1, groups);
checkActivityIsOnGroups(work3, groups);
checkActivityIsOnGroups(work4, groups);
checkActivityIsOnGroups(work5, groups);
checkActivityIsOnGroups(work8, groups);
}
use of org.orcid.jaxb.model.record.summary_rc3.WorkSummary in project ORCID-Source by ORCID.
the class ActivitiesGroupGenerator_GroupingWorksTest method groupWorks_1GroupsOf2Works_Test.
/**
* Test grouping work-1 and work-2
* */
@Test
public void groupWorks_1GroupsOf2Works_Test() {
ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
Map<String, WorkSummary> works = generateWorks();
WorkSummary work1 = works.get("work-1");
WorkSummary work2 = works.get("work-2");
generator.group(work1);
generator.group(work2);
List<ActivitiesGroup> groups = generator.getGroups();
assertNotNull(groups);
assertEquals(1, groups.size());
ActivitiesGroup g1 = groups.get(0);
assertNotNull(g1);
assertNotNull(g1.getActivities());
assertEquals(2, g1.getActivities().size());
assertTrue(g1.getActivities().contains(work1));
assertTrue(g1.getActivities().contains(work2));
assertNotNull(g1.getGroupKeys());
assertEquals(5, g1.getGroupKeys().size());
checkExternalIdentifiers(work1, g1);
checkExternalIdentifiers(work2, g1);
}
use of org.orcid.jaxb.model.record.summary_rc3.WorkSummary in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorImpl method viewWorkSummary.
@Override
public Response viewWorkSummary(String orcid, Long putCode) {
long lastModifiedTime = getLastModifiedTime(orcid);
WorkSummary ws = workManagerReadOnly.getWorkSummary(orcid, putCode, lastModifiedTime);
ActivityUtils.cleanEmptyFields(ws);
publicAPISecurityManagerV2.checkIsPublic(ws);
ActivityUtils.setPathToActivity(ws, orcid);
sourceUtilsReadOnly.setSourceName(ws);
return Response.ok(ws).build();
}
use of org.orcid.jaxb.model.record.summary_rc3.WorkSummary in project ORCID-Source by ORCID.
the class MemberV2ApiServiceDelegatorImpl method viewWorks.
@Override
public Response viewWorks(String orcid) {
List<WorkSummary> worksList = workManagerReadOnly.getWorksSummaryList(orcid, getLastModifiedTime(orcid));
// Lets copy the list so we don't modify the cached collection
List<WorkSummary> filteredList = null;
if (worksList != null) {
filteredList = new ArrayList<WorkSummary>(worksList);
}
worksList = filteredList;
orcidSecurityManager.checkAndFilter(orcid, worksList, ScopePathType.ORCID_WORKS_READ_LIMITED);
Works works = workManager.groupWorks(worksList, false);
Api2_0_LastModifiedDatesHelper.calculateLastModified(works);
ActivityUtils.cleanEmptyFields(works);
ActivityUtils.setPathToWorks(works, orcid);
sourceUtils.setSourceName(works);
return Response.ok(works).build();
}
Aggregations