Mercurial > lada > lada-server
changeset 126:410a3a25b3e9
New manager for LMessung.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 13 Jun 2013 09:27:51 +0200 |
parents | af62a2309106 |
children | ab094cd8d78b |
files | src/main/java/de/intevation/lada/manage/LMessungManager.java |
diffstat | 1 files changed, 72 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/manage/LMessungManager.java Thu Jun 13 09:27:51 2013 +0200 @@ -0,0 +1,72 @@ +package de.intevation.lada.manage; + +import javax.ejb.EJBTransactionRolledbackException; +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import javax.ejb.TransactionAttributeType; +import javax.inject.Inject; +import javax.persistence.EntityExistsException; +import javax.persistence.EntityManager; +import javax.persistence.TransactionRequiredException; + +import de.intevation.lada.model.LMessung; + +/** + * This Manager provides database operations for LMessung objects. + * + * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> + */ +@Stateless +public class LMessungManager +{ + @Inject + private EntityManager em; + + /** + * Delete a LProbe object by id. + * + * @param id + * @throws Exception + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void delete(String id) throws Exception { + LMessung probe = em.find(LMessung.class, id); + em.remove(probe); + } + + /** + * Persist a new LProbe object in the database using the LProbeValidator. + * + * @param probe The new LProbe object. + * + * @throws EntityExistsException + * @throws IllegalArgumentException + * @throws TransactionRequiredException + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void create(LMessung probe) + throws EntityExistsException, + IllegalArgumentException, + EJBTransactionRolledbackException, + TransactionRequiredException { + em.persist(probe); + } + + /** + * Updates a LProbe object in the database. + * + * @param probe The new LProbe object. + * + * @throws EntityExistsException + * @throws IllegalArgumentException + * @throws TransactionRequiredException + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void update(LMessung probe) + throws EntityExistsException, + IllegalArgumentException, + EJBTransactionRolledbackException, + TransactionRequiredException { + em.merge(probe); + } +}