Mercurial > lada > lada-server
comparison src/main/java/de/intevation/lada/manage/LProbeManager.java @ 65:8078fde8b02b
Persist a new LProbe using the LProbeValidator.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 31 May 2013 14:02:45 +0200 |
parents | 28b9167e5a5b |
children | 9e34b7e872f9 |
comparison
equal
deleted
inserted
replaced
64:132eca870434 | 65:8078fde8b02b |
---|---|
1 package de.intevation.lada.manage; | 1 package de.intevation.lada.manage; |
2 | 2 |
3 import java.util.Map; | |
3 import java.util.logging.Logger; | 4 import java.util.logging.Logger; |
4 | 5 |
5 import javax.ejb.Stateless; | 6 import javax.ejb.Stateless; |
6 import javax.ejb.TransactionAttribute; | 7 import javax.ejb.TransactionAttribute; |
7 import javax.ejb.TransactionAttributeType; | 8 import javax.ejb.TransactionAttributeType; |
8 import javax.inject.Inject; | 9 import javax.inject.Inject; |
10 import javax.inject.Named; | |
11 import javax.persistence.EntityExistsException; | |
9 import javax.persistence.EntityManager; | 12 import javax.persistence.EntityManager; |
13 import javax.persistence.TransactionRequiredException; | |
10 | 14 |
11 import de.intevation.lada.model.LProbe; | 15 import de.intevation.lada.model.LProbe; |
16 import de.intevation.lada.validation.ValidationException; | |
17 import de.intevation.lada.validation.Validator; | |
12 | 18 |
13 @Stateless | 19 @Stateless |
14 public class LProbeManager { | 20 public class LProbeManager { |
15 | 21 |
16 @Inject | 22 @Inject |
17 private Logger log; | 23 private Logger log; |
18 | 24 |
19 @Inject | 25 @Inject |
20 private EntityManager em; | 26 private EntityManager em; |
21 | 27 |
28 @Inject | |
29 @Named("lprobevalidator") | |
30 private Validator validator; | |
31 | |
32 /** | |
33 * Delete a LProbe object by id. | |
34 * | |
35 * @param id | |
36 * @throws Exception | |
37 */ | |
22 @TransactionAttribute(TransactionAttributeType.REQUIRED) | 38 @TransactionAttribute(TransactionAttributeType.REQUIRED) |
23 public void delete(String id) throws Exception { | 39 public void delete(String id) throws Exception { |
24 LProbe probe = em.find(LProbe.class, id); | 40 LProbe probe = em.find(LProbe.class, id); |
25 log.info("Deleting " + probe.getProbeId()); | 41 log.info("Deleting " + probe.getProbeId()); |
26 em.remove(probe); | 42 em.remove(probe); |
27 } | 43 } |
44 | |
45 @TransactionAttribute(TransactionAttributeType.REQUIRED) | |
46 public void create(LProbe probe) | |
47 throws EntityExistsException, | |
48 IllegalArgumentException, | |
49 TransactionRequiredException, | |
50 ValidationException { | |
51 validator.validate(probe); | |
52 em.persist(probe); | |
53 } | |
54 | |
55 public Map<String, Integer> getWarnings() { | |
56 return validator.getWarnings(); | |
57 } | |
28 } | 58 } |