# HG changeset patch # User Raimund Renkert # Date 1371213770 -7200 # Node ID 490a4766290154ea5e4b50216c0fcb15e20fc342 # Parent 068b0bfb133ad832f34a43847af3754c4d1e113b New manager for LStatus objects. diff -r 068b0bfb133a -r 490a47662901 src/main/java/de/intevation/lada/manage/LStatusManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/de/intevation/lada/manage/LStatusManager.java Fri Jun 14 14:42:50 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.LStatus; + +/** + * This Manager provides databse operations for LStatus objects. + * + * @author Raimund Renkert + */ +@Stateless +public class LStatusManager +{ + @Inject + private EntityManager em; + + /** + * Delete a LProbe object by id. + * + * @param id + * @throws Exception + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void delete(String id) throws Exception { + LStatus messwert = em.find(LStatus.class, id); + em.remove(messwert); + } + + /** + * Persist a new LMesswert object in the database. + * + * @param messwert The new LMesswert object. + * + * @throws EntityExistsException + * @throws IllegalArgumentException + * @throws TransactionRequiredException + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void create(LStatus status) + throws EntityExistsException, + IllegalArgumentException, + EJBTransactionRolledbackException, + TransactionRequiredException { + em.persist(status); + } + + /** + * Updates a LMesswert object in the database. + * + * @param messwert The new LMesswert object. + * + * @throws EntityExistsException + * @throws IllegalArgumentException + * @throws TransactionRequiredException + */ + @TransactionAttribute(TransactionAttributeType.REQUIRED) + public void update(LStatus status) + throws EntityExistsException, + IllegalArgumentException, + EJBTransactionRolledbackException, + TransactionRequiredException { + em.merge(status); + } +}