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 java.util.ArrayList;
 20  
 import java.util.Collection;
 21  
 import java.util.List;
 22  
 
 23  
 import javax.persistence.EntityManager;
 24  
 import javax.persistence.PersistenceContext;
 25  
 
 26  
 import org.kuali.rice.core.framework.persistence.platform.DatabasePlatform;
 27  
 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
 28  
 import org.kuali.rice.core.util.RiceConstants;
 29  
 import org.kuali.rice.kew.useroptions.UserOptions;
 30  
 import org.kuali.rice.kew.useroptions.dao.UserOptionsDAO;
 31  
 
 32  
 
 33  0
 public class UserOptionsDaoJpaImpl implements UserOptionsDAO {
 34  
 
 35  
     @PersistenceContext
 36  
     private EntityManager entityManager;
 37  
 
 38  
         public Long getNewOptionIdForActionList() {
 39  0
         return getPlatform().getNextValSQL("KREW_ACTN_LIST_OPTN_S", entityManager);
 40  
     }
 41  
 
 42  
         protected DatabasePlatform getPlatform() {
 43  0
             return (DatabasePlatform) GlobalResourceLoader.getService(RiceConstants.DB_PLATFORM);
 44  
     }
 45  
 
 46  
     public List findByUserQualified(String principalId, String likeString) {
 47  0
         return new ArrayList(entityManager.createNamedQuery("UserOptions.FindByUserQualified").setParameter("workflowId", principalId).setParameter("optionId", likeString).getResultList());
 48  
     }
 49  
 
 50  
     public void deleteByUserQualified(String principalId, String likeString) {
 51  0
         List<UserOptions> userOptions = (List<UserOptions>) entityManager.createNamedQuery("UserOptions.FindByUserQualified").setParameter("workflowId", principalId).setParameter("optionId", likeString).getResultList();
 52  0
         for (UserOptions uo : userOptions) {
 53  0
             entityManager.remove(uo);
 54  
         }
 55  0
     }
 56  
 
 57  
     public Collection findByWorkflowUser(String principalId) {
 58  0
         return entityManager.createNamedQuery("UserOptions.FindByWorkflowId").setParameter("workflowId", principalId).getResultList();
 59  
     }
 60  
 
 61  
     public void save(UserOptions userOptions) {
 62  0
         if (userOptions.getOptionId() == null) {
 63  0
             entityManager.persist(userOptions);
 64  
         } else {
 65  0
             entityManager.merge(userOptions);
 66  
         }
 67  0
     }
 68  
     
 69  
     public void save(Collection<UserOptions> userOptions) {
 70  0
             if (userOptions != null) for (UserOptions option : userOptions) {
 71  0
                         save(option);
 72  
                 }
 73  0
     }
 74  
 
 75  
     public void deleteUserOptions(UserOptions userOptions) {
 76  0
         UserOptions reattatched = entityManager.merge(userOptions);
 77  0
         entityManager.remove(reattatched);
 78  0
     }
 79  
 
 80  
     public UserOptions findByOptionId(String optionId, String principalId) {
 81  0
         return (UserOptions) entityManager.createNamedQuery("UserOptions.FindByOptionId").setParameter("optionId", optionId).setParameter("workflowId", principalId).getSingleResult();
 82  
     }
 83  
 
 84  
     public Collection findByOptionValue(String optionId, String optionValue) {
 85  0
         return entityManager.createNamedQuery("UserOptions.FindByOptionValue").setParameter("optionId", optionId).setParameter("optionValue", optionValue).getResultList();
 86  
     }
 87  
 
 88  
     public EntityManager getEntityManager() {
 89  0
         return this.entityManager;
 90  
     }
 91  
 
 92  
     public void setEntityManager(EntityManager entityManager) {
 93  0
         this.entityManager = entityManager;
 94  0
     }
 95  
 }