diff gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java @ 83:5c8e54726a58

Added Support for Vertical Profiles Mesh gnv-artifacts/trunk@113 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 23 Sep 2009 11:57:08 +0000
parents 5eb62df21f9a
children c8d1f7b9e5a8
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java	Tue Sep 22 13:20:30 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/TransitionBase.java	Wed Sep 23 11:57:08 2009 +0000
@@ -295,9 +295,18 @@
             while (it.hasNext()){
                 String value = it.next();
                 InputData data = this.inputData.get(value);
-                int size = this.inputValues.get(data.getName()).usedInQueries();
-                for (int j = 0; j < size; j++){
-                    list.add(data.getValue());
+                if (data != null && this.inputValues.containsKey(data.getName())){
+                    int size = this.inputValues.get(data.getName()).usedInQueries();
+                    String type = this.inputValues.get(data.getName()).getType();
+                    String requestValue = data.getValue();
+                    if (type.equalsIgnoreCase("string")){
+                        requestValue = this.prepareInputData4DBQuery(requestValue);
+                    }else if (type.equalsIgnoreCase("date")){
+                        requestValue = this.prepareInputData4DateDBQuery(requestValue);
+                    }
+                    for (int j = 0; j < size; j++){
+                        list.add(requestValue);
+                    }
                 }
             }
             String[] filterValues = list.toArray(new String[0]);
@@ -316,6 +325,38 @@
             throw new TransitionException(e);
         }
     }
+    
+    private String prepareInputData4DateDBQuery(String value){
+        if (value != null){
+            String[] values = value.split(",");
+            String newValue = "";
+            for (int i = 0; i < values.length; i++){
+                if (newValue.length() > 0){
+                    newValue= newValue + " , ";
+                }
+                newValue = "to_date('"+values[0].trim()+"', 'YYYY.MM.DD HH24:MI:SS')"; // TODO JUST HACK FIND A BETTER RESOLUTION
+            }
+            return newValue;
+        }
+        
+        return value; 
+    }
+    private String prepareInputData4DBQuery(String value){
+        if (value != null){
+            String[] values = value.split(",");
+            String newValue = "";
+            for (int i = 0; i < values.length; i++){
+                if (newValue.length() > 0){
+                    newValue= newValue + " , ";
+                }
+                newValue = "'"+values[0].trim()+"'";
+            }
+            return newValue;
+        }
+        
+        return value; 
+        
+    }
 
     /**
      * @param result

http://dive4elements.wald.intevation.org