# HG changeset patch # User Raimund Renkert # Date 1371108471 -7200 # Node ID 410a3a25b3e9f3f38dbcff151cae41da1b321f7a # Parent af62a2309106ccb35e02fb7754c8041058ce89fc New manager for LMessung. diff -r af62a2309106 -r 410a3a25b3e9 src/main/java/de/intevation/lada/manage/LMessungManager.java --- /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 Raimund Renkert + */ +@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); + } +}