Search in sources :

Example 71 with Url

use of org.orcid.jaxb.model.common_rc2.Url in project ORCID-Source by ORCID.

the class WorkFormTest method getWork.

public static Work getWork() {
    Work work = new Work();
    work.setCountry(new Country(Iso3166Country.US));
    Date date = new Date();
    work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
    work.setJournalTitle(new Title("Journal Title"));
    work.setLanguageCode("EN");
    work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
    work.setPutCode(Long.valueOf("12345"));
    work.setShortDescription("Short description");
    work.setUrl(new Url("http://test.com"));
    work.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.LIMITED);
    work.setWorkCitation(new org.orcid.jaxb.model.record_v2.Citation("Citation", CitationType.BIBTEX));
    WorkContributors contributors = new WorkContributors();
    org.orcid.jaxb.model.common_v2.Contributor contributor = new org.orcid.jaxb.model.common_v2.Contributor();
    contributor.setCreditName(new CreditName("Credit name"));
    contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
    ContributorAttributes att = new ContributorAttributes();
    att.setContributorRole(ContributorRole.ASSIGNEE);
    att.setContributorSequence(SequenceType.FIRST);
    contributor.setContributorAttributes(att);
    contributors.getContributor().add(contributor);
    work.setWorkContributors(contributors);
    ExternalIDs weis = new ExternalIDs();
    ExternalID wei = new ExternalID();
    wei.setRelationship(Relationship.SELF);
    wei.setUrl(new Url("http://test.com"));
    wei.setValue("ID");
    wei.setType(WorkExternalIdentifierType.AGR.value());
    weis.getExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Work Title"));
    workTitle.setSubtitle(new Subtitle("Subtitle"));
    TranslatedTitle translated = new TranslatedTitle("Translated", "US");
    workTitle.setTranslatedTitle(translated);
    work.setWorkTitle(workTitle);
    work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkContributors(org.orcid.jaxb.model.record_v2.WorkContributors) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Month(org.orcid.jaxb.model.common_v2.Month) Work(org.orcid.jaxb.model.record_v2.Work) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) ContributorAttributes(org.orcid.jaxb.model.common_v2.ContributorAttributes) 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) Date(java.util.Date) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) PublicationDate(org.orcid.jaxb.model.common_v2.PublicationDate) Subtitle(org.orcid.jaxb.model.common_v2.Subtitle) Year(org.orcid.jaxb.model.common_v2.Year) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) CreatedDate(org.orcid.jaxb.model.common_v2.CreatedDate) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) ContributorOrcid(org.orcid.jaxb.model.common_v2.ContributorOrcid) Day(org.orcid.jaxb.model.common_v2.Day)

Example 72 with Url

use of org.orcid.jaxb.model.common_rc2.Url in project ORCID-Source by ORCID.

the class Utils method getResearcherUrl.

public static ResearcherUrl getResearcherUrl() {
    ResearcherUrl rUrl = new ResearcherUrl();
    rUrl.setUrl(new Url("http://www.myRUrl.com"));
    rUrl.setUrlName("My researcher Url");
    rUrl.setVisibility(Visibility.LIMITED);
    return rUrl;
}
Also used : ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 73 with Url

use of org.orcid.jaxb.model.common_rc2.Url 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.record.summary_v2.WorkSummary) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Works(org.orcid.jaxb.model.record.summary_v2.Works) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 74 with Url

use of org.orcid.jaxb.model.common_rc2.Url in project ORCID-Source by ORCID.

the class ResearcherUrlManagerTest method getResearcherUrl.

private ResearcherUrl getResearcherUrl() {
    ResearcherUrl rUrl = new ResearcherUrl();
    rUrl.setUrl(new Url("http://orcid.org"));
    rUrl.setUrlName("ORCID Site");
    rUrl.setVisibility(Visibility.PUBLIC);
    return rUrl;
}
Also used : ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 75 with Url

use of org.orcid.jaxb.model.common_rc2.Url in project ORCID-Source by ORCID.

the class WorkManagerTest method testCreateWorksWithBulkAllErrors.

@Test
public void testCreateWorksWithBulkAllErrors() {
    String orcid = "0000-0000-0000-0003";
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    //Set up data: 
    //Create one work with a DOI doi-1 so we can create a duplicate
    Work work = new Work();
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("work #1"));
    work.setWorkTitle(workTitle);
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    extId.setType("doi");
    extId.setUrl(new Url("http://doi/1"));
    extId.setValue("doi-1");
    extIds.getExternalIdentifier().add(extId);
    work.setWorkExternalIdentifiers(extIds);
    work.setWorkType(WorkType.BOOK);
    Work newWork = workManager.createWork(orcid, work, true);
    Long putCode = newWork.getPutCode();
    WorkBulk bulk = new WorkBulk();
    //Work # 1: No ext ids
    Work work1 = getWork("work # 1 " + System.currentTimeMillis());
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    //Work # 2: No title
    Work work2 = getWork("work # 2 " + System.currentTimeMillis());
    work2.getWorkTitle().getTitle().setContent(null);
    //Work # 3: No work type
    Work work3 = getWork("work # 3 " + System.currentTimeMillis());
    work3.setWorkType(null);
    //Work # 4: Ext id already exists
    Work work4 = getWork("work # 4 " + System.currentTimeMillis());
    work4.getExternalIdentifiers().getExternalIdentifier().add(extId);
    bulk.getBulk().add(work1);
    bulk.getBulk().add(work2);
    bulk.getBulk().add(work3);
    bulk.getBulk().add(work4);
    bulk = workManager.createWorks(orcid, bulk);
    assertNotNull(bulk);
    assertEquals(4, bulk.getBulk().size());
    for (int i = 0; i < bulk.getBulk().size(); i++) {
        BulkElement element = bulk.getBulk().get(i);
        assertTrue(OrcidError.class.isAssignableFrom(element.getClass()));
        OrcidError error = (OrcidError) element;
        switch(i) {
            case 0:
                assertEquals(Integer.valueOf(9023), error.getErrorCode());
                break;
            case 1:
                assertEquals(Integer.valueOf(9022), error.getErrorCode());
                break;
            case 2:
                assertEquals(Integer.valueOf(9037), error.getErrorCode());
                break;
            case 3:
                assertEquals(Integer.valueOf(9021), error.getErrorCode());
                break;
        }
    }
    //Delete the work
    assertTrue(workManager.checkSourceAndRemoveWork(orcid, putCode));
}
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) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) BulkElement(org.orcid.jaxb.model.record_v2.BulkElement) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Url (org.orcid.jaxb.model.common_v2.Url)86 Test (org.junit.Test)84 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)55 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)37 ClientResponse (com.sun.jersey.api.client.ClientResponse)30 MarshallingTest (org.orcid.jaxb.model.notification.custom.MarshallingTest)24 Title (org.orcid.jaxb.model.common_v2.Title)23 Work (org.orcid.jaxb.model.record_v2.Work)21 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)20 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)18 Validator (javax.xml.validation.Validator)16 Funding (org.orcid.jaxb.model.record_v2.Funding)15 ArrayList (java.util.ArrayList)14 Url (org.orcid.jaxb.model.common_rc3.Url)11 Url (org.orcid.jaxb.model.common_rc4.Url)11 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)11 Response (javax.ws.rs.core.Response)10 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)10 DBUnitTest (org.orcid.test.DBUnitTest)10 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)9