Mercurial > lada > lada-server
changeset 381:ea4d2d685f32
Added new method to filter data including limit and start for dataitems.
In most repositories only stubs returning 'null', implmented only in readonly repository.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 09 Oct 2013 14:54:34 +0200 |
parents | ced1b02b36f6 |
children | 816291da1dde |
files | src/main/java/de/intevation/lada/data/LKommentarMRepository.java src/main/java/de/intevation/lada/data/LKommentarPRepository.java src/main/java/de/intevation/lada/data/LMessungRepository.java src/main/java/de/intevation/lada/data/LMesswertRepository.java src/main/java/de/intevation/lada/data/LOrtRepository.java src/main/java/de/intevation/lada/data/LProbeRepository.java src/main/java/de/intevation/lada/data/LStatusRepository.java src/main/java/de/intevation/lada/data/LZusatzwertRepository.java src/main/java/de/intevation/lada/data/OrtRepository.java src/main/java/de/intevation/lada/data/ReadOnlyRepository.java src/main/java/de/intevation/lada/data/Repository.java |
diffstat | 11 files changed, 59 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/LKommentarMRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LKommentarMRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -179,4 +179,8 @@ } return response; } + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/LKommentarPRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LKommentarPRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -187,4 +187,9 @@ } return response; } + + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/LMessungRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LMessungRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -207,4 +207,8 @@ } return response; } + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/LMesswertRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LMesswertRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -195,4 +195,8 @@ } return response; } + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } } \ No newline at end of file
--- a/src/main/java/de/intevation/lada/data/LOrtRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LOrtRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -208,4 +208,9 @@ } return response; } + + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/LProbeRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LProbeRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -223,4 +223,9 @@ public Response delete(Object object) { return null; } + + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/LStatusRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LStatusRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -181,4 +181,9 @@ } return response; } + + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/LZusatzwertRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/LZusatzwertRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -192,4 +192,9 @@ } return response; } + + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } }
--- a/src/main/java/de/intevation/lada/data/OrtRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/OrtRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -171,4 +171,9 @@ } return response; } + + @Override + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + return null; + } } \ No newline at end of file
--- a/src/main/java/de/intevation/lada/data/ReadOnlyRepository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/ReadOnlyRepository.java Wed Oct 09 14:54:34 2013 +0200 @@ -43,6 +43,21 @@ } /** + * Filter object list by the given criteria. + * + * @param filter The filter query. + * @return Response object. + */ + public <T> Response filter(CriteriaQuery<T> filter, int size, int start) { + List<T> result = em.createQuery(filter).getResultList(); + if (size > 0 && start > -1) { + List<T> newList = result.subList(start, size + start); + return new Response(true, 200, newList, result.size()); + } + return new Response(true, 200, result); + } + + /** * Get all objects of type <link>clazz</link>from database. * * @param clazz The object type.
--- a/src/main/java/de/intevation/lada/data/Repository.java Wed Oct 09 14:51:15 2013 +0200 +++ b/src/main/java/de/intevation/lada/data/Repository.java Wed Oct 09 14:54:34 2013 +0200 @@ -21,6 +21,8 @@ public <T> Response filter(CriteriaQuery<T> filter); + public <T> Response filter(CriteriaQuery<T> filter, int size, int start); + public <T> Response findAll(Class<T> clazz); public <T> Response findById(Class<T> clazz, String id);