Search in sources :

Example 6 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc4.WorkGroup 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 7 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc4.WorkGroup 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 8 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc4.WorkGroup 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)

Example 9 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc4.WorkGroup in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testAddWork.

@Test
public void testAddWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4445", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities("4444-4444-4444-4445");
    assertNotNull(response);
    ActivitiesSummary summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    // Check works
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(1, summary.getWorks().getWorkGroup().size());
    Utils.verifyLastModified(summary.getWorks().getLastModifiedDate());
    assertNotNull(summary.getWorks().getWorkGroup().get(0));
    Utils.verifyLastModified(summary.getWorks().getWorkGroup().get(0).getLastModifiedDate());
    assertNotNull(summary.getWorks().getWorkGroup().get(0).getWorkSummary());
    assertEquals(1, summary.getWorks().getWorkGroup().get(0).getWorkSummary().size());
    String title = "work # 1 " + System.currentTimeMillis();
    Work work = Utils.getWork(title);
    response = serviceDelegator.createWork("4444-4444-4444-4445", work);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewActivities("4444-4444-4444-4445");
    assertNotNull(response);
    summary = (ActivitiesSummary) response.getEntity();
    assertNotNull(summary);
    Utils.verifyLastModified(summary.getLastModifiedDate());
    // Check works
    assertNotNull(summary.getWorks());
    assertNotNull(summary.getWorks().getWorkGroup());
    assertEquals(2, summary.getWorks().getWorkGroup().size());
    boolean haveOld = false;
    boolean haveNew = false;
    for (WorkGroup group : summary.getWorks().getWorkGroup()) {
        Utils.verifyLastModified(group.getLastModifiedDate());
        assertNotNull(group.getWorkSummary());
        assertNotNull(group.getWorkSummary().get(0));
        WorkSummary workSummary = group.getWorkSummary().get(0);
        Utils.verifyLastModified(workSummary.getLastModifiedDate());
        assertNotNull(workSummary.getTitle());
        assertNotNull(workSummary.getTitle().getTitle());
        if ("A Book With Contributors JSON".equals(workSummary.getTitle().getTitle().getContent())) {
            haveOld = true;
        } else if (title.equals(workSummary.getTitle().getTitle().getContent())) {
            haveNew = true;
        }
    }
    assertTrue(haveOld);
    assertTrue(haveNew);
    // Delete them
    serviceDelegator.deleteWork("4444-4444-4444-4445", putCode);
}
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) Work(org.orcid.jaxb.model.record_v2.Work) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 10 with WorkGroup

use of org.orcid.jaxb.model.record.summary_rc4.WorkGroup in project ORCID-Source by ORCID.

the class BibtexManagerImpl method generateBibtexReferenceList.

@Override
public String generateBibtexReferenceList(String orcid) {
    long last = workManager.getLastModified(orcid);
    ActivitiesSummary summary = activitiesManager.getActivitiesSummary(orcid);
    List<String> citations = new ArrayList<String>();
    if (summary.getWorks() != null) {
        for (WorkGroup group : summary.getWorks().getWorkGroup()) {
            WorkSummary workSummary = group.getWorkSummary().get(0);
            Work work = workManager.getWork(orcid, workSummary.getPutCode(), last);
            String bibtex = generateBibtex(orcid, work);
            if (bibtex != null)
                citations.add(bibtex);
        }
    }
    return Joiner.on(",\n").join(citations);
}
Also used : WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ArrayList(java.util.ArrayList) Work(org.orcid.jaxb.model.record_v2.Work) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)

Aggregations

Test (org.junit.Test)32 ClientResponse (com.sun.jersey.api.client.ClientResponse)26 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)26 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)25 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)13 FundingGroup (org.orcid.jaxb.model.record.summary_v2.FundingGroup)13 PeerReviewGroup (org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup)13 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)12 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)12 Works (org.orcid.jaxb.model.record.summary_v2.Works)12 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)11 ArrayList (java.util.ArrayList)9 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)8 Response (javax.ws.rs.core.Response)5 ActivitiesSummary (org.orcid.jaxb.model.record.summary_rc1.ActivitiesSummary)5 WorkGroup (org.orcid.jaxb.model.record.summary_rc1.WorkGroup)5 WorkSummary (org.orcid.jaxb.model.record.summary_rc1.WorkSummary)5 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)5 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)5