use of org.orcid.jaxb.model.message.Biography in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerImpl method copyUpdatedShortDescriptionToExistingPreservingVisibility.
@Override
public void copyUpdatedShortDescriptionToExistingPreservingVisibility(OrcidBio existing, OrcidBio updated) {
if (updated.getBiography() == null) {
return;
}
Biography existingShortDescription = existing.getBiography();
Biography updatedShortDescription = updated.getBiography();
Visibility existingShortDescriptionVisibility = existingShortDescription != null ? existingShortDescription.getVisibility() : OrcidVisibilityDefaults.SHORT_DESCRIPTION_DEFAULT.getVisibility();
Visibility updatedShortDescriptionVisibility = updatedShortDescription != null ? updatedShortDescription.getVisibility() : existingShortDescriptionVisibility;
if (updatedShortDescriptionVisibility == null && existingShortDescriptionVisibility == null) {
updatedShortDescription.setVisibility(OrcidVisibilityDefaults.SHORT_DESCRIPTION_DEFAULT.getVisibility());
} else if (updatedShortDescriptionVisibility == null && existingShortDescriptionVisibility != null) {
updatedShortDescription.setVisibility(existingShortDescriptionVisibility);
}
if (existingShortDescription != null) {
if (existingShortDescription.getVisibility() != null && !existingShortDescription.getVisibility().equals(Visibility.PRIVATE)) {
existing.setBiography(updatedShortDescription);
}
} else {
existing.setBiography(updatedShortDescription);
}
}
use of org.orcid.jaxb.model.message.Biography in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdatedBiographyToExistingPreservingVisibility.
@Test
public void testUpdatedBiographyToExistingPreservingVisibility() throws Exception {
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
assertEquals(Visibility.LIMITED, existingOrcidBioProtected.getBiography().getVisibility());
String existingContent = "Josiah Stinkney Carberry is a fictional professor.";
assertEquals(existingContent, existingOrcidBioProtected.getBiography().getContent().trim());
assertNull(updatedOrcidBioPublic.getBiography().getVisibility());
updatedOrcidBioPublic.setBiography(new Biography("A new bio"));
updatedOrcidBioPublic.getBiography().setVisibility(Visibility.PRIVATE);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
// check that changes have propogated
assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getBiography().getVisibility());
assertEquals("A new bio", existingOrcidBioProtected.getBiography().getContent());
// reset the variable and attempt to override the content and visibility
updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
updatedOrcidBioPublic.setBiography(new Biography("A new and impoved bio"));
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
// check that the old values have been retained
assertEquals(Visibility.PRIVATE, existingOrcidBioProtected.getBiography().getVisibility());
assertEquals("A new bio", existingOrcidBioProtected.getBiography().getContent());
}
use of org.orcid.jaxb.model.message.Biography in project ORCID-Source by ORCID.
the class OrcidProfileManagerImplTest method setBio.
private void setBio(OrcidProfile profile, Visibility defaultVisibility) {
OrcidBio bio = new OrcidBio();
Biography biography = new Biography("This is my biography");
if (defaultVisibility != null) {
biography.setVisibility(defaultVisibility);
}
bio.setBiography(biography);
ContactDetails contactDetails = new ContactDetails();
Address address = new Address();
address.setCountry(new Country(Iso3166Country.US));
if (defaultVisibility != null) {
address.getCountry().setVisibility(defaultVisibility);
}
contactDetails.setAddress(address);
List<Email> emails = new ArrayList<Email>();
Email email = new Email();
email.setPrimary(true);
email.setValue(System.currentTimeMillis() + "@test.orcid.org");
emails.add(email);
contactDetails.setEmail(emails);
bio.setContactDetails(contactDetails);
ExternalIdentifiers extIds = new ExternalIdentifiers();
ExternalIdentifier extId = new ExternalIdentifier();
extId.setExternalIdCommonName(new ExternalIdCommonName("common-name"));
extId.setExternalIdReference(new ExternalIdReference("ext-id-reference"));
extId.setExternalIdUrl(new ExternalIdUrl("http://orcid.org/ext-id"));
extIds.getExternalIdentifier().add(extId);
if (defaultVisibility != null) {
extIds.setVisibility(defaultVisibility);
}
bio.setExternalIdentifiers(extIds);
Keywords keywords = new Keywords();
Keyword keyword = new Keyword();
keyword.setContent("k1");
keywords.getKeyword().add(keyword);
if (defaultVisibility != null) {
keywords.setVisibility(defaultVisibility);
}
bio.setKeywords(keywords);
PersonalDetails personalDetails = new PersonalDetails();
personalDetails.setCreditName(new CreditName("credit-name"));
personalDetails.setGivenNames(new GivenNames("given-names"));
personalDetails.setFamilyName(new FamilyName("family-name"));
OtherNames otherNames = new OtherNames();
OtherName otherName = new OtherName();
otherName.setContent("o1");
otherNames.getOtherName().add(otherName);
if (defaultVisibility != null) {
otherNames.setVisibility(defaultVisibility);
}
personalDetails.setOtherNames(otherNames);
bio.setPersonalDetails(personalDetails);
ResearcherUrls researcherUrls = new ResearcherUrls();
ResearcherUrl researcherUrl = new ResearcherUrl();
researcherUrl.setUrl(new Url("http://orcid.org/researcher-url-1"));
researcherUrl.setUrlName(new UrlName("url-name-1"));
researcherUrls.getResearcherUrl().add(researcherUrl);
if (defaultVisibility != null) {
researcherUrls.setVisibility(defaultVisibility);
}
bio.setResearcherUrls(researcherUrls);
profile.setOrcidBio(bio);
}
use of org.orcid.jaxb.model.message.Biography 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.Biography in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method deactivateOrcidProfile.
@Override
@Transactional
@Deprecated
public OrcidProfile deactivateOrcidProfile(OrcidProfile existingOrcidProfile) {
OrcidProfile blankedOrcidProfile = new OrcidProfile();
OrcidBio existingBio = existingOrcidProfile.getOrcidBio();
OrcidBio minimalBio = new OrcidBio();
ContactDetails minimalContactDetails = new ContactDetails();
minimalContactDetails.getEmail().addAll(existingBio.getContactDetails().getEmail());
OrcidInternal minimalOrcidInternal = new OrcidInternal();
minimalOrcidInternal.setSecurityDetails(existingOrcidProfile.getOrcidInternal().getSecurityDetails());
OrcidHistory deactivatedOrcidHistory = existingOrcidProfile.getOrcidHistory();
deactivatedOrcidHistory.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
blankedOrcidProfile.setOrcidHistory(deactivatedOrcidHistory);
// only names names from bio with a visibility setting
PersonalDetails minimalPersonalDetails = new PersonalDetails();
minimalPersonalDetails.setOtherNames(null);
CreditName creditName = new CreditName();
creditName.setVisibility(Visibility.PUBLIC);
minimalPersonalDetails.setCreditName(creditName);
minimalPersonalDetails.setGivenNames(new GivenNames("Given Names Deactivated"));
minimalPersonalDetails.setFamilyName(new FamilyName("Family Name Deactivated"));
for (Email email : minimalContactDetails.getEmail()) {
setVisibilityToPrivate(email);
}
setVisibilityToPrivate(minimalPersonalDetails.getOtherNames());
if (minimalPersonalDetails.getOtherNames() != null && minimalPersonalDetails.getOtherNames().getOtherName() != null) {
for (OtherName name : minimalPersonalDetails.getOtherNames().getOtherName()) setVisibilityToPrivate(name);
}
minimalBio.setPersonalDetails(minimalPersonalDetails);
minimalBio.setContactDetails(minimalContactDetails);
minimalBio.setBiography(new Biography());
minimalBio.setExternalIdentifiers(new ExternalIdentifiers());
blankedOrcidProfile.setOrcidBio(minimalBio);
blankedOrcidProfile.setOrcidIdentifier(existingOrcidProfile.getOrcidIdentifier().getPath());
OrcidProfile profileToReturn = updateOrcidProfile(blankedOrcidProfile);
userConnectionDao.deleteByOrcid(existingOrcidProfile.getOrcidIdentifier().getPath());
notificationManager.sendAmendEmail(profileToReturn, AmendedSection.UNKNOWN);
return profileToReturn;
}
Aggregations