[Lada-commits] [PATCH] Enable multiselect in queryfilter. (Used as example in final workshop)

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


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1381323631 -7200
# Node ID 5c401065996794687fb5e15f508b9706a75cd79f
# Parent  701b52518dcd85a0d1b6267272deab4c75f85a8d
Enable multiselect in queryfilter. (Used as example in final workshop)

diff -r 701b52518dcd -r 5c4010659967 src/main/java/de/intevation/lada/data/LProbeRepository.java
--- 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>>();
diff -r 701b52518dcd -r 5c4010659967 src/main/java/de/intevation/lada/model/query/QueryFilter.java
--- 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;
+    }
 }
diff -r 701b52518dcd -r 5c4010659967 src/main/java/de/intevation/lada/utils/QueryTools.java
--- 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);


More information about the Lada-commits mailing list