Coverage Report - org.kuali.mobility.xsl.dao.XslDaoImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
XslDaoImpl
0%
0/24
0%
0/6
1.571
 
 1  
 /**
 2  
  * Copyright 2011 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.mobility.xsl.dao;
 17  
 
 18  
 import java.util.List;
 19  
 
 20  
 import javax.persistence.EntityManager;
 21  
 import javax.persistence.PersistenceContext;
 22  
 import javax.persistence.Query;
 23  
 
 24  
 import org.kuali.mobility.xsl.entity.Xsl;
 25  
 import org.springframework.stereotype.Repository;
 26  
 
 27  
 @Repository
 28  0
 public class XslDaoImpl implements XslDao {
 29  
 
 30  
     @PersistenceContext
 31  
     private EntityManager entityManager;
 32  
     
 33  
     public void deleteXslById(Long id) {
 34  0
         Query query = entityManager.createQuery("delete from Xsl x where x.xslId = :id");
 35  0
         query.setParameter("id", id);
 36  0
         query.executeUpdate();
 37  0
     }
 38  
 
 39  
     @SuppressWarnings("unchecked")
 40  
     public List<Xsl> findAllXsl() {
 41  0
         Query query = entityManager.createQuery("select x from Xsl x order by x.id");
 42  0
         return query.getResultList();
 43  
     }
 44  
 
 45  
     public Xsl findXslById(Long id) {
 46  0
         Query query = entityManager.createQuery("select x from Xsl x where x.xslId = :id");
 47  0
         query.setParameter("id", id);
 48  0
         return (Xsl) query.getSingleResult();
 49  
     }
 50  
     
 51  
     public Xsl findXslByCode(String code) {
 52  0
         Query query = entityManager.createQuery("select x from Xsl x where x.code = :code");
 53  0
         query.setParameter("code", code);
 54  0
         return (Xsl) query.getSingleResult();
 55  
     }
 56  
 
 57  
     public void saveXsl(Xsl xsl) {
 58  0
         if (xsl == null) {
 59  0
             return;
 60  
         }
 61  0
         if (xsl.getValue() != null) {
 62  0
             xsl.setValue(xsl.getValue().trim());
 63  
         }
 64  0
         if (xsl.getXslId() == null) {
 65  0
             entityManager.persist(xsl);
 66  
         } else {
 67  0
             entityManager.merge(xsl);
 68  
         }
 69  0
     }
 70  
     
 71  
     public EntityManager getEntityManager() {
 72  0
         return entityManager;
 73  
     }
 74  
 
 75  
     public void setEntityManager(EntityManager entityManager) {
 76  0
         this.entityManager = entityManager;
 77  0
     }
 78  
     
 79  
 }