Coverage Report - org.kuali.rice.kew.useroptions.dao.impl.UserOptionsDaoJpaImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
UserOptionsDaoJpaImpl
0%
0/24
0%
0/8
1.333
 
 1  
 /*
 2  
  * Copyright 2005-2008 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.kuali.rice.kew.useroptions.dao.impl;
 18  
 
 19  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 20  
 import org.kuali.rice.core.api.util.RiceConstants;
 21  
 import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;
 22  
 import org.kuali.rice.kew.useroptions.UserOptions;
 23  
 import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO;
 24  
 
 25  
 import javax.persistence.EntityManager;
 26  
 import javax.persistence.PersistenceContext;
 27  
 import java.util.ArrayList;
 28  
 import java.util.Collection;
 29  
 import java.util.List;
 30  
 
 31  
 
 32  0
 public class UserOptionsDaoJpaImpl implements UserOptionsDAO {
 33  
 
 34  
     @PersistenceContext
 35  
     private EntityManager entityManager;
 36  
 
 37  
         public Long getNewOptionIdForActionList() {
 38  0
         return getPlatform().getNextValSQL("KREW_ACTN_LIST_OPTN_S", entityManager);
 39  
     }
 40  
 
 41  
         protected DatabasePlatform getPlatform() {
 42  0
             return (DatabasePlatform) GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM);
 43  
     }
 44  
 
 45  
     public List findByUserQualified(String principalId, String likeString) {
 46  0
         return new ArrayList(entityManager.createNamedQuery("UserOptions.FindByUserQualified").setParameter("workflowId", principalId).setParameter("optionId", likeString).getResultList());
 47  
     }
 48  
 
 49  
     public void deleteByUserQualified(String principalId, String likeString) {
 50  0
         List<UserOptions> userOptions = (List<UserOptions>) entityManager.createNamedQuery("UserOptions.FindByUserQualified").setParameter("workflowId", principalId).setParameter("optionId", likeString).getResultList();
 51  0
         for (UserOptions uo : userOptions) {
 52  0
             entityManager.remove(uo);
 53  
         }
 54  0
     }
 55  
 
 56  
     public Collection findByWorkflowUser(String principalId) {
 57  0
         return entityManager.createNamedQuery("UserOptions.FindByWorkflowId").setParameter("workflowId", principalId).getResultList();
 58  
     }
 59  
 
 60  
     public void save(UserOptions userOptions) {
 61  0
         if (userOptions.getOptionId() == null) {
 62  0
             entityManager.persist(userOptions);
 63  
         } else {
 64  0
             entityManager.merge(userOptions);
 65  
         }
 66  0
     }
 67  
     
 68  
     public void save(Collection<UserOptions> userOptions) {
 69  0
             if (userOptions != null) for (UserOptions option : userOptions) {
 70  0
                         save(option);
 71  
                 }
 72  0
     }
 73  
 
 74  
     public void deleteUserOptions(UserOptions userOptions) {
 75  0
         UserOptions reattatched = entityManager.merge(userOptions);
 76  0
         entityManager.remove(reattatched);
 77  0
     }
 78  
 
 79  
     public UserOptions findByOptionId(String optionId, String principalId) {
 80  0
         return (UserOptions) entityManager.createNamedQuery("UserOptions.FindByOptionId").setParameter("optionId", optionId).setParameter("workflowId", principalId).getSingleResult();
 81  
     }
 82  
 
 83  
     public Collection findByOptionValue(String optionId, String optionValue) {
 84  0
         return entityManager.createNamedQuery("UserOptions.FindByOptionValue").setParameter("optionId", optionId).setParameter("optionValue", optionValue).getResultList();
 85  
     }
 86  
 
 87  
     public EntityManager getEntityManager() {
 88  0
         return this.entityManager;
 89  
     }
 90  
 
 91  
     public void setEntityManager(EntityManager entityManager) {
 92  0
         this.entityManager = entityManager;
 93  0
     }
 94  
 }