Search in sources :

Example 16 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.WorkSummary in project ORCID-Source by ORCID.

the class ValidateV2SamplesTest method testUnmarshallWorks.

@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
    Works works = (Works) unmarshallFromPath("/record_2.0/samples/read_samples/works-2.0.xml", Works.class, "/record_2.0/activities-2.0.xsd");
    assertNotNull(works);
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertEquals(3, works.getWorkGroup().size());
    boolean foundWorkWithNoExtIds = false;
    for (WorkGroup group : works.getWorkGroup()) {
        assertNotNull(group.getLastModifiedDate().getValue());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            WorkSummary summary = group.getWorkSummary().get(0);
            assertEquals("1", summary.getDisplayIndex());
            assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
            assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
            assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
            assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
            assertEquals("03", summary.getPublicationDate().getDay().getValue());
            assertEquals("03", summary.getPublicationDate().getMonth().getValue());
            assertEquals("2017", summary.getPublicationDate().getYear().getValue());
            assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
            assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
            assertEquals(Visibility.PUBLIC, summary.getVisibility());
            foundWorkWithNoExtIds = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
            if (extId.getType().equals("arxiv")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
                assertEquals("123456", extId.getValue());
            } else if (extId.getType().equals("bibcode")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
                assertEquals("4567", extId.getValue());
            } else {
                fail("Invalid ext id type " + extId.getType());
            }
            assertEquals(1, group.getWorkSummary().size());
            WorkSummary summary = group.getWorkSummary().get(0);
            if (summary.getPutCode().equals(Long.valueOf(3357))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
                assertEquals("02", summary.getPublicationDate().getDay().getValue());
                assertEquals("02", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else if (summary.getPutCode().equals(Long.valueOf(3358))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
                assertEquals("03", summary.getPublicationDate().getDay().getValue());
                assertEquals("03", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else {
                fail("Invalid put code " + summary.getPutCode());
            }
        }
    }
    assertTrue(foundWorkWithNoExtIds);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test)

Example 17 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.WorkSummary in project ORCID-Source by ORCID.

the class ValidateV2_1SamplesTest method testUnmarshallWorks.

@Test
public void testUnmarshallWorks() throws JAXBException, SAXException, URISyntaxException {
    Works works = (Works) unmarshallFromPath("/record_2.1/samples/read_samples/works-2.1.xml", Works.class, "/record_2.1/activities-2.1.xsd");
    assertNotNull(works);
    assertNotNull(works.getLastModifiedDate());
    assertNotNull(works.getLastModifiedDate().getValue());
    assertEquals(3, works.getWorkGroup().size());
    boolean foundWorkWithNoExtIds = false;
    for (WorkGroup group : works.getWorkGroup()) {
        assertNotNull(group.getLastModifiedDate().getValue());
        assertNotNull(group.getIdentifiers().getExternalIdentifier());
        if (group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            WorkSummary summary = group.getWorkSummary().get(0);
            validateSourceInHttps(summary.getSource());
            assertEquals("1", summary.getDisplayIndex());
            assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
            assertEquals("doi", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
            assertEquals("https://doi.org/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
            assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
            assertEquals("/8888-8888-8888-8880/work/3356", summary.getPath());
            assertEquals("03", summary.getPublicationDate().getDay().getValue());
            assertEquals("03", summary.getPublicationDate().getMonth().getValue());
            assertEquals("2017", summary.getPublicationDate().getYear().getValue());
            assertEquals("Work # 0", summary.getTitle().getTitle().getContent());
            assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
            assertEquals(Visibility.PUBLIC, summary.getVisibility());
            foundWorkWithNoExtIds = true;
        } else {
            assertEquals(1, group.getIdentifiers().getExternalIdentifier().size());
            ExternalID extId = group.getIdentifiers().getExternalIdentifier().get(0);
            if (extId.getType().equals("arxiv")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://arxiv.org/abs/123456", extId.getUrl().getValue());
                assertEquals("123456", extId.getValue());
            } else if (extId.getType().equals("bibcode")) {
                assertEquals(Relationship.SELF, extId.getRelationship());
                assertEquals("http://adsabs.harvard.edu/abs/4567", extId.getUrl().getValue());
                assertEquals("4567", extId.getValue());
            } else {
                fail("Invalid ext id type " + extId.getType());
            }
            assertEquals(1, group.getWorkSummary().size());
            WorkSummary summary = group.getWorkSummary().get(0);
            validateSourceInHttps(summary.getSource());
            if (summary.getPutCode().equals(Long.valueOf(3357))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("arxiv", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://arxiv.org/abs/123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("123456", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3357", summary.getPath());
                assertEquals("02", summary.getPublicationDate().getDay().getValue());
                assertEquals("02", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 1", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.CONFERENCE_PAPER, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else if (summary.getPutCode().equals(Long.valueOf(3358))) {
                assertEquals("1", summary.getDisplayIndex());
                assertEquals(1, summary.getExternalIdentifiers().getExternalIdentifier().size());
                assertEquals("bibcode", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
                assertEquals("http://adsabs.harvard.edu/abs/4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
                assertEquals("4567", summary.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
                assertEquals("/8888-8888-8888-8880/work/3358", summary.getPath());
                assertEquals("03", summary.getPublicationDate().getDay().getValue());
                assertEquals("03", summary.getPublicationDate().getMonth().getValue());
                assertEquals("2017", summary.getPublicationDate().getYear().getValue());
                assertEquals("Work # 2", summary.getTitle().getTitle().getContent());
                assertEquals(WorkType.JOURNAL_ARTICLE, summary.getType());
                assertEquals(Visibility.PUBLIC, summary.getVisibility());
            } else {
                fail("Invalid put code " + summary.getPutCode());
            }
        }
    }
    assertTrue(foundWorkWithNoExtIds);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Works(org.orcid.jaxb.model.record.summary_v2.Works) Test(org.junit.Test)

Example 18 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.WorkSummary in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewWorks.

@Override
public Response viewWorks(String orcid) {
    long lastModifiedTime = getLastModifiedTime(orcid);
    List<WorkSummary> works = workManagerReadOnly.getWorksSummaryList(orcid, lastModifiedTime);
    Works publicWorks = workManagerReadOnly.groupWorks(works, true);
    publicAPISecurityManagerV2.filter(publicWorks);
    ActivityUtils.cleanEmptyFields(publicWorks);
    ActivityUtils.setPathToWorks(publicWorks, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(publicWorks);
    sourceUtilsReadOnly.setSourceName(publicWorks);
    return Response.ok(publicWorks).build();
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Example 19 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.WorkSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_ActivitiesSummaryTest method testViewActitivies.

@Test
public void testViewActitivies() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewActivities(ORCID);
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    ActivitiesSummary as = (ActivitiesSummary) response.getEntity();
    assertNotNull(as);
    assertEquals("/0000-0000-0000-0003/activities", as.getPath());
    Utils.verifyLastModified(as.getLastModifiedDate());
    assertNotNull(as.getEducations());
    assertEquals(4, as.getEducations().getSummaries().size());
    for (EducationSummary element : as.getEducations().getSummaries()) {
        if (element.getPutCode().equals(Long.valueOf(20))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(21))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(22))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(25))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getEmployments());
    assertEquals(4, as.getEmployments().getSummaries().size());
    for (EmploymentSummary element : as.getEmployments().getSummaries()) {
        if (element.getPutCode().equals(Long.valueOf(17))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(18))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(19))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(23))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getFundings());
    assertEquals(4, as.getFundings().getFundingGroup().size());
    for (FundingGroup group : as.getFundings().getFundingGroup()) {
        assertEquals(1, group.getFundingSummary().size());
        FundingSummary element = group.getFundingSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(10))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(11))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(13))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getPeerReviews());
    assertEquals(4, as.getPeerReviews().getPeerReviewGroup().size());
    for (PeerReviewGroup group : as.getPeerReviews().getPeerReviewGroup()) {
        assertEquals(1, group.getPeerReviewSummary().size());
        PeerReviewSummary element = group.getPeerReviewSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(9))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(10))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(11))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
    found1 = found2 = found3 = found4 = false;
    assertNotNull(as.getWorks());
    assertEquals(4, as.getWorks().getWorkGroup().size());
    for (WorkGroup group : as.getWorks().getWorkGroup()) {
        assertEquals(1, group.getWorkSummary().size());
        WorkSummary element = group.getWorkSummary().get(0);
        if (element.getPutCode().equals(Long.valueOf(11))) {
            found1 = true;
        } else if (element.getPutCode().equals(Long.valueOf(12))) {
            found2 = true;
        } else if (element.getPutCode().equals(Long.valueOf(13))) {
            found3 = true;
        } else if (element.getPutCode().equals(Long.valueOf(14))) {
            found4 = true;
        } else {
            fail("Invalid put code " + element.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 20 with WorkSummary

use of org.orcid.jaxb.model.record.summary_rc1.WorkSummary in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method viewWorksTest.

@Test
public void viewWorksTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewWorks(ORCID);
    assertNotNull(r);
    Works works = (Works) r.getEntity();
    assertNotNull(works);
    assertEquals("/0000-0000-0000-0003/works", works.getPath());
    Utils.verifyLastModified(works.getLastModifiedDate());
    assertNotNull(works.getWorkGroup());
    assertNotNull(works.getPath());
    assertEquals(4, works.getWorkGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (WorkGroup workGroup : works.getWorkGroup()) {
        Utils.verifyLastModified(workGroup.getLastModifiedDate());
        assertNotNull(workGroup.getIdentifiers());
        assertNotNull(workGroup.getIdentifiers().getExternalIdentifier());
        assertEquals(1, workGroup.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(workGroup.getWorkSummary());
        assertEquals(1, workGroup.getWorkSummary().size());
        WorkSummary summary = workGroup.getWorkSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        switch(workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "1":
                assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found1 = true;
                break;
            case "2":
                assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found2 = true;
                break;
            case "3":
                assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(13), summary.getPutCode());
                found3 = true;
                break;
            case "4":
                assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(14), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid external id found: " + workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

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