changeset 239:75da91eca29f

Added possibility to print column labels in the first line of an export. Added labels for odv export as well. gnv-artifacts/trunk@307 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 09 Nov 2009 14:11:09 +0000
parents a157c6042cb4
children 76897b73db4e
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultExport.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultProfile.java gnv-artifacts/src/main/java/de/intevation/gnv/exports/Export.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java
diffstat 6 files changed, 44 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Mon Nov 09 13:48:50 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Mon Nov 09 14:11:09 2009 +0000
@@ -1,3 +1,15 @@
+2009-11-09  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/exports/Export.java
+	  src/main/java/de/intevation/gnv/exports/DefaultProfile.java
+	  src/main/java/de/intevation/gnv/exports/DefaultExport.java: Added the
+	  possibility to print column labels in the first line of an export.
+
+	* src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java,
+	  src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java:
+	  Adjusted instantiation of the DefaultExport object and added column labels
+	  for odv export.
+
 2009-11-09  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/exports/SimpleOdvDataCollector.java:
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultExport.java	Mon Nov 09 13:48:50 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultExport.java	Mon Nov 09 14:11:09 2009 +0000
@@ -44,6 +44,10 @@
         log.debug("create content for export.");
         Iterator<Result> it = result.iterator();
 
+        String[] header = profile.getHeader();
+        if (header != null)
+            writer.writeNext(header);
+
         while (it.hasNext()) {
             Result res = it.next();
 
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultProfile.java	Mon Nov 09 13:48:50 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/DefaultProfile.java	Mon Nov 09 14:11:09 2009 +0000
@@ -11,6 +11,7 @@
 implements   Export.Profile
 {
     protected Export.DataCollector collector;
+    protected String []            header;
     protected String []            names;
     protected char                 separator;
     protected char                 escapeCharacter;
@@ -22,12 +23,14 @@
     }
 
     public DefaultProfile(
+        String []            header,
         char                 separator,
         char                 escapeCharacter,
         char                 quoteCharacter,
         String               type,
         String               encoding
     ) {
+        this.header          = header;
         this.separator       = separator;
         this.escapeCharacter = escapeCharacter;
         this.quoteCharacter  = quoteCharacter;
@@ -58,4 +61,8 @@
     public String getEncoding() {
         return encoding;
     }
+
+    public String[] getHeader() {
+        return header;
+    }
 }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/exports/Export.java	Mon Nov 09 13:48:50 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/exports/Export.java	Mon Nov 09 14:11:09 2009 +0000
@@ -18,11 +18,12 @@
 
     public interface Profile {
         String toString(int column, String value);
-        char   getSeparator();
-        char   getEscapeCharacter();
-        char   getQuoteCharacter();
-        String getType();
-        String getEncoding();
+        char      getSeparator();
+        char      getEscapeCharacter();
+        char      getQuoteCharacter();
+        String    getType();
+        String    getEncoding();
+        String [] getHeader();
     }
 
     public interface DataCollector {
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java	Mon Nov 09 13:48:50 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java	Mon Nov 09 14:11:09 2009 +0000
@@ -58,6 +58,7 @@
 
     public static final Profile TIMESERIES_CSV_PROFILE =
         new DefaultProfile(
+            null,
             ',',
             '"',
             '"',
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java	Mon Nov 09 13:48:50 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/timeseries/TimeSeriesOutputTransition.java	Mon Nov 09 14:11:09 2009 +0000
@@ -107,13 +107,25 @@
           //"PARAMETER",
           //"MEASUREMENTID",
           //"TIMESERIESID"
-      };
+    };
+
+
+    public static final String [] ODV_COLUMN_HEADER = {
+        "Cruise",
+        "Station",
+        "Type",
+        "Date/Time",
+        "Longitude [deegrees_east]",
+        "Latitude [deegrees_north]",
+        "Bot. Depth [m]"
+    };
 
     /**
      * Profile for exporting data to cvs
      */
     public static final Profile TIMESERIES_CSV_PROFILE =
         new DefaultProfile(
+            null,
             ',',
             '"',
             '"',
@@ -126,6 +138,7 @@
      */
     public static final Profile TIMESERIES_ODV_PROFILE =
         new DefaultProfile(
+            ODV_COLUMN_HEADER,
             '\t',
             CSVWriter.NO_QUOTE_CHARACTER,
             CSVWriter.NO_ESCAPE_CHARACTER,

http://dive4elements.wald.intevation.org