Search in sources :

Example 36 with Title

use of org.orcid.jaxb.model.common_rc1.Title in project ORCID-Source by ORCID.

the class WorkManagerTest method testCreateWorkWithBulk_TwoSelf_DupError.

@Test
public void testCreateWorkWithBulk_TwoSelf_DupError() {
    String orcid = "0000-0000-0000-0003";
    Long time = System.currentTimeMillis();
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    WorkBulk bulk = new WorkBulk();
    // Work # 1
    Work work1 = new Work();
    WorkTitle title1 = new WorkTitle();
    title1.setTitle(new Title("Work # 1"));
    work1.setWorkTitle(title1);
    ExternalIDs extIds1 = new ExternalIDs();
    ExternalID extId1 = new ExternalID();
    extId1.setRelationship(Relationship.SELF);
    extId1.setType("isbn");
    extId1.setUrl(new Url("http://isbn/1/" + time));
    extId1.setValue("isbn-1");
    extIds1.getExternalIdentifier().add(extId1);
    work1.setWorkExternalIdentifiers(extIds1);
    work1.setWorkType(WorkType.BOOK);
    bulk.getBulk().add(work1);
    // Work # 2
    Work work2 = new Work();
    WorkTitle title2 = new WorkTitle();
    title2.setTitle(new Title("Work # 2"));
    work2.setWorkTitle(title2);
    ExternalIDs extIds2 = new ExternalIDs();
    ExternalID extId2 = new ExternalID();
    extId2.setRelationship(Relationship.SELF);
    extId2.setType("isbn");
    extId2.setUrl(new Url("http://isbn/1/" + time));
    extId2.setValue("isbn-1");
    extIds2.getExternalIdentifier().add(extId2);
    work2.setWorkExternalIdentifiers(extIds2);
    work2.setWorkType(WorkType.BOOK);
    bulk.getBulk().add(work2);
    WorkBulk updatedBulk = workManager.createWorks(orcid, bulk);
    assertNotNull(updatedBulk);
    assertEquals(2, updatedBulk.getBulk().size());
    assertTrue(updatedBulk.getBulk().get(0) instanceof Work);
    assertNotNull(((Work) updatedBulk.getBulk().get(0)).getPutCode());
    assertEquals(Relationship.SELF, ((Work) updatedBulk.getBulk().get(0)).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("isbn-1", ((Work) updatedBulk.getBulk().get(0)).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertTrue(updatedBulk.getBulk().get(1) instanceof OrcidError);
    assertEquals(Integer.valueOf(9021), ((OrcidError) updatedBulk.getBulk().get(1)).getErrorCode());
    assertEquals("409 Conflict: You have already added this activity (matched by external identifiers.) If you are trying to edit the item, please use PUT instead of POST.", ((OrcidError) updatedBulk.getBulk().get(1)).getDeveloperMessage());
    workManager.removeWorks(orcid, Arrays.asList(((Work) updatedBulk.getBulk().get(0)).getPutCode()));
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 37 with Title

use of org.orcid.jaxb.model.common_rc1.Title in project ORCID-Source by ORCID.

the class WorkManagerTest method testCreateWorksWithBulkAllOK.

@Test
public void testCreateWorksWithBulkAllOK() {
    String orcid = "0000-0000-0000-0003";
    Long time = System.currentTimeMillis();
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    WorkBulk bulk = new WorkBulk();
    for (int i = 0; i < 5; i++) {
        Work work = new Work();
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Bulk work " + i + " " + time));
        work.setWorkTitle(title);
        ExternalIDs extIds = new ExternalIDs();
        ExternalID extId = new ExternalID();
        extId.setRelationship(Relationship.SELF);
        extId.setType("doi");
        extId.setUrl(new Url("http://doi/" + i + "/" + time));
        extId.setValue("doi-" + i + "-" + time);
        extIds.getExternalIdentifier().add(extId);
        work.setWorkExternalIdentifiers(extIds);
        work.setWorkType(WorkType.BOOK);
        bulk.getBulk().add(work);
    }
    bulk = workManager.createWorks(orcid, bulk);
    assertNotNull(bulk);
    assertEquals(5, bulk.getBulk().size());
    for (int i = 0; i < 5; i++) {
        assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
        Work w = (Work) bulk.getBulk().get(i);
        assertNotNull(w.getPutCode());
        assertTrue(0L < w.getPutCode());
        assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
        assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
        assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
        Work w1 = workManager.getWork(orcid, w.getPutCode());
        assertNotNull(w1);
        assertEquals("Bulk work " + i + " " + time, w1.getWorkTitle().getTitle().getContent());
        // Delete the work
        assertTrue(workManager.checkSourceAndRemoveWork(orcid, w1.getPutCode()));
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 38 with Title

use of org.orcid.jaxb.model.common_rc1.Title in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method generateFundings.

/**
 * funding-1 -> A, B, C
 * funding-2 -> C, D, E
 * funding-3 -> X, Y, Z
 * funding-4 -> Y, B, 1
 * funding-5 -> M, N, O
 * funding-6 -> O, P, Q
 * funding-7 -> 1, 2, B
 * funding-8 -> No external identifiers
 * funding-9 -> No external identifiers
 */
private Map<String, FundingSummary> generateFundings() {
    Map<String, FundingSummary> result = new HashMap<String, FundingSummary>();
    for (int i = 1; i < 10; i++) {
        String name = "funding-" + i;
        FundingSummary funding = new FundingSummary();
        FundingTitle title = new FundingTitle();
        title.setTitle(new Title(name));
        funding.setTitle(title);
        ExternalIDs fei = new ExternalIDs();
        switch(i) {
            case 1:
                ExternalID f1 = new ExternalID();
                f1.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f1.setValue("A");
                ExternalID f2 = new ExternalID();
                f2.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f2.setValue("B");
                ExternalID f3 = new ExternalID();
                f3.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f3.setValue("C");
                fei.getExternalIdentifier().add(f1);
                fei.getExternalIdentifier().add(f2);
                fei.getExternalIdentifier().add(f3);
                break;
            case 2:
                ExternalID f4 = new ExternalID();
                f4.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f4.setValue("C");
                ExternalID f5 = new ExternalID();
                f5.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f5.setValue("D");
                ExternalID f6 = new ExternalID();
                f6.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f6.setValue("E");
                fei.getExternalIdentifier().add(f4);
                fei.getExternalIdentifier().add(f5);
                fei.getExternalIdentifier().add(f6);
                break;
            case 3:
                ExternalID f7 = new ExternalID();
                f7.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f7.setValue("X");
                ExternalID f8 = new ExternalID();
                f8.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f8.setValue("Y");
                ExternalID f9 = new ExternalID();
                f9.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f9.setValue("Z");
                fei.getExternalIdentifier().add(f7);
                fei.getExternalIdentifier().add(f8);
                fei.getExternalIdentifier().add(f9);
                break;
            case 4:
                ExternalID f10 = new ExternalID();
                f10.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f10.setValue("Y");
                ExternalID f11 = new ExternalID();
                f11.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f11.setValue("B");
                ExternalID f12 = new ExternalID();
                f12.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f12.setValue("1");
                fei.getExternalIdentifier().add(f10);
                fei.getExternalIdentifier().add(f11);
                fei.getExternalIdentifier().add(f12);
                break;
            case 5:
                ExternalID f13 = new ExternalID();
                f13.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f13.setValue("M");
                ExternalID f14 = new ExternalID();
                f14.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f14.setValue("N");
                ExternalID f15 = new ExternalID();
                f15.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f15.setValue("O");
                fei.getExternalIdentifier().add(f13);
                fei.getExternalIdentifier().add(f14);
                fei.getExternalIdentifier().add(f15);
                break;
            case 6:
                ExternalID f16 = new ExternalID();
                f16.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f16.setValue("O");
                ExternalID f17 = new ExternalID();
                f17.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f17.setValue("P");
                ExternalID f18 = new ExternalID();
                f18.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f18.setValue("Q");
                fei.getExternalIdentifier().add(f16);
                fei.getExternalIdentifier().add(f17);
                fei.getExternalIdentifier().add(f18);
                break;
            case 7:
                ExternalID f19 = new ExternalID();
                f19.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f19.setValue("1");
                ExternalID f20 = new ExternalID();
                f20.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f20.setValue("2");
                ExternalID f21 = new ExternalID();
                f21.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f21.setValue("B");
                fei.getExternalIdentifier().add(f19);
                fei.getExternalIdentifier().add(f20);
                fei.getExternalIdentifier().add(f21);
                break;
        }
        funding.setExternalIdentifiers(fei);
        result.put(name, funding);
    }
    return result;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) HashMap(java.util.HashMap) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle)

Example 39 with Title

use of org.orcid.jaxb.model.common_rc1.Title in project ORCID-Source by ORCID.

the class ActivityUtilsTest method getEmptyWorkSummary.

private WorkSummary getEmptyWorkSummary() {
    WorkSummary s = new WorkSummary();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title(""));
    title.setSubtitle(new Subtitle(""));
    title.setTranslatedTitle(new TranslatedTitle(""));
    s.setTitle(title);
    return s;
}
Also used : Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle)

Example 40 with Title

use of org.orcid.jaxb.model.common_rc1.Title in project ORCID-Source by ORCID.

the class ActivityUtilsTest method getEmptyWork.

private Work getEmptyWork() {
    Work w = new Work();
    // Title
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title(""));
    title.setSubtitle(new Subtitle(""));
    title.setTranslatedTitle(new TranslatedTitle(""));
    w.setWorkTitle(title);
    // Citation
    w.setWorkCitation(new Citation());
    WorkContributors wc = new WorkContributors();
    // Contributors
    Contributor c = new Contributor();
    c.setCreditName(new CreditName(""));
    wc.getContributor().add(c);
    w.setWorkContributors(wc);
    return w;
}
Also used : Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) WorkContributors(org.orcid.jaxb.model.record_v2.WorkContributors) Work(org.orcid.jaxb.model.record_v2.Work) CreditName(org.orcid.jaxb.model.common_v2.CreditName) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) FundingContributor(org.orcid.jaxb.model.record_v2.FundingContributor) Contributor(org.orcid.jaxb.model.common_v2.Contributor) Citation(org.orcid.jaxb.model.record_v2.Citation)

Aggregations

Title (org.orcid.jaxb.model.common_v2.Title)47 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)41 Test (org.junit.Test)31 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)28 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)24 Work (org.orcid.jaxb.model.record_v2.Work)24 Url (org.orcid.jaxb.model.common_v2.Url)23 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)23 ClientResponse (com.sun.jersey.api.client.ClientResponse)20 TranslatedTitle (org.orcid.jaxb.model.common_v2.TranslatedTitle)14 Funding (org.orcid.jaxb.model.record_v2.Funding)11 ArrayList (java.util.ArrayList)8 List (java.util.List)8 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)8 Visibility (org.orcid.jaxb.model.common_rc1.Visibility)7 Map (java.util.Map)6 Url (org.orcid.jaxb.model.common_rc1.Url)6 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)6 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)6 WorkBulk (org.orcid.jaxb.model.record_v2.WorkBulk)6