Search in sources :

Example 16 with WorkExternalIdentifier

use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.

the class OrcidProfileCleanerTest method testSimpleClean.

@Test
public void testSimpleClean() {
    OrcidWork orcidWork = new OrcidWork();
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Test Title"));
    workTitle.setSubtitle(new Subtitle(""));
    orcidWork.setWorkTitle(workTitle);
    WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
    orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
    WorkExternalIdentifier workExternalIdentifier1 = new WorkExternalIdentifier();
    workExternalIdentifiers.getWorkExternalIdentifier().add(workExternalIdentifier1);
    workExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    workExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work-doi"));
    orcidProfileCleaner.clean(orcidWork);
    assertEquals("Test Title", orcidWork.getWorkTitle().getTitle().getContent());
    assertEquals("work-doi", orcidWork.getWorkExternalIdentifiers().getWorkExternalIdentifier().get(0).getWorkExternalIdentifierId().getContent());
    assertNull("Subtitle should be null", orcidWork.getWorkTitle().getSubtitle());
}
Also used : Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) Title(org.orcid.jaxb.model.message.Title) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) BaseTest(org.orcid.core.BaseTest) Test(org.junit.Test)

Example 17 with WorkExternalIdentifier

use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.

the class OrcidProfileManagerBaseTest method createWork2Identifiers.

protected WorkExternalIdentifiers createWork2Identifiers() {
    WorkExternalIdentifiers work2ExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier work2ExternalIdentifier1 = new WorkExternalIdentifier();
    work2ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work2ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-doi1"));
    WorkExternalIdentifier work2ExternalIdentifier2 = new WorkExternalIdentifier();
    work2ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
    work2ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work2-pmid"));
    work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier1);
    work2ExternalIdentifiers.getWorkExternalIdentifier().add(work2ExternalIdentifier2);
    return work2ExternalIdentifiers;
}
Also used : WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier)

Example 18 with WorkExternalIdentifier

use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testDuplicatedExternalIdentifiersThrowsException.

@Test
@Transactional
@Rollback(true)
public void testDuplicatedExternalIdentifiersThrowsException() {
    OrcidWork work2 = createWork2();
    OrcidWork work3 = createWork3();
    WorkExternalIdentifier sharedExternalIdentifier1 = new WorkExternalIdentifier();
    sharedExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    sharedExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("shared-doi1"));
    work2.getWorkExternalIdentifiers().getWorkExternalIdentifier().add(sharedExternalIdentifier1);
    work3.getWorkExternalIdentifiers().getWorkExternalIdentifier().add(sharedExternalIdentifier1);
    OrcidProfile profile = createBasicProfile();
    profile = orcidProfileManager.createOrcidProfile(profile, false, false);
    assertNotNull(profile);
    assertNotNull(profile.getOrcidActivities());
    assertNotNull(profile.getOrcidActivities().getOrcidWorks());
    assertNotNull(profile.getOrcidActivities().getOrcidWorks().getOrcidWork());
    assertEquals(1, profile.getOrcidActivities().getOrcidWorks().getOrcidWork().size());
    profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work2);
    profile.getOrcidActivities().getOrcidWorks().getOrcidWork().add(work3);
    try {
        orcidProfileManager.addOrcidWorks(profile);
        fail("This should not pass since we add works with duplicated external identifiers");
    } catch (IllegalArgumentException iae) {
        assertEquals("Works \"Test Title # 2\" and \"Test Title # 3\" have the same external id \"shared-doi1\"", iae.getMessage());
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 19 with WorkExternalIdentifier

use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.

the class OrcidProfileManagerImplTest method testUpdateProfileButRemoveWorkExternalIdentifier.

@Test
@Transactional
@Rollback(true)
public void testUpdateProfileButRemoveWorkExternalIdentifier() {
    OrcidProfile profile1 = createBasicProfile();
    profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
    List<WorkExternalIdentifier> workExternalIdentifiers = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkExternalIdentifiers().getWorkExternalIdentifier();
    assertEquals(3, workExternalIdentifiers.size());
    Iterator<WorkExternalIdentifier> workExternalIdentifiersIterator = workExternalIdentifiers.iterator();
    while (workExternalIdentifiersIterator.hasNext()) {
        if (WorkExternalIdentifierType.PMID.equals(workExternalIdentifiersIterator.next().getWorkExternalIdentifierType())) {
            workExternalIdentifiersIterator.remove();
        }
    }
    profile1 = orcidProfileManager.updateOrcidProfile(profile1);
    OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertNotNull(resultProfile);
    assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    assertEquals(1, resultProfile.retrieveOrcidWorks().getOrcidWork().size());
    assertEquals(1, resultProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().size());
    assertEquals("http://www.wjrs.co.uk", resultProfile.getOrcidBio().getResearcherUrls().getResearcherUrl().get(0).getUrl().getValue());
    assertEquals(2, resultProfile.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getWorkExternalIdentifiers().getWorkExternalIdentifier().size());
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with WorkExternalIdentifier

use of org.orcid.jaxb.model.message.WorkExternalIdentifier in project ORCID-Source by ORCID.

the class OrcidProfileManagerBaseTest method createWork3Identifiers.

protected WorkExternalIdentifiers createWork3Identifiers() {
    WorkExternalIdentifiers work3ExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier work3ExternalIdentifier1 = new WorkExternalIdentifier();
    work3ExternalIdentifier1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    work3ExternalIdentifier1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi1"));
    WorkExternalIdentifier work3ExternalIdentifier2 = new WorkExternalIdentifier();
    work3ExternalIdentifier2.setWorkExternalIdentifierType(WorkExternalIdentifierType.PMID);
    work3ExternalIdentifier2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("work3-doi2"));
    work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier1);
    work3ExternalIdentifiers.getWorkExternalIdentifier().add(work3ExternalIdentifier2);
    return work3ExternalIdentifiers;
}
Also used : WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier)

Aggregations

WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)22 WorkExternalIdentifierId (org.orcid.jaxb.model.message.WorkExternalIdentifierId)17 WorkExternalIdentifiers (org.orcid.jaxb.model.message.WorkExternalIdentifiers)16 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)15 Title (org.orcid.jaxb.model.message.Title)13 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)11 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)10 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)10 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)8 Test (org.junit.Test)7 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)7 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)6 Source (org.orcid.jaxb.model.message.Source)5 Transactional (org.springframework.transaction.annotation.Transactional)5 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)4 DBUnitTest (org.orcid.test.DBUnitTest)4 ArrayList (java.util.ArrayList)3 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)3 Email (org.orcid.jaxb.model.message.Email)3 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)3