Coverage Report - org.kuali.student.r2.core.class1.enumerationmanagement.dao.EnumeratedValueDao
 
Classes in this File Line Coverage Branch Coverage Complexity
EnumeratedValueDao
0%
0/6
N/A
1
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.r2.core.class1.enumerationmanagement.dao;
 17  
 
 18  
 import java.util.Date;
 19  
 import java.util.List;
 20  
 
 21  
 import org.kuali.student.enrollment.dao.GenericEntityDao;
 22  
 import org.kuali.student.r2.core.class1.enumerationmanagement.model.EnumeratedValueEntity;
 23  
 
 24  
 /**
 25  
  * Enumerated Value Dao class.
 26  
  *
 27  
  * @Version 2.0
 28  
  */
 29  0
 public class EnumeratedValueDao extends GenericEntityDao<EnumeratedValueEntity> {
 30  
 
 31  
     @SuppressWarnings("unchecked")
 32  
     public List<EnumeratedValueEntity> getByDate(String enumerationKey, Date contextDate) {
 33  0
         return em.createQuery("from EnumeratedValueEntity e where e.effectiveDate <= :contextDate and " + 
 34  
                 "(e.expirationDate is null or e.expirationDate >= :contextDate) and e.enumeration.id = :enumerationKey ")
 35  
                 .setParameter("enumerationKey", enumerationKey).setParameter("contextDate", contextDate).getResultList();
 36  
     }
 37  
 
 38  
     @SuppressWarnings("unchecked")
 39  
     public List<EnumeratedValueEntity> getByContextAndDate(String enumerationKey, String contextKey, String contextValue, Date contextDate) {
 40  0
         return em.createQuery("select e from EnumeratedValueEntity e , IN(e.contextValueEntities) c " +
 41  
                 "where e.effectiveDate <= :contextDate and (e.expirationDate is null or e.expirationDate >= :contextDate) and " + 
 42  
                 "c.contextValue = :contextValue and c.contextKey = :enumContextKey and e.enumeration.id = :enumKey ")
 43  
                 .setParameter("contextDate", contextDate).setParameter("contextValue", contextValue).setParameter("enumContextKey", contextKey)
 44  
                 .setParameter("enumKey", enumerationKey).getResultList();
 45  
     }
 46  
 
 47  
     @SuppressWarnings("unchecked")
 48  
     public List<EnumeratedValueEntity> getByContextTypeAndValue(String enumerationKey, String contextTypeKey, String contextValue) {
 49  0
         return em.createQuery("select e from EnumeratedValueEntity e JOIN e.contextValueEntities c " + 
 50  
                 "where c.contextValue = :contextValue and c.contextKey = :enumContextKey and " + 
 51  
                 "e.enumeration.id = :enumerationKey ").setParameter("enumerationKey", enumerationKey)
 52  
                 .setParameter("enumContextKey", contextTypeKey).setParameter("contextValue", contextValue).getResultList();
 53  
     }
 54  
     
 55  
     @SuppressWarnings("unchecked")
 56  
     public List<EnumeratedValueEntity> getByEnumerationKey(String enumerationKey) {
 57  0
         return em.createQuery("from EnumeratedValueEntity e where e.enumeration.id = :enumerationKey ")
 58  
                 .setParameter("enumerationKey", enumerationKey).getResultList();
 59  
     }
 60  
     
 61  
     public EnumeratedValueEntity getByEnumerationKeyAndCode(String enumerationKey, String code) {
 62  0
         return (EnumeratedValueEntity) (em.createQuery("select e from EnumeratedValueEntity e where e.enumeration.id = :enumerationKey and e.code = :code")
 63  
                 .setParameter("enumerationKey", enumerationKey).setParameter("code", code).getSingleResult());
 64  
         
 65  
     }
 66  
 }