changeset 5184:e8e092c00791

use pattern matching for grain fraction in SedimentYieldParser
author Tom Gottfried <tom@intevation.de>
date Thu, 07 Mar 2013 11:20:52 +0100
parents 8aac391871f9
children 25cafe0a974d
files flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java
diffstat 1 files changed, 22 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java	Thu Mar 07 10:53:44 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java	Thu Mar 07 11:20:52 2013 +0100
@@ -33,28 +33,28 @@
     public static final String FRAKTION_START = "Fraktion:";
 
     public static final String FRACTION_COARSE_STR =
-        "_Grobkorn.csv";
+        ".*Grobkorn.*";
 
     public static final String FRACTION_FINE_MIDDLE_STR =
-        "_Fein-Mittel-Kies.csv";
+        ".*Fein-Mittel-Kies.*";
 
     public static final String FRACTION_SAND =
-        "_Sand.csv";
+        ".*Sand.*";
 
     public static final String FRACTION_SUSP_SAND =
-        "_susp_Sand.csv";
+        ".*susp_Sand.*";
 
     public static final String FRACTION_SUSP_SAND_BED =
-        "_bettbild_Anteil_susp_Sand.csv";
+        ".*bettbild_Anteil_susp_Sand.*";
 
     public static final String FRACTION_SUSP_SAND_BED_EPOCH =
-        "_susp_Sand_bettbildAnteil.csv";
+        ".*susp_Sand_bettbildAnteil.*";
 
     public static final String FRACTION_SUSPENDED_SEDIMENT =
-        "_Schwebstoff.csv";
+        ".*Schwebstoff.*";
 
     public static final String FRACTION_TOTAL =
-        "_gesamt.csv";
+        ".*gesamt.*";
 
 
     public static final Pattern TIMEINTERVAL_SINGLE =
@@ -357,35 +357,33 @@
             }
         }
 
-        log.warn("SYP: Unknow grain fraction: '" + gfStr + "'");
+        log.warn("SYP: Unknown grain fraction: '" + gfStr + "'");
 
         return null;
     }
 
 
     public static String getGrainFractionTypeName(String filename) {
-        if (filename.endsWith(FRACTION_COARSE_STR)) {
-            return GrainFraction.COARSE;
+        if (Pattern.matches(FRACTION_COARSE_STR, filename)) {
+	    return GrainFraction.COARSE;
         }
-        else if (filename.endsWith(FRACTION_FINE_MIDDLE_STR)) {
+        else if (Pattern.matches(FRACTION_FINE_MIDDLE_STR, filename)) {
             return GrainFraction.FINE_MIDDLE;
         }
-        else if (filename.endsWith(FRACTION_SAND) &&
-            !filename.endsWith(FRACTION_SUSP_SAND)) {
+        else if (Pattern.matches(FRACTION_SUSP_SAND_BED, filename) ||
+            Pattern.matches(FRACTION_SUSP_SAND_BED_EPOCH, filename)) {
+            return GrainFraction.SUSP_SAND_BED;
+        }
+        else if (Pattern.matches(FRACTION_SUSP_SAND, filename)) {
+            return GrainFraction.SUSP_SAND;
+        }
+	else if (Pattern.matches(FRACTION_SAND, filename)) {
             return GrainFraction.SAND;
         }
-        else if (filename.endsWith(FRACTION_SUSP_SAND) &&
-            !filename.endsWith(FRACTION_SUSP_SAND_BED)) {
-            return GrainFraction.SUSP_SAND;
-        }
-        else if (filename.endsWith(FRACTION_SUSP_SAND_BED) ||
-            filename.endsWith(FRACTION_SUSP_SAND_BED_EPOCH)) {
-            return GrainFraction.SUSP_SAND_BED;
-        }
-        else if (filename.endsWith(FRACTION_SUSPENDED_SEDIMENT)) {
+        else if (Pattern.matches(FRACTION_SUSPENDED_SEDIMENT, filename)) {
             return GrainFraction.SUSPENDED_SEDIMENT;
         }
-        else if (filename.endsWith(FRACTION_TOTAL)) {
+        else if (Pattern.matches(FRACTION_TOTAL, filename)) {
             return GrainFraction.TOTAL;
         }
         else {

http://dive4elements.wald.intevation.org