| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 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 | |
} |