Search in sources :

Example 16 with Visibility

use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.

the class OrcidJaxbCopyManagerImpl method copyOtherNamesPreservingVisibility.

private void copyOtherNamesPreservingVisibility(PersonalDetails existingPersonalDetails, PersonalDetails updatedPersonalDetails) {
    OtherNames existingOtherNames = existingPersonalDetails.getOtherNames();
    OtherNames updatedOtherNames = updatedPersonalDetails.getOtherNames();
    // if no update, nothing to do
    if (updatedOtherNames == null) {
        return;
    }
    // otherwise take into account the visibility of updated and existing
    Visibility existingVisibility = existingOtherNames.getVisibility() != null ? existingOtherNames.getVisibility() : OrcidVisibilityDefaults.OTHER_NAMES_DEFAULT.getVisibility();
    updatedOtherNames.setVisibility(updatedOtherNames.getVisibility() != null ? updatedOtherNames.getVisibility() : existingVisibility);
    // now visibility has been preserved, overwrite the content
    existingPersonalDetails.setOtherNames(updatedOtherNames);
}
Also used : OtherNames(org.orcid.jaxb.model.message.OtherNames) Visibility(org.orcid.jaxb.model.message.Visibility)

Example 17 with Visibility

use of org.orcid.jaxb.model.message.Visibility in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method setBiographyDetails.

private void setBiographyDetails(ProfileEntity profileEntity, Biography biography) {
    if (biography != null) {
        Visibility defaultVisibility = profileEntity.getActivitiesVisibilityDefault() == null ? OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility() : Visibility.fromValue(profileEntity.getActivitiesVisibilityDefault().value());
        if (profileEntity.getBiographyEntity() == null) {
            profileEntity.setBiographyEntity(new BiographyEntity());
            profileEntity.getBiographyEntity().setProfile(profileEntity);
        }
        profileEntity.getBiographyEntity().setBiography(biography.getContent());
        if (profileEntity.getClaimed() == null || !profileEntity.getClaimed()) {
            if (biography.getVisibility() != null) {
                profileEntity.getBiographyEntity().setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(biography.getVisibility().value()));
            } else {
                profileEntity.getBiographyEntity().setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(defaultVisibility.value()));
            }
        }
        //Fill the visibility in case it is still null
        if (profileEntity.getBiographyEntity().getVisibility() == null) {
            profileEntity.getBiographyEntity().setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(defaultVisibility.value()));
        }
    }
}
Also used : Visibility(org.orcid.jaxb.model.message.Visibility) BiographyEntity(org.orcid.persistence.jpa.entities.BiographyEntity)

Aggregations

Visibility (org.orcid.jaxb.model.message.Visibility)17 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)6 Transactional (org.springframework.transaction.annotation.Transactional)6 HashSet (java.util.HashSet)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4 AccessControlException (java.security.AccessControlException)2 Date (java.util.Date)2 OrcidOAuth2Authentication (org.orcid.core.oauth.OrcidOAuth2Authentication)2 Affiliation (org.orcid.jaxb.model.message.Affiliation)2 Country (org.orcid.jaxb.model.message.Country)2 ExternalIdentifiers (org.orcid.jaxb.model.message.ExternalIdentifiers)2 Funding (org.orcid.jaxb.model.message.Funding)2 Keywords (org.orcid.jaxb.model.message.Keywords)2 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)2 OtherNames (org.orcid.jaxb.model.message.OtherNames)2 ResearcherUrls (org.orcid.jaxb.model.message.ResearcherUrls)2 ScopePathType (org.orcid.jaxb.model.message.ScopePathType)2 ArrayList (java.util.ArrayList)1 AfterReturning (org.aspectj.lang.annotation.AfterReturning)1 Test (org.junit.Test)1