use of org.orcid.jaxb.model.message.WorkTitle 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());
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createWork1.
protected OrcidWork createWork1() {
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Test Title"));
workTitle.setSubtitle(new Subtitle("Subtitle # 1"));
TranslatedTitle tt = new TranslatedTitle();
tt.setContent("Titulo prueba");
tt.setLanguageCode("es_CR");
workTitle.setTranslatedTitle(tt);
return createWork1(workTitle);
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createWork2.
protected OrcidWork createWork2() {
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Test Title # 2"));
workTitle.setSubtitle(new Subtitle("Subtitle # 2"));
TranslatedTitle tt = new TranslatedTitle();
tt.setContent("Titulo prueba # 2");
tt.setLanguageCode("es_MX");
workTitle.setTranslatedTitle(tt);
return createWork2(workTitle);
}
use of org.orcid.jaxb.model.message.WorkTitle 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());
}
}
use of org.orcid.jaxb.model.message.WorkTitle in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method getOrcidWork.
private OrcidWork getOrcidWork(String workName, boolean isExistingWork) {
OrcidWork orcidWork = new OrcidWork();
if (isExistingWork) {
orcidWork.setPutCode(String.valueOf(currentWorkId));
currentWorkId += 1;
}
//Set title
WorkTitle title = new WorkTitle();
if (isExistingWork)
title.setTitle(new Title("Title for " + workName));
else
title.setTitle(new Title("Title for " + workName + "->updated"));
orcidWork.setWorkTitle(title);
//Set source
Source workSource = new Source(TEST_ORCID);
orcidWork.setSource(workSource);
//Set external identifiers
WorkExternalIdentifier extId1 = new WorkExternalIdentifier();
extId1.setWorkExternalIdentifierId(new WorkExternalIdentifierId("doi-" + workName));
extId1.setWorkExternalIdentifierType(WorkExternalIdentifierType.DOI);
WorkExternalIdentifier extId2 = new WorkExternalIdentifier();
if (isExistingWork)
extId2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("issn-" + workName));
else
extId2.setWorkExternalIdentifierId(new WorkExternalIdentifierId("issn-" + workName + "->updated"));
extId2.setWorkExternalIdentifierType(WorkExternalIdentifierType.ISSN);
WorkExternalIdentifiers extIds = new WorkExternalIdentifiers();
extIds.getWorkExternalIdentifier().add(extId1);
extIds.getWorkExternalIdentifier().add(extId2);
orcidWork.setWorkExternalIdentifiers(extIds);
return orcidWork;
}
Aggregations