Mercurial > lada > lada-server
changeset 87:36b2191c3fcb
Added reset function to reinit the success boolean as same as errors and
warnings.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Fri, 07 Jun 2013 15:18:23 +0200 |
parents | d408eaa7c11b |
children | 750e284adc65 |
files | src/main/java/de/intevation/lada/data/Repository.java |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/Repository.java Fri Jun 07 15:17:18 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/Repository.java Fri Jun 07 15:18:23 2013 +0200 @@ -1,5 +1,6 @@ package de.intevation.lada.data; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,6 +43,7 @@ * @return List of objects. */ public <T> List<T> findAll(Class<T> clazz) { + this.reset(); CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<T> criteria = builder.createQuery(clazz); Root<T> member = criteria.from(clazz); @@ -49,6 +51,13 @@ return em.createQuery(criteria).getResultList(); } + public void reset() { + this.setSuccess(true); + this.setGeneralError(200); + this.setErrors(new HashMap<String, Integer>()); + this.setWarnings(new HashMap<String, Integer>()); + } + /** * Find a single object identified by its id. * @@ -57,6 +66,7 @@ * @return The requested object of type clazz */ public <T> T findById(Class<T> clazz, String id) { + this.reset(); T item = em.find(clazz, id); if (item == null) { this.setGeneralError(600);