Hi list,

I have done some fixes in the Oracle Datastore on the 2.4.x Branch.
There are again Date-Support Issues in Queryhandling.
I create a patch file.
Can anyone take a look at it?
May I check in these Changes?

Tim

 <<bugfix_oracle_datesupport.txt>> 
### Eclipse Workspace Patch 1.0
#P gt2-oracle-spatial
Index: src/main/java/org/geotools/filter/SQLEncoderOracle.java
===================================================================
--- src/main/java/org/geotools/filter/SQLEncoderOracle.java     (revision 31516)
+++ src/main/java/org/geotools/filter/SQLEncoderOracle.java     (working copy)
@@ -16,15 +16,19 @@
 package org.geotools.filter;
 
 import java.io.IOException;
+import java.text.Format;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
+import org.apache.commons.lang.time.DateUtils;
+import org.geotools.data.DataSourceException;
 import org.geotools.data.oracle.sdo.SDO;
-import org.geotools.data.DataSourceException;
-import org.opengis.feature.type.AttributeDescriptor;
 import org.opengis.filter.ExcludeFilter;
 import org.opengis.filter.Id;
 import org.opengis.filter.IncludeFilter;
@@ -128,6 +132,15 @@
     private String fidColumn;
     private String currentGeomColumnName = null;
     boolean inGeomFilter = false;
+    
+       /** Date Patterns **/
+    private static String[] patterns = new String[] {
+       "yyyy-MM-dd",
+       "dd-MM-yyyy",
+       "MM-dd-yyyy"
+    };
+    
+    protected Format formatter = new SimpleDateFormat("dd.MM.yyyy");
 
     public SQLEncoderOracle(String fidColumn, int defaultSRID) {
         this(new HashMap());
@@ -707,7 +720,25 @@
      * @see 
org.geotools.filter.FilterVisitor#visit(org.geotools.filter.LiteralExpression)
      */
     public void visit(LiteralExpression literal) {
-        if (literal.getType() == DefaultExpression.LITERAL_GEOMETRY) {
+        
+        if (literal.getType() == DefaultExpression.LITERAL_STRING) {
+                               String value = (String)literal.getLiteral();
+                       try {
+                                       try {
+                                               Date date = 
DateUtils.parseDate(value, patterns);
+                                               String dateValue = 
formatter.format(date);
+                                           
out.write("to_date('"+dateValue+"','dd.mm.yyyy')");
+                                           LOGGER.finest("Wert "+value+" wurde 
in ein Datum umgewandelt");
+                                       } catch (ParseException e) {
+                                               // TODO: Fehler in GT Zahlen 
die numerisch sind werden in Exponetialschreibweise ausgegeben
+                                               String escaped = 
value.replaceAll("'", "''");
+                                               out.write("'"+escaped+"'");
+                                       }
+                               } catch (IOException e) {
+                                       LOGGER.warning("IO Error exporting 
Literal String");
+                               }
+                        
+                }else if (literal.getType() == 
DefaultExpression.LITERAL_GEOMETRY) {
             Geometry geometry = (Geometry) literal.getLiteral();
 
             try {
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to