Search in sources :

Example 11 with ContactDetails

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;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) FamilyName(org.orcid.jaxb.model.message.FamilyName) GivenNames(org.orcid.jaxb.model.message.GivenNames) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) Source(org.orcid.jaxb.model.message.Source)

Example 12 with ContactDetails

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());
                }
            }
        }
    }
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) EmailEntity(org.orcid.persistence.jpa.entities.EmailEntity)

Example 13 with ContactDetails

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;
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) FamilyName(org.orcid.jaxb.model.message.FamilyName) Affiliations(org.orcid.jaxb.model.message.Affiliations) GivenNames(org.orcid.jaxb.model.message.GivenNames) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) OrcidActivities(org.orcid.jaxb.model.message.OrcidActivities)

Example 14 with ContactDetails

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());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) Address(org.orcid.jaxb.model.message.Address) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) ArrayList(java.util.ArrayList) Country(org.orcid.jaxb.model.message.Country) Iso3166Country(org.orcid.jaxb.model.message.Iso3166Country) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 15 with ContactDetails

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;
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) FamilyName(org.orcid.jaxb.model.message.FamilyName) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) CreditName(org.orcid.jaxb.model.message.CreditName) OtherName(org.orcid.jaxb.model.message.OtherName) PersonalDetails(org.orcid.jaxb.model.message.PersonalDetails) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) GivenNames(org.orcid.jaxb.model.message.GivenNames) Biography(org.orcid.jaxb.model.message.Biography) ExternalIdentifiers(org.orcid.jaxb.model.message.ExternalIdentifiers) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ContactDetails (org.orcid.jaxb.model.message.ContactDetails)26 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)23 Email (org.orcid.jaxb.model.message.Email)22 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)18 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)17 GivenNames (org.orcid.jaxb.model.message.GivenNames)13 FamilyName (org.orcid.jaxb.model.message.FamilyName)12 CreditName (org.orcid.jaxb.model.message.CreditName)8 OrcidMessage (org.orcid.jaxb.model.message.OrcidMessage)8 ArrayList (java.util.ArrayList)7 Biography (org.orcid.jaxb.model.message.Biography)7 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)7 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)7 ExternalIdentifier (org.orcid.jaxb.model.message.ExternalIdentifier)6 OrcidActivities (org.orcid.jaxb.model.message.OrcidActivities)6 SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)6 Date (java.util.Date)5 Keyword (org.orcid.jaxb.model.message.Keyword)5 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)5 OtherName (org.orcid.jaxb.model.message.OtherName)5