use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerBaseTest method createBasicProfile.
protected OrcidProfile createBasicProfile() {
OrcidProfile profile = new OrcidProfile();
profile.setPassword("password");
profile.setVerificationCode("1234");
profile.setSecurityQuestionAnswer("random answer");
profile.setOrcidIdentifier(TEST_ORCID);
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("will@semantico.com"));
bio.setContactDetails(contactDetails);
profile.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
bio.setPersonalDetails(personalDetails);
personalDetails.setGivenNames(new GivenNames("Will"));
personalDetails.setFamilyName(new FamilyName("Simpson"));
bio.setBiography(new Biography("Will is a software developer"));
ResearcherUrls researcherUrls = new ResearcherUrls();
bio.setResearcherUrls(researcherUrls);
researcherUrls.getResearcherUrl().add(new ResearcherUrl(new Url("http://www.wjrs.co.uk"), null));
OrcidWorks orcidWorks = new OrcidWorks();
profile.setOrcidWorks(orcidWorks);
OrcidWork orcidWork = createWork1();
// TODO JB - needs test
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
// orcidWork.setAddedToProfileDate(new
// AddedToProfileDate(DateUtils.convertToXMLGregorianCalendar("2010-03-04")));
orcidWorks.getOrcidWork().add(orcidWork);
OrcidInternal orcidInternal = new OrcidInternal();
profile.setOrcidInternal(orcidInternal);
SecurityDetails securityDetails = new SecurityDetails();
securityDetails.setSecurityQuestionId(new SecurityQuestionId(3));
orcidInternal.setSecurityDetails(securityDetails);
Preferences preferences = new Preferences();
orcidInternal.setPreferences(preferences);
return profile;
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsPrivate.
@Test
@Transactional
public void testAddOrcidWorksWhenDefaultVisibilityIsPrivate() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.PRIVATE));
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);
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 ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PRIVATE, work.getVisibility());
else
assertEquals(Visibility.PRIVATE, work.getVisibility());
}
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testUpdatePersonalInformationRemovesOrcidIndexFields.
@Test
@Transactional
@Rollback(true)
public void testUpdatePersonalInformationRemovesOrcidIndexFields() throws Exception {
// re-use the createFull method but add some extra criteria so we can
// use our specific orcidAllSolrFieldsPopulatedForSave matcher
OrcidProfile profile = createFullOrcidProfile();
OtherNames otherNames = new OtherNames();
otherNames.getOtherName().add(new OtherName("Stan", null));
otherNames.getOtherName().add(new OtherName("Willis", null));
profile.getOrcidBio().getPersonalDetails().setOtherNames(otherNames);
OrcidWorks orcidWorks = new OrcidWorks();
profile.setOrcidWorks(orcidWorks);
WorkTitle singleWorkTitle = new WorkTitle();
singleWorkTitle.setTitle(new Title("Single works"));
singleWorkTitle.setSubtitle(new Subtitle("Single works"));
OrcidWork orcidWork = createWork1(singleWorkTitle);
// TODO JB some doi testing here?
// orcidWork.getElectronicResourceNum().add(new
// ElectronicResourceNum("10.1016/S0021-8502(00)90373-2",
// ElectronicResourceNumType.DOI));
orcidWorks.getOrcidWork().add(orcidWork);
orcidProfileManager.createOrcidProfile(profile, false, false);
// now negate all fields that form part of a solr query, leaving only
// the orcid itself
// we do this by passing through an orcid missing the fields from an
// OrcidSolrDocument
OrcidProfile negatedProfile = createBasicProfile();
negatedProfile.getOrcidBio().getPersonalDetails().setFamilyName(null);
negatedProfile.getOrcidBio().getPersonalDetails().setGivenNames(null);
negatedProfile.getOrcidBio().getPersonalDetails().setCreditName(null);
negatedProfile.getOrcidBio().getPersonalDetails().setOtherNames(null);
negatedProfile.getOrcidActivities().setAffiliations(null);
orcidProfileManager.updateOrcidBio(negatedProfile);
assertEquals(IndexingStatus.PENDING, profileDao.find(TEST_ORCID).getIndexingStatus());
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method testAddOrcidWorksWhenDefaultVisibilityIsLimited.
@Test
@Transactional
@Rollback(true)
public void testAddOrcidWorksWhenDefaultVisibilityIsLimited() {
OrcidProfile profile1 = createBasicProfile();
OrcidHistory history = new OrcidHistory();
history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile1.setOrcidHistory(history);
history.setClaimed(new Claimed(true));
profile1.getOrcidInternal().getPreferences().setActivitiesVisibilityDefault(new ActivitiesVisibilityDefault(Visibility.LIMITED));
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);
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 ("Test Title".equals(work.getWorkTitle().getTitle().getContent()))
assertEquals(Visibility.PRIVATE, work.getVisibility());
else
assertEquals(Visibility.LIMITED, work.getVisibility());
}
}
use of org.orcid.jaxb.model.message.OrcidWork in project ORCID-Source by ORCID.
the class OrcidProfileManagerContributorVisibilityTest method emailProvidedAndDoesExistInDbButCreditNameAndEmailArePrivate.
@Test
@Transactional
public void emailProvidedAndDoesExistInDbButCreditNameAndEmailArePrivate() {
// Unmarshall message containing contributor email
OrcidMessage orcidMessage = unmarshallOrcidMessage("new_work_with_contributor_email_and_name.xml");
// Change email to one that exists in DB
orcidMessage.getOrcidProfile().retrieveOrcidWorks().getOrcidWork().get(0).getWorkContributors().getContributor().get(0).getContributorEmail().setValue("otis@reading.com");
// Add the work
orcidProfileManager.addOrcidWorks(orcidMessage.getOrcidProfile());
// Get it back from the API
OrcidWork retrievedWork = retrieveAddedWorkFromApi();
Contributor workContributor = retrievedWork.getWorkContributors().getContributor().get(0);
// Check that the contributor name is not included in the resulting
// work, because it is private
assertNull(workContributor.getCreditName());
// Check that the email is not included in the resulting work, because
// never want to show email
assertNull(workContributor.getContributorEmail());
// Get the contributor directly from the DB so can see stuff not
// included in the API
Contributor workContributorDirectFromDb = retrieveWorkContributorEntityDirectlyFromDb(retrievedWork);
// Check the email is in the DB for later use if needed
assertEquals("otis@reading.com", workContributorDirectFromDb.getContributorEmail().getValue());
}
Aggregations