Search in sources :

Example 11 with WorkTitle

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

the class ActivitiesGroupGenerator_GroupingWorksTest method testNormalizedGrouping.

@Test
public void testNormalizedGrouping() {
    ActivitiesGroupGenerator generator = new ActivitiesGroupGenerator();
    List<WorkSummary> sums = new ArrayList<WorkSummary>();
    for (int i = 0; i < 2; i++) {
        String title = "work-" + i;
        WorkSummary work = new WorkSummary();
        // Set title
        WorkTitle workTitle = new WorkTitle();
        workTitle.setTitle(new Title(title));
        work.setTitle(workTitle);
        ExternalIDs wei = new ExternalIDs();
        ExternalID e1 = new ExternalID();
        e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
        e1.setValue("a");
        e1.setNormalized(new TransientNonEmptyString("a"));
        wei.getExternalIdentifier().add(e1);
        work.setExternalIdentifiers(wei);
        sums.add(work);
    }
    sums.get(0).getExternalIdentifiers().getExternalIdentifier().get(0).setValue("A");
    generator.group(sums.get(0));
    generator.group(sums.get(1));
    assertEquals(1, generator.getGroups().size());
    checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(0), sums.get(1));
    for (int i = 2; i < 4; i++) {
        String title = "work-" + i;
        WorkSummary work = new WorkSummary();
        // Set title
        WorkTitle workTitle = new WorkTitle();
        workTitle.setTitle(new Title(title));
        work.setTitle(workTitle);
        ExternalIDs wei = new ExternalIDs();
        ExternalID e1 = new ExternalID();
        e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
        e1.setValue("https://dx.doi.org/10/UPPER");
        e1.setNormalized(new TransientNonEmptyString("10/upper"));
        wei.getExternalIdentifier().add(e1);
        work.setExternalIdentifiers(wei);
        sums.add(work);
    }
    sums.get(0).getExternalIdentifiers().getExternalIdentifier().get(0).setValue("http://doi.org/10/upper");
    generator.group(sums.get(2));
    generator.group(sums.get(3));
    assertEquals(2, generator.getGroups().size());
    checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(0), sums.get(1));
    checkActivitiesBelongsToTheSameGroup(generator.getGroups(), sums.get(2), sums.get(3));
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) ArrayList(java.util.ArrayList) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 12 with WorkTitle

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

the class ActivitiesGroupGenerator_GroupingWorksTest method generateWorks.

/**
 * work-1 -> ARG(A), ARG(B), ARG(C)
 * work-2 -> ARG(C), ARG(D), ARG(E)
 * work-3 -> ARG(X), ARG(Y), ARG(Z)
 * work-4 -> ARG(Y), ARG(B), ARG(1)
 * work-5 -> ARG(M), ARG(N), ARG(O)
 * work-6 -> ARXIV(A), ARXIV(B), ARXIV(C)
 * work-7 -> DOI(1), DOI(2), ARIXV(B)
 * work-8 -> No external identifiers
 * work-9 -> No external identifiers
 * work-10 -> ISSN(1), ISSN(2), ISSN(3)
 * work-11 -> ISSN(3), ISSN(4), ISSN(5)
 * work-12 -> DOI(1), ISSN(1)
 * work-13 -> DOI(1), ISSN(4)
 */
private Map<String, WorkSummary> generateWorks() {
    Map<String, WorkSummary> result = new HashMap<String, WorkSummary>();
    for (int i = 1; i < 14; i++) {
        String title = "work-" + i;
        WorkSummary work = new WorkSummary();
        // Set title
        WorkTitle workTitle = new WorkTitle();
        workTitle.setTitle(new Title(title));
        work.setTitle(workTitle);
        ExternalIDs wei = new ExternalIDs();
        switch(i) {
            case 1:
                ExternalID e1 = new ExternalID();
                e1.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e1.setValue("A");
                ExternalID e2 = new ExternalID();
                e2.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e2.setValue("B");
                ExternalID e3 = new ExternalID();
                e3.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e3.setValue("C");
                wei.getExternalIdentifier().add(e1);
                wei.getExternalIdentifier().add(e2);
                wei.getExternalIdentifier().add(e3);
                break;
            case 2:
                ExternalID e4 = new ExternalID();
                e4.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e4.setValue("C");
                ExternalID e5 = new ExternalID();
                e5.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e5.setValue("D");
                ExternalID e6 = new ExternalID();
                e6.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e6.setValue("E");
                wei.getExternalIdentifier().add(e4);
                wei.getExternalIdentifier().add(e5);
                wei.getExternalIdentifier().add(e6);
                break;
            case 3:
                ExternalID e7 = new ExternalID();
                e7.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e7.setValue("X");
                ExternalID e8 = new ExternalID();
                e8.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e8.setValue("Y");
                ExternalID e9 = new ExternalID();
                e9.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e9.setValue("Z");
                wei.getExternalIdentifier().add(e7);
                wei.getExternalIdentifier().add(e8);
                wei.getExternalIdentifier().add(e9);
                break;
            case 4:
                ExternalID e10 = new ExternalID();
                e10.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e10.setValue("Y");
                ExternalID e11 = new ExternalID();
                e11.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e11.setValue("B");
                ExternalID e12 = new ExternalID();
                e12.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e12.setValue("1");
                wei.getExternalIdentifier().add(e10);
                wei.getExternalIdentifier().add(e11);
                wei.getExternalIdentifier().add(e12);
                break;
            case 5:
                ExternalID e13 = new ExternalID();
                e13.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e13.setValue("M");
                ExternalID e14 = new ExternalID();
                e14.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e14.setValue("N");
                ExternalID e15 = new ExternalID();
                e15.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.AGR.value());
                e15.setValue("O");
                wei.getExternalIdentifier().add(e13);
                wei.getExternalIdentifier().add(e14);
                wei.getExternalIdentifier().add(e15);
                break;
            case 6:
                ExternalID e16 = new ExternalID();
                e16.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ARXIV.value());
                e16.setValue("A");
                ExternalID e17 = new ExternalID();
                e17.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ARXIV.value());
                e17.setValue("B");
                ExternalID e18 = new ExternalID();
                e18.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ARXIV.value());
                e18.setValue("C");
                wei.getExternalIdentifier().add(e16);
                wei.getExternalIdentifier().add(e17);
                wei.getExternalIdentifier().add(e18);
                break;
            case 7:
                ExternalID e19 = new ExternalID();
                e19.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
                e19.setValue("1");
                ExternalID e20 = new ExternalID();
                e20.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
                e20.setValue("2");
                ExternalID e21 = new ExternalID();
                e21.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ARXIV.value());
                e21.setValue("B");
                wei.getExternalIdentifier().add(e19);
                wei.getExternalIdentifier().add(e20);
                wei.getExternalIdentifier().add(e21);
                break;
            case 10:
                ExternalID e22 = new ExternalID();
                e22.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e22.setValue("1");
                ExternalID e23 = new ExternalID();
                e23.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e23.setValue("2");
                ExternalID e24 = new ExternalID();
                e24.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e24.setValue("3");
                wei.getExternalIdentifier().add(e22);
                wei.getExternalIdentifier().add(e23);
                wei.getExternalIdentifier().add(e24);
                break;
            case 11:
                ExternalID e25 = new ExternalID();
                e25.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e25.setValue("3");
                ExternalID e26 = new ExternalID();
                e26.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e26.setValue("3");
                ExternalID e27 = new ExternalID();
                e27.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e27.setValue("3");
                wei.getExternalIdentifier().add(e25);
                wei.getExternalIdentifier().add(e26);
                wei.getExternalIdentifier().add(e27);
                break;
            case 12:
                ExternalID e28 = new ExternalID();
                e28.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
                e28.setValue("1");
                ExternalID e29 = new ExternalID();
                e29.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e29.setValue("1");
                wei.getExternalIdentifier().add(e28);
                wei.getExternalIdentifier().add(e29);
                break;
            case 13:
                ExternalID e30 = new ExternalID();
                e30.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.DOI.value());
                e30.setValue("1");
                ExternalID e31 = new ExternalID();
                e31.setType(org.orcid.jaxb.model.message.WorkExternalIdentifierType.ISSN.value());
                e31.setValue("4");
                wei.getExternalIdentifier().add(e30);
                wei.getExternalIdentifier().add(e31);
                break;
        }
        work.setExternalIdentifiers(wei);
        result.put(title, work);
    }
    return result;
}
Also used : WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) HashMap(java.util.HashMap) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)

Example 13 with WorkTitle

use of org.orcid.jaxb.model.v3.dev1.record.WorkTitle 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.v3.dev1.common.Subtitle) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) WorkContributors(org.orcid.jaxb.model.v3.dev1.record.WorkContributors) Work(org.orcid.jaxb.model.v3.dev1.record.Work) CreditName(org.orcid.jaxb.model.v3.dev1.common.CreditName) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingContributor(org.orcid.jaxb.model.v3.dev1.record.FundingContributor) Contributor(org.orcid.jaxb.model.v3.dev1.common.Contributor) Citation(org.orcid.jaxb.model.v3.dev1.record.Citation)

Example 14 with WorkTitle

use of org.orcid.jaxb.model.v3.dev1.record.WorkTitle 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.v3.dev1.common.Subtitle) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle)

Example 15 with WorkTitle

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

the class MemberV3ApiServiceDelegator_WorksTest method testCreateBulkWorksWithBlankTitles.

@Test
public void testCreateBulkWorksWithBlankTitles() {
    RequestAttributes previousAttrs = RequestContextHolder.getRequestAttributes();
    RequestAttributes attrs = new ServletRequestAttributes(new MockHttpServletRequest());
    attrs.setAttribute(ApiVersionFilter.API_VERSION_REQUEST_ATTRIBUTE_NAME, "3.0_dev1", RequestAttributes.SCOPE_REQUEST);
    RequestContextHolder.setRequestAttributes(attrs);
    Long time = System.currentTimeMillis();
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    WorkBulk bulk = new WorkBulk();
    for (int i = 0; i < 5; i++) {
        Work work = new Work();
        WorkTitle title = new WorkTitle();
        title.setTitle(i == 0 ? new Title(" ") : new Title("title " + i));
        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);
    }
    Response response = serviceDelegator.createWorks(ORCID, bulk);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    bulk = (WorkBulk) response.getEntity();
    assertNotNull(bulk);
    assertEquals(5, bulk.getBulk().size());
    for (int i = 0; i < 5; i++) {
        if (i == 0) {
            assertTrue(bulk.getBulk().get(i) instanceof OrcidError);
        } else {
            assertTrue(bulk.getBulk().get(i) instanceof Work);
            serviceDelegator.deleteWork(ORCID, ((Work) bulk.getBulk().get(i)).getPutCode());
        }
    }
    RequestContextHolder.setRequestAttributes(previousAttrs);
}
Also used : OrcidError(org.orcid.jaxb.model.v3.dev1.error.OrcidError) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) WorkBulk(org.orcid.jaxb.model.v3.dev1.record.WorkBulk) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) TranslatedTitle(org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) RequestAttributes(org.springframework.web.context.request.RequestAttributes) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) Response(javax.ws.rs.core.Response) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) Work(org.orcid.jaxb.model.v3.dev1.record.Work) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)30 Title (org.orcid.jaxb.model.v3.dev1.common.Title)29 Work (org.orcid.jaxb.model.v3.dev1.record.Work)21 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)19 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)18 Url (org.orcid.jaxb.model.v3.dev1.common.Url)14 Test (org.junit.Test)12 TranslatedTitle (org.orcid.jaxb.model.v3.dev1.common.TranslatedTitle)9 Subtitle (org.orcid.jaxb.model.v3.dev1.common.Subtitle)7 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)7 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)7 BaseTest (org.orcid.core.BaseTest)6 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)6 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)5 ClientDetailsEntity (org.orcid.persistence.jpa.entities.ClientDetailsEntity)5 DBUnitTest (org.orcid.test.DBUnitTest)5 Day (org.orcid.jaxb.model.v3.dev1.common.Day)4 Month (org.orcid.jaxb.model.v3.dev1.common.Month)4 Year (org.orcid.jaxb.model.v3.dev1.common.Year)4 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)4