changeset 384:5c4010659967

Enable multiselect in queryfilter. (Used as example in final workshop)
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 09 Oct 2013 15:00:31 +0200
parents 701b52518dcd
children 77b4b85b0134 012f76de0687
files src/main/java/de/intevation/lada/data/LProbeRepository.java src/main/java/de/intevation/lada/model/query/QueryFilter.java src/main/java/de/intevation/lada/utils/QueryTools.java
diffstat 3 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/de/intevation/lada/data/LProbeRepository.java	Wed Oct 09 14:57:28 2013 +0200
+++ b/src/main/java/de/intevation/lada/data/LProbeRepository.java	Wed Oct 09 15:00:31 2013 +0200
@@ -78,7 +78,12 @@
         MultivaluedMap<String, String> params) {
         Query query = em.createNativeQuery(sql);
         for (String filter: filters) {
-            query.setParameter(filter, params.get(filter));
+            List<String> param = params.get(filter);
+            List<String> clean = new ArrayList<String>();
+            for(String p : param) {
+                clean.add(p.replace(",", "|"));
+            }
+            query.setParameter(filter, clean);
         }
         List<Object[]> result = query.getResultList();
         List<Map<String, Object>> res = new ArrayList<Map<String, Object>>();
--- a/src/main/java/de/intevation/lada/model/query/QueryFilter.java	Wed Oct 09 14:57:28 2013 +0200
+++ b/src/main/java/de/intevation/lada/model/query/QueryFilter.java	Wed Oct 09 15:00:31 2013 +0200
@@ -11,6 +11,7 @@
     private String dataIndex;
     private String type;
     private String label;
+    private boolean multiSelect;
 
     /**
      * Default constructor.
@@ -72,4 +73,18 @@
     public void setLabel(String label) {
         this.label = label;
     }
+
+    /**
+     * @return the multiSelect
+     */
+    public boolean isMultiSelect() {
+        return multiSelect;
+    }
+
+    /**
+     * @param multiSelect the multiSelect to set
+     */
+    public void setMultiSelect(boolean multiSelect) {
+        this.multiSelect = multiSelect;
+    }
 }
--- a/src/main/java/de/intevation/lada/utils/QueryTools.java	Wed Oct 09 14:57:28 2013 +0200
+++ b/src/main/java/de/intevation/lada/utils/QueryTools.java	Wed Oct 09 15:00:31 2013 +0200
@@ -72,6 +72,7 @@
                     qFilter.setDataIndex(filter.getString("dataIndex"));
                     qFilter.setType(filter.getString("type"));
                     qFilter.setLabel(filter.getString("label"));
+                    qFilter.setMultiSelect(filter.optBoolean("multiselect", false));
                     qFilters.add(qFilter);
                 }
                 qConf.setFilters(qFilters);
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)