Search in sources :

Example 71 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.

the class OrcidSecurityManager_ActivitiesSummaryTest method testActivitiesSummary_When_AllPrivate_NoSource_ReadPublicToken.

@Test
public void testActivitiesSummary_When_AllPrivate_NoSource_ReadPublicToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID_1, CLIENT_1, ScopePathType.READ_PUBLIC);
    DistinctionSummary d1 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
    DistinctionSummary d2 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
    DistinctionSummary d3 = createDistinctionSummary(Visibility.PRIVATE, CLIENT_2);
    EducationSummary e1 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EducationSummary e2 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EducationSummary e3 = createEducationSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em1 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em2 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    EmploymentSummary em3 = createEmploymentSummary(Visibility.PRIVATE, CLIENT_2);
    InvitedPositionSummary i1 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
    InvitedPositionSummary i2 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
    InvitedPositionSummary i3 = createInvitedPositionSummary(Visibility.PRIVATE, CLIENT_2);
    MembershipSummary m1 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
    MembershipSummary m2 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
    MembershipSummary m3 = createMembershipSummary(Visibility.PRIVATE, CLIENT_2);
    QualificationSummary q1 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
    QualificationSummary q2 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
    QualificationSummary q3 = createQualificationSummary(Visibility.PRIVATE, CLIENT_2);
    ServiceSummary s1 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
    ServiceSummary s2 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
    ServiceSummary s3 = createServiceSummary(Visibility.PRIVATE, CLIENT_2);
    FundingSummary f1 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
    FundingSummary f2 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    FundingSummary f3 = createFundingSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    PeerReviewSummary p1 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
    PeerReviewSummary p2 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    PeerReviewSummary p3 = createPeerReviewSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    WorkSummary w1 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_1);
    WorkSummary w2 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_2);
    WorkSummary w3 = createWorkSummary(Visibility.PRIVATE, CLIENT_2, EXTID_3);
    ActivitiesSummary as = new ActivitiesSummary();
    as.setDistinctions(createDistinctions(d1, d2, d3));
    as.setInvitedPositions(createInvitedPositions(i1, i2, i3));
    as.setMemberships(createMemberships(m1, m2, m3));
    as.setQualifications(createQualifications(q1, q2, q3));
    as.setServices(createServices(s1, s2, s3));
    as.setEducations(createEducations(e1, e2, e3));
    as.setEmployments(createEmployments(em1, em2, em3));
    as.setFundings(createFundings(f1, f2, f3));
    as.setPeerReviews(createPeerReviews(p1, p2, p3));
    as.setWorks(createWorks(w1, w2, w3));
    orcidSecurityManager.checkAndFilter(ORCID_1, as);
    assertNotNull(as);
    // Check distinctions
    assertEquals(0, as.getDistinctions().getSummaries().size());
    // Check invited positions
    assertEquals(0, as.getInvitedPositions().getSummaries().size());
    // Check memberships
    assertEquals(0, as.getMemberships().getSummaries().size());
    // Check qualifications
    assertEquals(0, as.getQualifications().getSummaries().size());
    // Check services
    assertEquals(0, as.getServices().getSummaries().size());
    // Check educations
    assertEquals(0, as.getEducations().getSummaries().size());
    // Check employments
    assertEquals(0, as.getEmployments().getSummaries().size());
    // Check fundings
    assertEquals(0, as.getFundings().getFundingGroup().size());
    // Check peer reviews
    assertEquals(0, as.getPeerReviews().getPeerReviewGroup().size());
    // Check works
    assertEquals(0, as.getWorks().getWorkGroup().size());
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) InvitedPositionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary) QualificationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary) EducationSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) DistinctionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary) EmploymentSummary(org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary) MembershipSummary(org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Test(org.junit.Test)

Example 72 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.

the class WorkManagerTest method nonGroupableIdsGenerateEmptyIdsListTest.

@Test
public void nonGroupableIdsGenerateEmptyIdsListTest() {
    WorkSummary s1 = getWorkSummary("Element 1", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s2 = getWorkSummary("Element 2", "ext-id-2", Visibility.LIMITED);
    WorkSummary s3 = getWorkSummary("Element 3", "ext-id-3", Visibility.PRIVATE);
    // s1 will be a part of identifier, so, it will go in its own group
    s1.getExternalIdentifiers().getExternalIdentifier().get(0).setRelationship(Relationship.PART_OF);
    List<WorkSummary> workList = Arrays.asList(s1, s2, s3);
    /**
     * They should be grouped as
     *
     * Group 1: Element 1
     * Group 2: Element 2
     * Group 3: Element 3
     */
    Works works = workManager.groupWorks(workList, false);
    assertNotNull(works);
    assertEquals(3, works.getWorkGroup().size());
    boolean foundEmptyGroup = false;
    boolean found2 = false;
    boolean found3 = false;
    for (WorkGroup group : works.getWorkGroup()) {
        assertEquals(1, group.getWorkSummary().size());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            assertEquals("Element 1", group.getWorkSummary().get(0).getTitle().getTitle().getContent());
            assertEquals("ext-id-1", group.getWorkSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            foundEmptyGroup = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            assertThat(group.getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-2"), is("ext-id-3")));
            if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("ext-id-2")) {
                assertEquals("Element 2", group.getWorkSummary().get(0).getTitle().getTitle().getContent());
                assertEquals("ext-id-2", group.getWorkSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                found2 = true;
            } else if (group.getIdentifiers().getExternalIdentifier().get(0).getValue().equals("ext-id-3")) {
                assertEquals("Element 3", group.getWorkSummary().get(0).getTitle().getTitle().getContent());
                assertEquals("ext-id-3", group.getWorkSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                found3 = true;
            } else {
                fail("Invalid ext id found " + group.getIdentifiers().getExternalIdentifier().get(0).getValue());
            }
        }
    }
    assertTrue(foundEmptyGroup);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 73 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.

the class WorkManagerTest method testGroupWorks_groupOnlyPublicWorks1.

@Test
public void testGroupWorks_groupOnlyPublicWorks1() {
    WorkSummary s1 = getWorkSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s2 = getWorkSummary("Limited 1", "ext-id-2", Visibility.LIMITED);
    WorkSummary s3 = getWorkSummary("Private 1", "ext-id-3", Visibility.PRIVATE);
    WorkSummary s4 = getWorkSummary("Public 2", "ext-id-4", Visibility.PUBLIC);
    WorkSummary s5 = getWorkSummary("Limited 2", "ext-id-5", Visibility.LIMITED);
    WorkSummary s6 = getWorkSummary("Private 2", "ext-id-6", Visibility.PRIVATE);
    WorkSummary s7 = getWorkSummary("Public 3", "ext-id-7", Visibility.PUBLIC);
    WorkSummary s8 = getWorkSummary("Limited 3", "ext-id-8", Visibility.LIMITED);
    WorkSummary s9 = getWorkSummary("Private 3", "ext-id-9", Visibility.PRIVATE);
    List<WorkSummary> workList = 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
     */
    Works works = workManager.groupWorks(workList, true);
    assertNotNull(works);
    assertEquals(3, works.getWorkGroup().size());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
    assertEquals("ext-id-1", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 1", works.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTitle().getContent());
    assertEquals(1, works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, works.getWorkGroup().get(1).getWorkSummary().size());
    assertEquals("ext-id-4", works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 2", works.getWorkGroup().get(1).getWorkSummary().get(0).getTitle().getTitle().getContent());
    assertEquals(1, works.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals(1, works.getWorkGroup().get(2).getWorkSummary().size());
    assertEquals("ext-id-7", works.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals("Public 3", works.getWorkGroup().get(2).getWorkSummary().get(0).getTitle().getTitle().getContent());
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 74 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.

the class WorkManagerTest method testGroupWorksWithDisplayIndex.

@Test
public void testGroupWorksWithDisplayIndex() {
    /**
     * @formatter:off
     * They should be grouped as
     *
     * Group 1: Work 3
     * Group 2: Work 4 + Work 1
     * Group 3: Work 5 + Work 2
     * Group 4: Work 6
     * @formatter:on
     */
    WorkSummary s1 = getWorkSummary("Work 1", "ext-id-1", Visibility.PUBLIC, "0");
    WorkSummary s2 = getWorkSummary("Work 2", "ext-id-2", Visibility.LIMITED, "1");
    WorkSummary s3 = getWorkSummary("Work 3", "ext-id-3", Visibility.PRIVATE, "0");
    WorkSummary s4 = getWorkSummary("Work 4", "ext-id-1", Visibility.PRIVATE, "1");
    WorkSummary s5 = getWorkSummary("Work 5", "ext-id-2", Visibility.PUBLIC, "2");
    WorkSummary s6 = getWorkSummary("Work 6", "ext-id-4", Visibility.PRIVATE, "0");
    List<WorkSummary> workList1 = Arrays.asList(s1, s2, s3, s4, s5, s6);
    Works works1 = workManager.groupWorks(workList1, false);
    assertNotNull(works1);
    assertEquals(4, works1.getWorkGroup().size());
    // Group 1 have all with ext-id-3
    assertEquals(1, works1.getWorkGroup().get(0).getWorkSummary().size());
    assertEquals(1, works1.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-3", works1.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    // Group 2 have all with ext-id-2
    assertEquals(2, works1.getWorkGroup().get(1).getWorkSummary().size());
    assertEquals(1, works1.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", works1.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    // Group 3 have ext-id-3
    assertEquals(2, works1.getWorkGroup().get(2).getWorkSummary().size());
    assertEquals(1, works1.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", works1.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
    // Group 4 have ext-id-4
    assertEquals(1, works1.getWorkGroup().get(3).getWorkSummary().size());
    assertEquals(1, works1.getWorkGroup().get(3).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-4", works1.getWorkGroup().get(3).getIdentifiers().getExternalIdentifier().get(0).getValue());
    WorkSummary s7 = getWorkSummary("Work 7", "ext-id-4", Visibility.PRIVATE, "0");
    // Add ext-id-3 to work 7, so, it join group 3 and group 4 in a single
    // group
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("doi");
    extId.setUrl(new Url("http://orcid.org"));
    extId.setValue("ext-id-3");
    s7.getExternalIdentifiers().getExternalIdentifier().add(extId);
    /**
     * @formatter:off
     * Now, they should be grouped as
     *
     * Group 1: Work 3 + Work 6 + Work 7
     * Group 2: Work 4 + Work 1
     * Group 3: Work 5 + Work 2
     * @formatter:on
     */
    List<WorkSummary> workList2 = Arrays.asList(s1, s2, s3, s4, s5, s6, s7);
    Works works2 = workManager.groupWorks(workList2, false);
    assertNotNull(works2);
    assertEquals(3, works2.getWorkGroup().size());
    // Group 1 have all with ext-id-3 and ext-id-4
    assertEquals(3, works2.getWorkGroup().get(0).getWorkSummary().size());
    assertEquals(2, works2.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertThat(works2.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
    assertThat(works2.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(1).getValue(), anyOf(is("ext-id-3"), is("ext-id-4")));
    // Group 2 have all with ext-id-1
    assertEquals(2, works2.getWorkGroup().get(1).getWorkSummary().size());
    assertEquals(1, works2.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", works2.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    // Group 2 have all with ext-id-2
    assertEquals(2, works2.getWorkGroup().get(2).getWorkSummary().size());
    assertEquals(1, works2.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", works2.getWorkGroup().get(2).getIdentifiers().getExternalIdentifier().get(0).getValue());
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 75 with WorkSummary

use of org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary in project ORCID-Source by ORCID.

the class WorkManagerTest method testGroupWorks_groupOnlyPublicWorks2.

@Test
public void testGroupWorks_groupOnlyPublicWorks2() {
    WorkSummary s1 = getWorkSummary("Public 1", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s2 = getWorkSummary("Limited 1", "ext-id-1", Visibility.LIMITED);
    WorkSummary s3 = getWorkSummary("Private 1", "ext-id-1", Visibility.PRIVATE);
    WorkSummary s4 = getWorkSummary("Public 2", "ext-id-1", Visibility.PUBLIC);
    WorkSummary s5 = getWorkSummary("Limited 2", "ext-id-1", Visibility.LIMITED);
    WorkSummary s6 = getWorkSummary("Private 2", "ext-id-1", Visibility.PRIVATE);
    WorkSummary s7 = getWorkSummary("Public 3", "ext-id-2", Visibility.PUBLIC);
    WorkSummary s8 = getWorkSummary("Limited 3", "ext-id-2", Visibility.LIMITED);
    WorkSummary s9 = getWorkSummary("Private 3", "ext-id-2", Visibility.PRIVATE);
    List<WorkSummary> workList = Arrays.asList(s1, s2, s3, s4, s5, s6, s7, s8, s9);
    /**
     * They should be grouped as
     *
     * Group 1: Public 1 + Public 2
     * Group 2: Public 3
     */
    Works works = workManager.groupWorks(workList, true);
    assertNotNull(works);
    assertEquals(2, works.getWorkGroup().size());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-1", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(2, works.getWorkGroup().get(0).getWorkSummary().size());
    assertThat(works.getWorkGroup().get(0).getWorkSummary().get(0).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
    assertThat(works.getWorkGroup().get(0).getWorkSummary().get(1).getTitle().getTitle().getContent(), anyOf(is("Public 1"), is("Public 2")));
    assertEquals(1, works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().size());
    assertEquals("ext-id-2", works.getWorkGroup().get(1).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, works.getWorkGroup().get(1).getWorkSummary().size());
    assertEquals("Public 3", works.getWorkGroup().get(1).getWorkSummary().get(0).getTitle().getTitle().getContent());
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)85 Test (org.junit.Test)64 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)42 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)40 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)40 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)40 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)39 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)35 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)35 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)35 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)35 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)35 WorkGroup (org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup)27 Works (org.orcid.jaxb.model.v3.dev1.record.summary.Works)23 Address (org.orcid.jaxb.model.v3.dev1.record.Address)15 Email (org.orcid.jaxb.model.v3.dev1.record.Email)15 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)15 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)15 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)15 Record (org.orcid.jaxb.model.v3.dev1.record.Record)15