Mercurial > lada > lada-server
view src/main/java/de/intevation/lada/data/LStatusRepository.java @ 182:a2e04ab2cd44
Use the new filter and query builder and have authentication for LProbeInfo objects.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 27 Jun 2013 15:03:18 +0200 |
parents | 8bf3054109ba |
children | 5bd5057f58e2 |
line wrap: on
line source
package de.intevation.lada.data; import javax.ejb.EJBTransactionRolledbackException; import javax.inject.Inject; import javax.inject.Named; import javax.persistence.EntityExistsException; import javax.persistence.EntityManager; import javax.persistence.TransactionRequiredException; import de.intevation.lada.manage.Manager; import de.intevation.lada.model.LStatus; import de.intevation.lada.rest.Response; /** * This Container is an interface to request, filter and select LMesswert * obejcts from the connected database. * * @author <a href="mailto:rrenkert@intevation.de">Raimund Renkert</a> */ @Named("lstatusrepository") public class LStatusRepository extends Repository { /** * The entitymanager managing the data. */ @Inject private EntityManager em; /** * Manager class for LPRobe. Used to manipulate data objects. */ @Inject @Named("datamanager") private Manager manager; @Override public Response create(Object object) { if (!(object instanceof LStatus)) { return new Response(false, 602, object); } LStatus status = (LStatus)object; Response response = new Response(true, 200, status); // Try to save the new LProbe. try { manager.create(status); return response; } catch (EntityExistsException eee) { response.setSuccess(false); response.setMessage(601); } catch (IllegalArgumentException iae) { response.setSuccess(false); response.setMessage(602); } catch (TransactionRequiredException tre) { response.setSuccess(false); response.setMessage(603); } catch (EJBTransactionRolledbackException te) { response.setSuccess(false); response.setMessage(604); } return response; } @Override public Response update(Object object) { if (!(object instanceof LStatus)) { return new Response(false, 602, object); } LStatus status = (LStatus)object; Response response = new Response(true, 200, status); try { manager.update(status); return response; } catch (EntityExistsException eee) { response.setSuccess(false); response.setMessage(601); } catch (IllegalArgumentException iae) { response.setSuccess(false); response.setMessage(602); } catch (TransactionRequiredException tre) { response.setSuccess(false); response.setMessage(603); } catch (EJBTransactionRolledbackException te) { response.setSuccess(false); response.setMessage(604); } return response; } }