Search in sources :

Example 1 with OrcidWorks

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

the class T2OrcidApiServiceDelegatorTest method testAddWorkToDeprecatedAccount.

@Test(expected = OrcidDeprecatedException.class)
public void testAddWorkToDeprecatedAccount() {
    SecurityContextTestUtils.setUpSecurityContext();
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-444X"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWork work = new OrcidWork();
    WorkTitle title = new WorkTitle();
    title.setTitle(new Title("Title"));
    work.setWorkTitle(title);
    WorkExternalIdentifiers weis = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("00000001"));
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    weis.getWorkExternalIdentifier().add(wei);
    work.setWorkExternalIdentifiers(weis);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    t2OrcidApiServiceDelegator.addWorks(mockedUriInfo, "4444-4444-4444-444X", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 2 with OrcidWorks

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

the class T2OrcidApiServiceDelegatorTest method testUpdateWithNewWork.

@Test
@Transactional
public void testUpdateWithNewWork() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = new OrcidWork();
    orcidWorks.getOrcidWork().add(orcidWork);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Added by works update"));
    orcidWork.setWorkTitle(workTitle);
    orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
    workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
    orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
    Response response = t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
    assertNotNull(response);
    OrcidProfile retrievedProfile = orcidProfileManager.retrieveOrcidProfile("4444-4444-4444-4446");
    List<OrcidWork> retreivedWorksList = retrievedProfile.getOrcidActivities().getOrcidWorks().getOrcidWork();
    boolean foundWorkFromAnotherSource = false;
    boolean foundExisting = false;
    boolean foundNew = false;
    boolean foundExistingPrivate = false;
    // another source
    for (OrcidWork retrievedWork : retreivedWorksList) {
        if ("6".equals(retrievedWork.getPutCode())) {
            assertEquals("Journal article B", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.LIMITED, retrievedWork.getVisibility());
            foundWorkFromAnotherSource = true;
        } else if ("7".equals(retrievedWork.getPutCode())) {
            // Existing private work
            assertEquals("Journal article C", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
            foundExisting = true;
        } else if ("8".equals(retrievedWork.getPutCode())) {
            // Existing private work added by the user
            assertEquals("Journal article D", retrievedWork.getWorkTitle().getTitle().getContent());
            assertEquals(Visibility.PRIVATE, retrievedWork.getVisibility());
            foundExistingPrivate = true;
        } else {
            // The added work
            assertEquals("Added by works update", retrievedWork.getWorkTitle().getTitle().getContent());
            foundNew = true;
        }
    }
    assertTrue("Work from other source should be there", foundWorkFromAnotherSource);
    assertTrue("New work should be there", foundNew);
    assertTrue("Existing private work should be there", foundExisting);
    assertTrue("Existing private work added by the user should be there", foundExistingPrivate);
    assertEquals(4, retreivedWorksList.size());
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Response(javax.ws.rs.core.Response) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with OrcidWorks

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

the class T2OrcidApiServiceDelegatorTest method testUpdateWorkWhenNotSource.

@Test(expected = WrongSourceException.class)
@Transactional
public void testUpdateWorkWhenNotSource() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4446", ScopePathType.ORCID_WORKS_UPDATE);
    OrcidMessage orcidMessage = new OrcidMessage();
    orcidMessage.setMessageVersion("1.2_rc6");
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidMessage.setOrcidProfile(orcidProfile);
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier("4444-4444-4444-4446"));
    OrcidActivities orcidActivities = new OrcidActivities();
    orcidProfile.setOrcidActivities(orcidActivities);
    OrcidWorks orcidWorks = new OrcidWorks();
    orcidActivities.setOrcidWorks(orcidWorks);
    OrcidWork orcidWork = new OrcidWork();
    orcidWorks.getOrcidWork().add(orcidWork);
    orcidWork.setPutCode("6");
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("Updated by works update"));
    orcidWork.setWorkTitle(workTitle);
    orcidWork.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
    WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
    WorkExternalIdentifier wei = new WorkExternalIdentifier();
    wei.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
    wei.setWorkExternalIdentifierId(new WorkExternalIdentifierId("abc123"));
    workExternalIdentifiers.getWorkExternalIdentifier().add(wei);
    orcidWork.setWorkExternalIdentifiers(workExternalIdentifiers);
    t2OrcidApiServiceDelegator.updateWorks(mockedUriInfo, "4444-4444-4444-4446", orcidMessage);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) WorkExternalIdentifiers(org.orcid.jaxb.model.message.WorkExternalIdentifiers) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) WorkExternalIdentifierId(org.orcid.jaxb.model.message.WorkExternalIdentifierId) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) WorkExternalIdentifier(org.orcid.jaxb.model.message.WorkExternalIdentifier) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with OrcidWorks

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

the class OrcidProfileManagerImplTest method testAddOrcidWorks.

@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorks() {
    OrcidProfile profile1 = createBasicProfile();
    OrcidHistory history = new OrcidHistory();
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    profile1.setOrcidHistory(history);
    history.setClaimed(new Claimed(true));
    profile1 = orcidProfileManager.createOrcidProfile(profile1, false, false);
    String originalPutCode = profile1.getOrcidActivities().getOrcidWorks().getOrcidWork().get(0).getPutCode();
    OrcidProfile profile2 = new OrcidProfile();
    profile2.setOrcidIdentifier(TEST_ORCID);
    OrcidWorks orcidWorks = new OrcidWorks();
    profile2.setOrcidWorks(orcidWorks);
    WorkTitle workTitle1 = new WorkTitle();
    workTitle1.setTitle(new Title("Another Title"));
    workTitle1.setSubtitle(new Subtitle("Journal of Cloud Spotting"));
    OrcidWork work1 = createWork1(workTitle1);
    Source source = new Source(TEST_ORCID);
    work1.setSource(source);
    orcidWorks.getOrcidWork().add(work1);
    WorkTitle workTitle2 = new WorkTitle();
    workTitle2.setTitle(new Title("New Title"));
    workTitle2.setSubtitle(new Subtitle("Another New subtitle"));
    OrcidWork work2 = createWork2(workTitle2);
    orcidWorks.getOrcidWork().add(work2);
    // Try to add a duplicate
    WorkTitle workTitle3 = new WorkTitle();
    workTitle3.setTitle(new Title("New Title"));
    workTitle3.setSubtitle(new Subtitle("Another New subtitle"));
    OrcidWork work3 = createWork2(workTitle3);
    work3.setVisibility(Visibility.LIMITED);
    orcidWorks.getOrcidWork().add(work3);
    orcidProfileManager.addOrcidWorks(profile2);
    OrcidProfile resultProfile = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    assertEquals("Will", resultProfile.getOrcidBio().getPersonalDetails().getGivenNames().getContent());
    List<OrcidWork> works = resultProfile.retrieveOrcidWorks().getOrcidWork();
    assertEquals(3, works.size());
    assertEquals("Another Title", works.get(0).getWorkTitle().getTitle().getContent());
    assertEquals("Journal of Cloud Spotting", works.get(0).getWorkTitle().getSubtitle().getContent());
    for (OrcidWork work : works) {
        assertEquals(Visibility.PRIVATE, work.getVisibility());
    }
    assertEquals("Put code of original work should not have changed", originalPutCode, works.get(2).getPutCode());
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Title(org.orcid.jaxb.model.message.Title) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) FundingTitle(org.orcid.jaxb.model.message.FundingTitle) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Date(java.util.Date) ApprovalDate(org.orcid.jaxb.model.message.ApprovalDate) Claimed(org.orcid.jaxb.model.message.Claimed) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with OrcidWorks

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

the class OrcidProfileManagerContributorVisibilityTest method retrieveAddedWorkFromApi.

private OrcidWork retrieveAddedWorkFromApi() {
    OrcidProfile retrieved = orcidProfileManager.retrieveOrcidProfile(TEST_ORCID);
    OrcidWorks orcidWorks = retrieved.retrieveOrcidWorks();
    assertNotNull(orcidWorks);
    List<OrcidWork> orcidWorkList = orcidWorks.getOrcidWork();
    assertEquals(1, orcidWorkList.size());
    return orcidWorkList.get(0);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) OrcidWork(org.orcid.jaxb.model.message.OrcidWork) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks)

Aggregations

OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)46 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)35 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)32 Test (org.junit.Test)24 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)19 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)15 Title (org.orcid.jaxb.model.message.Title)15 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)13 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)13 Transactional (org.springframework.transaction.annotation.Transactional)12 FundingList (org.orcid.jaxb.model.message.FundingList)9 Funding (org.orcid.jaxb.model.message.Funding)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)8 OrcidIdentifier (org.orcid.jaxb.model.message.OrcidIdentifier)8 DBUnitTest (org.orcid.test.DBUnitTest)8 Rollback (org.springframework.test.annotation.Rollback)8 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 Date (java.util.Date)6 Affiliations (org.orcid.jaxb.model.message.Affiliations)6 Subtitle (org.orcid.jaxb.model.message.Subtitle)6