[Lada-commits] [PATCH 3 of 5] Added new method to filter data including limit and start for dataitems

Wald Commits scm-commit at wald.intevation.org
Wed Oct 9 14:54:08 CEST 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1381323274 -7200
# Node ID ea4d2d685f3263131d32a455b0855be205427db3
# Parent  ced1b02b36f6b6f09d4ca0aa0f3e184cfccbe435
Added new method to filter data including limit and start for dataitems.

In most repositories only stubs returning 'null', implmented only in readonly repository.

diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LKommentarMRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LKommentarPRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LMessungRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LMesswertRepository.java
--- 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
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LOrtRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LProbeRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LStatusRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/LZusatzwertRepository.java
--- 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;
+    }
 }
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/OrtRepository.java
--- 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
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/ReadOnlyRepository.java
--- 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.
diff -r ced1b02b36f6 -r ea4d2d685f32 src/main/java/de/intevation/lada/data/Repository.java
--- 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);


More information about the Lada-commits mailing list