use of org.orcid.jaxb.model.message.ContactDetails in project ORCID-Source by ORCID.
the class RegistrationManagerImplTest method createBasicProfile.
private OrcidProfile createBasicProfile(String email, boolean claimed, String sourceId) {
OrcidProfile profile = new OrcidProfile();
profile.setPassword("password");
profile.setVerificationCode("1234");
OrcidBio bio = new OrcidBio();
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email(email));
bio.setContactDetails(contactDetails);
profile.setOrcidBio(bio);
PersonalDetails personalDetails = new PersonalDetails();
bio.setPersonalDetails(personalDetails);
personalDetails.setGivenNames(new GivenNames("New"));
personalDetails.setFamilyName(new FamilyName("User"));
OrcidHistory orcidHistory = new OrcidHistory();
orcidHistory.setClaimed(new Claimed(claimed));
orcidHistory.setCreationMethod(CreationMethod.DIRECT);
orcidHistory.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
profile.setOrcidHistory(orcidHistory);
// Set the source
profile.getOrcidHistory().setSource(new Source(sourceId));
return profile;
}
use of org.orcid.jaxb.model.message.ContactDetails in project ORCID-Source by ORCID.
the class OrcidProfileManagerImpl method addSourceToEmails.
/**
* Preserves existing source for existing emails, and adds specified source
* for new emails
*
* @param orcidProfile
* The incoming profile
* @param existingProfileEntity
* The existing profile entity from the DB
* @param amenderOrcid
* The source of new emails (from the security context)
*/
private void addSourceToEmails(OrcidProfile orcidProfile, ProfileEntity existingProfileEntity, String amenderOrcid) {
Map<String, EmailEntity> existingMap = new HashMap<>();
Set<EmailEntity> existingEmails = existingProfileEntity.getEmails();
if (existingEmails != null) {
existingMap = EmailEntity.mapByLowerCaseEmail(existingEmails);
}
OrcidBio orcidBio = orcidProfile.getOrcidBio();
if (orcidBio != null) {
ContactDetails contactDetails = orcidBio.getContactDetails();
if (contactDetails != null) {
SourceEntity entity = sourceManager.retrieveSourceEntity();
for (Email email : contactDetails.getEmail()) {
EmailEntity existingEmail = existingMap.get(email.getValue().toLowerCase());
if (existingEmail == null) {
if (entity.getSourceClient() != null && !PojoUtil.isEmpty(entity.getSourceClient().getId())) {
email.setSourceClientId(entity.getSourceClient().getId());
} else if (entity.getSourceProfile() != null && !PojoUtil.isEmpty(entity.getSourceProfile().getId())) {
email.setSource(entity.getSourceProfile().getId());
}
} else {
email.setSource(existingEmail.getSourceId());
email.setSourceClientId(existingEmail.getClientSourceId());
}
}
}
}
}
use of org.orcid.jaxb.model.message.ContactDetails in project ORCID-Source by ORCID.
the class OrcidIndexManagerImplTest method getOrcidProfileMandatoryOnly.
/**
* According to the validation rules on the web front end, these fields are
* mandatory. Ultimately they may or may not make it into SOLR due to
* visibility restrictions
*
* @return OrcidProfile with only mandatory fields populated.
*/
private OrcidProfile getOrcidProfileMandatoryOnly() {
OrcidProfile orcidProfile = new OrcidProfile();
orcidProfile.setOrcidIdentifier("5678");
OrcidBio orcidBio = new OrcidBio();
orcidProfile.setOrcidBio(orcidBio);
ContactDetails contactDetails = new ContactDetails();
contactDetails.addOrReplacePrimaryEmail(new Email("stan@test.com"));
orcidBio.setContactDetails(contactDetails);
PersonalDetails personalDetails = new PersonalDetails();
FamilyName familyName = new FamilyName("Logan");
familyName.setVisibility(Visibility.PUBLIC);
personalDetails.setFamilyName(familyName);
GivenNames givenNames = new GivenNames("Donald Edward");
givenNames.setVisibility(Visibility.PUBLIC);
personalDetails.setGivenNames(givenNames);
orcidBio.setPersonalDetails(personalDetails);
OrcidActivities orcidActivities = new OrcidActivities();
orcidProfile.setOrcidActivities(orcidActivities);
Affiliations affiliations = new Affiliations();
orcidActivities.setAffiliations(affiliations);
return orcidProfile;
}
use of org.orcid.jaxb.model.message.ContactDetails in project ORCID-Source by ORCID.
the class OrcidJaxbCopyManagerTest method testUpdatedContactDetailsToExistingPreservingVisibility.
@Test
public void testUpdatedContactDetailsToExistingPreservingVisibility() throws Exception {
when(mockSourceManager.retrieveSourceOrcid()).thenReturn("APP-0000000000000000");
SourceEntity sourceEntity = new SourceEntity();
sourceEntity.setSourceClient(new ClientDetailsEntity("APP-0000000000000000"));
when(mockSourceManager.retrieveSourceEntity()).thenReturn(sourceEntity);
OrcidBio existingOrcidBioProtected = protectedOrcidMessage.getOrcidProfile().getOrcidBio();
OrcidBio updatedOrcidBioPublic = publicOrcidMessage.getOrcidProfile().getOrcidBio();
ContactDetails existingContactDetails = existingOrcidBioProtected.getContactDetails();
ContactDetails updatedContactDetails = updatedOrcidBioPublic.getContactDetails();
assertEquals("josiah_carberry@brown.edu", existingContactDetails.retrievePrimaryEmail().getValue());
assertEquals(Visibility.LIMITED, existingContactDetails.retrievePrimaryEmail().getVisibility());
String[] alternativeEmails = new String[] { "josiah_carberry_1@brown.edu" };
for (String alternativeEmail : alternativeEmails) {
Email email = existingContactDetails.getEmailByString(alternativeEmail);
assertNotNull(email);
assertEquals(Visibility.LIMITED, email.getVisibility());
}
assertEquals(2, existingContactDetails.getEmail().size());
Address existingAddress = existingContactDetails.getAddress();
assertTrue(Iso3166Country.US.equals(existingAddress.getCountry().getValue()) && existingAddress.getCountry().getVisibility() == null);
Address updatedAddress = new Address();
Country country = new Country(Iso3166Country.GB);
country.setVisibility(Visibility.LIMITED);
updatedAddress.setCountry(country);
updatedOrcidBioPublic.getContactDetails().setAddress(updatedAddress);
List<Email> updatedEmailList = new ArrayList<>();
Email updatedMainEmail = new Email("jimmyb@semantico.com");
updatedMainEmail.setSourceClientId("APP-0000000000000000");
updatedMainEmail.setVisibility(Visibility.PUBLIC);
updatedMainEmail.setPrimary(true);
updatedEmailList.add(updatedMainEmail);
String[] updatedAlternativeEmails = new String[] { "jimmyb1@semantico.com" };
for (String alternativeEmail : updatedAlternativeEmails) {
Email email = new Email(alternativeEmail);
email.setPrimary(false);
email.setVerified(false);
email.setVisibility(Visibility.PRIVATE);
email.setSourceClientId("APP-0000000000000000");
updatedEmailList.add(email);
}
updatedContactDetails.getEmail().clear();
updatedContactDetails.getEmail().addAll(updatedEmailList);
updatedContactDetails.setAddress(updatedAddress);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
existingContactDetails = existingOrcidBioProtected.getContactDetails();
assertEquals("josiah_carberry@brown.edu", existingContactDetails.retrievePrimaryEmail().getValue());
assertEquals(Visibility.LIMITED, existingContactDetails.retrievePrimaryEmail().getVisibility());
// Emails remain unchanged
assertEquals(2, existingContactDetails.getEmail().size());
assertEquals(Iso3166Country.GB, existingContactDetails.getAddress().getCountry().getValue());
assertEquals(OrcidVisibilityDefaults.COUNTRY_DEFAULT.getVisibility(), existingContactDetails.getAddress().getCountry().getVisibility());
updatedContactDetails = new ContactDetails();
updatedOrcidBioPublic.setContactDetails(updatedContactDetails);
updatedAddress = new Address();
country = new Country(Iso3166Country.AU);
country.setVisibility(null);
updatedAddress.setCountry(country);
updatedContactDetails.setAddress(updatedAddress);
updatedEmailList = new ArrayList<>();
updatedMainEmail = new Email("jimmyb1@semantico.com");
updatedMainEmail.setVisibility(Visibility.PUBLIC);
updatedEmailList.add(updatedMainEmail);
String[] moreAlternativeEmails = new String[] { "jimmyb3@semantico.com" };
for (String alternativeEmail : moreAlternativeEmails) {
Email email = new Email(alternativeEmail);
email.setPrimary(false);
email.setVisibility(Visibility.PRIVATE);
email.setSourceClientId("APP-0000000000000000");
updatedEmailList.add(email);
}
updatedContactDetails.getEmail().clear();
updatedContactDetails.getEmail().addAll(updatedEmailList);
orcidJaxbCopyManager.copyUpdatedBioToExistingWithVisibility(existingOrcidBioProtected, updatedOrcidBioPublic);
existingContactDetails = existingOrcidBioProtected.getContactDetails();
// Emails remain unchanged
assertEquals(2, existingContactDetails.getEmail().size());
assertEquals(Iso3166Country.AU, existingContactDetails.getAddress().getCountry().getValue());
}
use of org.orcid.jaxb.model.message.ContactDetails 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