Search in sources :

Example 6 with Source

use of org.orcid.jaxb.model.message.Source 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 7 with Source

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

the class OrcidProfileManagerImpl method createSource.

private Source createSource(String amenderOrcid) {
    Source source = new Source();
    if (OrcidStringUtils.isValidOrcid(amenderOrcid)) {
        source.setSourceOrcid(new SourceOrcid(amenderOrcid));
        source.setSourceClientId(null);
    } else {
        source.setSourceClientId(new SourceClientId(amenderOrcid));
        source.setSourceOrcid(null);
    }
    return source;
}
Also used : SourceClientId(org.orcid.jaxb.model.message.SourceClientId) SourceOrcid(org.orcid.jaxb.model.message.SourceOrcid) Source(org.orcid.jaxb.model.message.Source)

Example 8 with Source

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

the class OrcidProfileManagerImpl method addSourceToWorks.

private void addSourceToWorks(OrcidWorks orcidWorks, String amenderOrcid) {
    if (orcidWorks != null && !orcidWorks.getOrcidWork().isEmpty() && amenderOrcid != null) {
        for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
            Source source = createSource(amenderOrcid);
            orcidWork.setSource(source);
        }
    }
}
Also used : OrcidWork(org.orcid.jaxb.model.message.OrcidWork) Source(org.orcid.jaxb.model.message.Source)

Example 9 with Source

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

the class JpaJaxbEntityAdapterToOrcidProfileTest method checkOrcidHistory.

private void checkOrcidHistory(OrcidHistory orcidHistory) {
    assertNotNull(orcidHistory);
    Source sponsor = orcidHistory.getSource();
    assertNotNull(sponsor);
    assertEquals("Credit Name", sponsor.getSourceName().getContent());
    assertEquals("4444-4444-4444-4441", sponsor.retrieveSourcePath());
    assertEquals(DateUtils.convertToDate("2011-07-02T15:31:00"), orcidHistory.getLastModifiedDate().getValue().toGregorianCalendar().getTime());
    assertEquals(DateUtils.convertToDate("2011-06-29T15:31:00"), orcidHistory.getSubmissionDate().getValue().toGregorianCalendar().getTime());
    assertEquals(DateUtils.convertToDate("2011-07-02T15:31:00"), orcidHistory.getCompletionDate().getValue().toGregorianCalendar().getTime());
}
Also used : Source(org.orcid.jaxb.model.message.Source)

Example 10 with Source

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

the class OrcidProfileManagerImplTest method testAddOrcidWorkToUnclaimedProfile.

@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorkToUnclaimedProfile() {
    OrcidProfile profile1 = createBasicProfile();
    orcidProfileManager.createOrcidProfile(profile1, false, false);
    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);
    work2.setVisibility(Visibility.PUBLIC);
    orcidWorks.getOrcidWork().add(work2);
    // Try to add a duplicate
    WorkTitle workTitle3 = new WorkTitle();
    workTitle3.setTitle(new Title("Further Title"));
    workTitle3.setSubtitle(new Subtitle("Further subtitle"));
    OrcidWork work3 = createWork3(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(4, 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) {
        if ("Further Title".equals(work.getWorkTitle().getTitle().getContent()))
            assertEquals(Visibility.LIMITED, work.getVisibility());
        else if ("New Title".equals(work.getWorkTitle().getTitle().getContent()))
            assertEquals(Visibility.PUBLIC, work.getVisibility());
        else
            assertEquals(Visibility.PRIVATE, work.getVisibility());
    }
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Subtitle(org.orcid.jaxb.model.message.Subtitle) WorkTitle(org.orcid.jaxb.model.message.WorkTitle) 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) Source(org.orcid.jaxb.model.message.Source) OrcidWorks(org.orcid.jaxb.model.message.OrcidWorks) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Source (org.orcid.jaxb.model.message.Source)30 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)14 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)11 SourceOrcid (org.orcid.jaxb.model.message.SourceOrcid)10 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)9 Title (org.orcid.jaxb.model.message.Title)9 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)8 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)8 Test (org.junit.Test)7 Subtitle (org.orcid.jaxb.model.message.Subtitle)7 WorkExternalIdentifier (org.orcid.jaxb.model.message.WorkExternalIdentifier)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Date (java.util.Date)6 WorkTitle (org.orcid.jaxb.model.message.WorkTitle)6 HashMap (java.util.HashMap)5 Claimed (org.orcid.jaxb.model.message.Claimed)5 Email (org.orcid.jaxb.model.message.Email)5 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)5 OrcidWorks (org.orcid.jaxb.model.message.OrcidWorks)5 SourceClientId (org.orcid.jaxb.model.message.SourceClientId)5