Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/data/LProbeRepository.java @ 44:2d89a04d5ad9
LProbe repository now extends the generic repository.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 24 May 2013 11:51:51 +0200 |
parents | 0dd63fcc9581 |
children | 3a00c8fd5a8e |
comparison
equal
deleted
inserted
replaced
43:13178bbe77ff | 44:2d89a04d5ad9 |
---|---|
4 import java.util.List; | 4 import java.util.List; |
5 | 5 |
6 import javax.enterprise.context.ApplicationScoped; | 6 import javax.enterprise.context.ApplicationScoped; |
7 import javax.inject.Inject; | 7 import javax.inject.Inject; |
8 import javax.persistence.EntityManager; | 8 import javax.persistence.EntityManager; |
9 import javax.persistence.PersistenceContext; | |
10 import javax.persistence.PersistenceContextType; | |
11 import javax.persistence.criteria.CriteriaBuilder; | 9 import javax.persistence.criteria.CriteriaBuilder; |
12 import javax.persistence.criteria.CriteriaQuery; | 10 import javax.persistence.criteria.CriteriaQuery; |
13 import javax.persistence.criteria.Predicate; | 11 import javax.persistence.criteria.Predicate; |
14 import javax.persistence.criteria.Root; | 12 import javax.persistence.criteria.Root; |
15 | 13 |
14 import de.intevation.lada.manage.LProbeManager; | |
16 import de.intevation.lada.model.LProbe; | 15 import de.intevation.lada.model.LProbe; |
17 import de.intevation.lada.service.LProbeService; | |
18 | 16 |
19 /** | 17 /** |
20 * This Container is an interface to request, filter and select LProbe | 18 * This Container is an interface to request, filter and select LProbe |
21 * obejcts from the connected database. | 19 * obejcts from the connected database. |
22 * | 20 * |
23 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> | 21 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> |
24 */ | 22 */ |
25 @ApplicationScoped | 23 @ApplicationScoped |
26 public class LProbeRepository { | 24 public class LProbeRepository extends Repository{ |
27 | 25 |
28 /** | 26 /** |
29 * The entitymanager managing the data. | 27 * The entitymanager managing the data. |
30 */ | 28 */ |
31 @Inject | 29 @Inject |
32 private EntityManager em; | 30 private EntityManager em; |
33 | 31 |
34 /** | 32 /** |
35 * Service class for LPRobe. Used to manipulate data objects. | 33 * Manager class for LPRobe. Used to manipulate data objects. |
36 */ | 34 */ |
37 @Inject | 35 @Inject |
38 private LProbeService service; | 36 private LProbeManager manager; |
39 | |
40 /** | |
41 * Find a single LProbe object identified by its id. | |
42 * | |
43 * @param id The mst_id | |
44 * @return The SMessStelle object. | |
45 */ | |
46 public LProbe findById(String id) { | |
47 return em.find(LProbe.class, id); | |
48 } | |
49 | 37 |
50 /** | 38 /** |
51 * Filter for LProbe objects. | 39 * Filter for LProbe objects. |
52 * | 40 * |
53 * @param mstId mst_id | 41 * @param mstId mst_id |
87 Predicate beg = cb.equal(member.get("probeentnahmeBeginn"), new Date(begin)); | 75 Predicate beg = cb.equal(member.get("probeentnahmeBeginn"), new Date(begin)); |
88 criteria.where(beg); | 76 criteria.where(beg); |
89 } | 77 } |
90 return em.createQuery(criteria).getResultList(); | 78 return em.createQuery(criteria).getResultList(); |
91 } | 79 } |
92 | |
93 /** | |
94 * Get all LProbe objects from database. | |
95 * | |
96 * @return List of LProbe objects. | |
97 */ | |
98 public List<LProbe> findAll() { | |
99 CriteriaBuilder cb = em.getCriteriaBuilder(); | |
100 CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); | |
101 Root<LProbe> member = criteria.from(LProbe.class); | |
102 criteria.select(member); | |
103 return em.createQuery(criteria).getResultList(); | |
104 } | |
105 } | 80 } |