use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testCopyUpdatedWorksToExistingWithVisibility.
@Test
public void testCopyUpdatedWorksToExistingWithVisibility() throws Exception {
OrcidWorks worksToUpdate = publicOrcidMessage.getOrcidProfile().retrieveOrcidWorks();
OrcidWorks existingWorks = protectedOrcidMessage.getOrcidProfile().retrieveOrcidWorks();
checkWorksVisibility(null, worksToUpdate.getOrcidWork());
// update is private, so the update should persist and alter the
// existing as well
assertEquals("Work title 1", existingWorks.getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
assertEquals(Visibility.PUBLIC, existingWorks.getOrcidWork().get(0).getVisibility());
assertEquals("Work title 2", existingWorks.getOrcidWork().get(1).getWorkTitle().getTitle().getContent());
assertNull(existingWorks.getOrcidWork().get(1).getVisibility());
assertEquals("Work Title 3", existingWorks.getOrcidWork().get(2).getWorkTitle().getTitle().getContent());
assertNull(existingWorks.getOrcidWork().get(2).getVisibility());
worksToUpdate.getOrcidWork().get(0).getWorkTitle().getTitle().setContent("updated-work-title-1");
worksToUpdate.getOrcidWork().get(0).setVisibility(Visibility.PRIVATE);
worksToUpdate.getOrcidWork().get(1).getWorkTitle().getTitle().setContent("updated-work-title-2");
worksToUpdate.getOrcidWork().get(2).getWorkTitle().getTitle().setContent("updated-work-title-3");
orcidJaxbCopyManager.copyUpdatedWorksPreservingVisbility(existingWorks, worksToUpdate);
assertEquals("updated-work-title-1", existingWorks.getOrcidWork().get(0).getWorkTitle().getTitle().getContent());
assertEquals("updated-work-title-2", existingWorks.getOrcidWork().get(1).getWorkTitle().getTitle().getContent());
assertEquals("updated-work-title-3", existingWorks.getOrcidWork().get(2).getWorkTitle().getTitle().getContent());
// check the update was copied across
assertEquals(Visibility.PRIVATE, existingWorks.getOrcidWork().get(0).getVisibility());
// check that as null was supplied as an update, the works default was
// used
assertEquals(Visibility.PUBLIC, existingWorks.getOrcidWork().get(1).getVisibility());
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class RegistrationControllerTest method createBasicProfile.
protected OrcidProfile createBasicProfile() {
OrcidProfile profile = new OrcidProfile();
profile.setPassword("password");
profile.setVerificationCode("1234");
profile.setSecurityQuestionAnswer("random answer");
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);
return profile;
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method addSourceToWorks.
/**
* Add source to the profile works
*
* @param orcidProfile
* The profile
* @param amenderOrcid
* The orcid of the user or client that add the work to the
* profile user
* */
private void addSourceToWorks(OrcidProfile orcidProfile, String amenderOrcid) {
OrcidWorks orcidWorks = orcidProfile.getOrcidActivities() == null ? null : orcidProfile.getOrcidActivities().getOrcidWorks();
addSourceToWorks(orcidWorks, amenderOrcid);
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method setWorkPrivacy.
private void setWorkPrivacy(OrcidProfile updatedOrcidProfile, Visibility defaultWorkVisibility) {
OrcidHistory orcidHistory = updatedOrcidProfile.getOrcidHistory();
boolean isClaimed = orcidHistory != null ? orcidHistory.getClaimed().isValue() : false;
OrcidActivities incomingActivities = updatedOrcidProfile.getOrcidActivities();
if (incomingActivities != null) {
OrcidWorks incomingWorks = incomingActivities.getOrcidWorks();
if (incomingWorks != null) {
setWorkPrivacy(incomingWorks, defaultWorkVisibility, isClaimed);
}
}
}
use of org.orcid.jaxb.model.message.OrcidWorks in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method dedupeWorks.
@Override
public OrcidWorks dedupeWorks(OrcidWorks orcidWorks) {
Set<OrcidWork> workSet = new LinkedHashSet<OrcidWork>();
for (OrcidWork orcidWork : orcidWorks.getOrcidWork()) {
orcidProfileCleaner.clean(orcidWork);
workSet.add(orcidWork);
}
OrcidWorks dedupedOrcidWorks = new OrcidWorks();
dedupedOrcidWorks.getOrcidWork().addAll(workSet);
return dedupedOrcidWorks;
}
Aggregations