[PATCH] Distinguish between types of measurement stations and filter appropriately (plus minor cleanup in related classes)

Wald Commits scm-commit at wald.intevation.org
Tue Oct 14 12:41:40 CEST 2014


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1413283297 -7200
# Node ID 6ae0c5116d5859028fdd396b87f75d99d315c195
# Parent  a779ee47aa79cb456e00d6163c0395d5c6aea105
Distinguish between types of measurement stations and filter appropriately (plus minor cleanup in related classes).

diff -r a779ee47aa79 -r 6ae0c5116d58 artifacts/src/main/java/org/dive4elements/river/artifacts/model/AnnotationFacet.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/AnnotationFacet.java	Mon Oct 13 17:22:52 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/AnnotationFacet.java	Tue Oct 14 12:41:37 2014 +0200
@@ -12,8 +12,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.log4j.Logger;
-
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallContext;
 
@@ -39,10 +37,6 @@
 public class AnnotationFacet
 extends      DefaultFacet
 {
-    /** Logger for this class. */
-    private static final Logger log = Logger.getLogger(AnnotationFacet.class);
-
-
     /**
      * Trivial Constructor.
      */
diff -r a779ee47aa79 -r 6ae0c5116d58 artifacts/src/main/java/org/dive4elements/river/artifacts/services/DistanceInfoService.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DistanceInfoService.java	Mon Oct 13 17:22:52 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/services/DistanceInfoService.java	Tue Oct 14 12:41:37 2014 +0200
@@ -98,7 +98,7 @@
             if ("locations".equals(name)) return FastAnnotations.IS_POINT;
             if ("distances".equals(name)) return FastAnnotations.IS_RANGE;
             if ("measuringpoint".equals(name))
-                return new FastAnnotations.NameFilter("Messstelle");
+                return new FastAnnotations.NameFilter(".*[Mm]essstelle");
         }
 
         return FastAnnotations.ALL;
diff -r a779ee47aa79 -r 6ae0c5116d58 artifacts/src/main/java/org/dive4elements/river/artifacts/states/AnnotationRiverState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/AnnotationRiverState.java	Mon Oct 13 17:22:52 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/AnnotationRiverState.java	Tue Oct 14 12:41:37 2014 +0200
@@ -64,7 +64,7 @@
 
         String facetName = annotationArtifact.getFilterName();
         if (facetName == null) {
-            facetName = Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION);
+            facetName = Resources.getMsg(meta, I18N_DESCRIPTION);
         }
 
         AnnotationFacet facet = new AnnotationFacet(
diff -r a779ee47aa79 -r 6ae0c5116d58 artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeState.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeState.java	Mon Oct 13 17:22:52 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/GaugeDischargeState.java	Tue Oct 14 12:41:37 2014 +0200
@@ -99,7 +99,7 @@
      * @param hash Ignored.
      * @param context Ignored.
      * @param meta CallMeta to be used for internationalization.
-     * @param facets List to add AnnotationFacet to.
+     * @param facets List to add Facet to.
      *
      * @return null.
      */
diff -r a779ee47aa79 -r 6ae0c5116d58 backend/doc/annotation-types.xml
--- a/backend/doc/annotation-types.xml	Mon Oct 13 17:22:52 2014 +0200
+++ b/backend/doc/annotation-types.xml	Tue Oct 14 12:41:37 2014 +0200
@@ -15,6 +15,8 @@
         <type name="Landkreis"/>
         <type name="Meldestelle"/>
         <type name="Messstelle"/>
+        <type name="Geschiebemessstelle"/>
+        <type name="Schwebstoffmessstelle"/>
         <type name="Pegel"/>
         <type name="Stauwehr"/>
         <type name="Staatsgrenze"/>
@@ -54,8 +56,10 @@
         <line pattern="^Landkreis[:\s].*$" type="Landkreis"/>
         <line pattern="^Meldestelle[:\s].*$" type="Meldestelle"/>
         <line pattern="^Messstelle[:\s].*$" type="Messstelle"/>
-        <line pattern="^Geschiebemessstelle[:\s].*$" type="Messstelle"/>
-        <line pattern="^Schwebstoffmessstelle[:\s].*$" type="Messstelle"/>
+        <line pattern="^Geschiebemessstelle[:\s].*$"
+              type="Geschiebemessstelle"/>
+        <line pattern="^Schwebstoffmessstelle[:\s].*$"
+              type="Schwebstoffmessstelle"/>
         <line pattern="^Pegel[:\s].*$" type="Pegel"/>
         <line pattern="^Staatsgrenze[:\s].*$" type="Staatsgrenze"/>
         <line pattern="^Staat[:\s].*$" type="Staat"/>
diff -r a779ee47aa79 -r 6ae0c5116d58 backend/src/main/java/org/dive4elements/river/model/FastAnnotations.java
--- a/backend/src/main/java/org/dive4elements/river/model/FastAnnotations.java	Mon Oct 13 17:22:52 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/model/FastAnnotations.java	Tue Oct 14 12:41:37 2014 +0200
@@ -15,6 +15,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+import java.util.regex.Pattern;
 
 import java.io.Serializable;
 
@@ -160,15 +161,15 @@
 
     public static class NameFilter implements Filter {
 
-        private String name;
+        private Pattern namePattern;
 
         public NameFilter(String name) {
-            this.name = name;
+            this.namePattern = Pattern.compile(name);
         }
 
         @Override
         public boolean accept(Annotation annotation) {
-            return annotation.getName().contains(name);
+            return namePattern.matcher(annotation.getName()).matches();
         }
     } // class NameFilter
 


More information about the Dive4Elements-commits mailing list