[Dive4elements-commits] [PATCH 1 of 2] use pattern matching for grain fraction in SedimentYieldParser

Wald Commits scm-commit at wald.intevation.org
Thu Mar 7 11:25:40 CET 2013


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1362651652 -3600
# Node ID e8e092c00791efc6d3f1da39d8122d223769e80e
# Parent  8aac391871f9fb1175529ddb8812af0d9711fecd
use pattern matching for grain fraction in SedimentYieldParser

diff -r 8aac391871f9 -r e8e092c00791 flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java
--- 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 {


More information about the Dive4elements-commits mailing list