Search in sources :

Example 91 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.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);
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Test(org.junit.Test)

Example 92 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.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);
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Test(org.junit.Test)

Example 93 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.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);
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Test(org.junit.Test)

Example 94 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.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();
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary)

Example 95 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.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();
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Aggregations

Test (org.junit.Test)81 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)80 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)46 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)46 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)45 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)44 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)43 ClientResponse (com.sun.jersey.api.client.ClientResponse)27 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)25 Works (org.orcid.jaxb.model.record.summary_v2.Works)22 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)19 Address (org.orcid.jaxb.model.record_v2.Address)18 Email (org.orcid.jaxb.model.record_v2.Email)18 Keyword (org.orcid.jaxb.model.record_v2.Keyword)18 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 Record (org.orcid.jaxb.model.record_v2.Record)18 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)18 Name (org.orcid.jaxb.model.record_v2.Name)17 Addresses (org.orcid.jaxb.model.record_v2.Addresses)15 Biography (org.orcid.jaxb.model.record_v2.Biography)15