@@ -0,0 +1,3330 @@
+/**%0A * Licensed to Jasig under one or more contributor license%0A * agreements. See the NOTICE file distributed with this work%0A * for additional information regarding copyright ownership.%0A * Jasig licenses this file to you under the Apache License,%0A * Version 2.0 (the %22License%22); you may not use this file%0A * except in compliance with the License. You may obtain a%0A * copy of the License at:%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on%0A * an %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0Apackage org.jasig.portal.layout.profile.dao.jpa;%0A%0Aimport org.apache.commons.lang3.Validate;%0Aimport org.jasig.portal.jpa.BasePortalJpaDao;%0Aimport org.jasig.portal.jpa.OpenEntityManager;%0Aimport org.jasig.portal.layout.profile.IProfileSelection;%0Aimport org.jasig.portal.layout.profile.dao.IProfileSelectionDao;%0Aimport org.springframework.stereotype.Repository;%0A%0A/**%0A * JPA implementation of IProfilePreferenceDao.%0A *%0A * @since uPortal 4.2%0A */%0A// deliberately not annotated as Repository to avoid annotation-driven instantiation,%0A// instead adopters wishing to store profile selections via JPA can explicitly configure.%0Apublic class ProfileSelectionDaoImpl%0A    extends BasePortalJpaDao%0A    implements IProfileSelectionDao %7B%0A%0A%0A    @Override%0A    @PortalTransactional%0A    public IProfileSelection createProfileSelection(final String userName, final String profileFName) %7B%0A%0A        Validate.notEmpty(userName, %22Cannot create a profile selection for an empty userName%22);%0A        Validate.notEmpty(profileFName,%0A                %22Cannot create profile selection with empty profile fname %22 +%0A                        %22(instead delete any selection for this user.)%22);%0A%0A        final ProfileSelection jpaProfileSelection = new ProfileSelection(userName, profileFName);%0A%0A        getEntityManager().persist(jpaProfileSelection);%0A%0A        return jpaProfileSelection;%0A    %7D%0A%0A    @Override%0A    @PortalTransactional%0A    public IProfileSelection updateProfileSelection(final IProfileSelection profileSelection) %7B%0A%0A        Validate.notNull(profileSelection);%0A%0A        getEntityManager().persist(profileSelection);%0A%0A        return profileSelection;%0A    %7D%0A%0A    @Override%0A    @PortalTransactional%0A    public void deleteProfileSelection(final IProfileSelection profileSelection) %7B%0A%0A        Validate.notNull(profileSelection, %22Cannot delete a null profileSelection.%22);%0A%0A        final IProfileSelection persistentProfileSelection;%0A%0A        if (getEntityManager().contains(profileSelection)) %7B%0A            persistentProfileSelection = profileSelection;%0A        %7D else %7B%0A            persistentProfileSelection = getEntityManager().merge(profileSelection);%0A        %7D%0A%0A        getEntityManager().remove(persistentProfileSelection);%0A%0A    %7D%0A%0A    @Override%0A    @OpenEntityManager(unitName = PERSISTENCE_UNIT_NAME)%0A    public IProfileSelection readProfileSelectionForUser(final String userName) %7B%0A%0A        final NaturalIdQuery%3CProfileSelection%3E query = createNaturalIdQuery(ProfileSelection.class);%0A        query.using(ProfileSelection_.userName, userName);%0A%0A        return query.load();%0A    %7D%0A%7D%0A

Add ProfileSelectionDaoImpl (JPA).