Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/data/LProbeRepository.java @ 39:e0a5477f657e
Documentation.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 23 May 2013 15:29:13 +0200 |
parents | 8155d2ed5cb8 |
children | 0dd63fcc9581 |
comparison
equal
deleted
inserted
replaced
38:c20674399ad7 | 39:e0a5477f657e |
---|---|
1 /* | |
2 * JBoss, Home of Professional Open Source | |
3 * Copyright 2012, Red Hat, Inc. and/or its affiliates, and individual | |
4 * contributors by the @authors tag. See the copyright.txt in the | |
5 * distribution for a full listing of individual contributors. | |
6 * | |
7 * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 * you may not use this file except in compliance with the License. | |
9 * You may obtain a copy of the License at | |
10 * http://www.apache.org/licenses/LICENSE-2.0 | |
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 de.intevation.lada.data; | 1 package de.intevation.lada.data; |
18 | 2 |
19 import java.util.Date; | 3 import java.util.Date; |
20 import java.util.List; | 4 import java.util.List; |
21 | 5 |
30 import javax.persistence.criteria.Root; | 14 import javax.persistence.criteria.Root; |
31 | 15 |
32 import de.intevation.lada.model.LProbe; | 16 import de.intevation.lada.model.LProbe; |
33 import de.intevation.lada.service.LProbeService; | 17 import de.intevation.lada.service.LProbeService; |
34 | 18 |
19 /** | |
20 * This Container is an interface to request, filter and select LProbe | |
21 * obejcts from the connected database. | |
22 * | |
23 * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> | |
24 */ | |
35 @ApplicationScoped | 25 @ApplicationScoped |
36 public class LProbeRepository { | 26 public class LProbeRepository { |
37 | 27 |
28 /** | |
29 * The entitymanager managing the data. | |
30 */ | |
38 @Inject | 31 @Inject |
39 @PersistenceContext(type=PersistenceContextType.EXTENDED) | 32 @PersistenceContext(type=PersistenceContextType.EXTENDED) |
40 private EntityManager em; | 33 private EntityManager em; |
41 | 34 |
35 /** | |
36 * Service class for LPRobe. Used to manipulate data objects. | |
37 */ | |
42 @Inject | 38 @Inject |
43 private LProbeService service; | 39 private LProbeService service; |
44 | 40 |
41 /** | |
42 * Find a single LProbe object identified by its id. | |
43 * | |
44 * @param id The mst_id | |
45 * @return The SMessStelle object. | |
46 */ | |
45 public LProbe findById(String id) { | 47 public LProbe findById(String id) { |
46 return em.find(LProbe.class, id); | 48 return em.find(LProbe.class, id); |
47 } | 49 } |
48 | 50 |
49 public void delete(LProbe item) { | 51 /** |
50 try { | 52 * Filter for LProbe objects. |
51 service.delete(item.getProbeId()); | 53 * |
52 } | 54 * @param mstId mst_id |
53 catch (Exception e) { | 55 * @param uwbId umw_id |
54 // TODO Auto-generated catch block | 56 * @param begin probeentnahmebegin |
55 e.printStackTrace(); | 57 * @return |
56 } | 58 */ |
57 } | |
58 | |
59 public List<LProbe> filter(String mstId, String uwbId, Long begin) { | 59 public List<LProbe> filter(String mstId, String uwbId, Long begin) { |
60 CriteriaBuilder cb = em.getCriteriaBuilder(); | 60 CriteriaBuilder cb = em.getCriteriaBuilder(); |
61 CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); | 61 CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); |
62 Root<LProbe> member = criteria.from(LProbe.class); | 62 Root<LProbe> member = criteria.from(LProbe.class); |
63 Predicate mst = cb.equal(member.get("mstId"), mstId); | 63 Predicate mst = cb.equal(member.get("mstId"), mstId); |
89 criteria.where(beg); | 89 criteria.where(beg); |
90 } | 90 } |
91 return em.createQuery(criteria).getResultList(); | 91 return em.createQuery(criteria).getResultList(); |
92 } | 92 } |
93 | 93 |
94 /** | |
95 * Get all LProbe objects from database. | |
96 * | |
97 * @return List of LProbe objects. | |
98 */ | |
94 public List<LProbe> findAll() { | 99 public List<LProbe> findAll() { |
95 CriteriaBuilder cb = em.getCriteriaBuilder(); | 100 CriteriaBuilder cb = em.getCriteriaBuilder(); |
96 CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); | 101 CriteriaQuery<LProbe> criteria = cb.createQuery(LProbe.class); |
97 Root<LProbe> member = criteria.from(LProbe.class); | 102 Root<LProbe> member = criteria.from(LProbe.class); |
98 criteria.select(member); | 103 criteria.select(member); |