[Dive4elements-commits] [PATCH] New facet types and renaming for infoldings

Wald Commits scm-commit at wald.intevation.org
Thu Feb 28 13:09:57 CET 2013


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1362053366 -3600
# Node ID fc0cdcae8f07a82dd3eb9e281ae86c7429386ef4
# Parent  04eb62eae722ccda052c3daa4222dd8fb6c9d13e
New facet types and renaming for infoldings.

diff -r 04eb62eae722 -r fc0cdcae8f07 flys-artifacts/doc/conf/artifacts/winfo.xml
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Feb 28 12:58:25 2013 +0100
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Thu Feb 28 13:09:26 2013 +0100
@@ -402,6 +402,8 @@
                     <facets>
                         <facet name="discharge_longitudinal_section.w"/>
                         <facet name="discharge_longitudinal_section.q"/>
+                        <facet name="discharge_longitudinal_section.q.infolding"/>
+                        <facet name="discharge_longitudinal_section.q.cutting"/>
                         <facet name="discharge_longitudinal_section.c"/>
                         <facet name="discharge_longitudinal_section.manualpoints" description="Manuelle Punkte"/>
                         <facet name="other.wqkms.w"/>
diff -r 04eb62eae722 -r fc0cdcae8f07 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java	Thu Feb 28 12:58:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java	Thu Feb 28 13:09:26 2013 +0100
@@ -323,9 +323,7 @@
             int numProblemsBefore = numProblems();
             double [] qs = qf.findQs(kms, this);
 
-            // TODO: i18n
-            String name = "Umh\u00fcllende " + columns[i].getName();
-
+            String name = columns[i].getName();
             ConstantWQKms infolding = new ConstantWQKms(kms, qs, ws, name);
 
             if (numProblems() > numProblemsBefore) {
@@ -335,6 +333,19 @@
             infoldings.add(infolding);
         }
 
+        for (int i = 0; i < infoldings.size(); i++) {
+            String name = infoldings.get(i).getName();
+            // TODO: i18n
+            if (i == 0) {
+                infoldings.get(i).setName("untere Umh\u00fcllende " + name);
+            }
+            else if (i ==  infoldings.size() - 1) {
+                infoldings.get(i).setName("obere Umh\u00fcllende " + name);
+            }
+            else {
+                infoldings.get(i).setName("geschnitten " + name);
+            }
+        }
         return infoldings.toArray(new ConstantWQKms[infoldings.size()]);
     }
 
diff -r 04eb62eae722 -r fc0cdcae8f07 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Feb 28 12:58:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Thu Feb 28 13:09:26 2013 +0100
@@ -175,6 +175,8 @@
 
     String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w";
     String DISCHARGE_LONGITUDINAL_Q = "discharge_longitudinal_section.q";
+    String DISCHARGE_LONGITUDINAL_Q_INFOLD = "discharge_longitudinal_section.q.infolding";
+    String DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT = "discharge_longitudinal_section.q.cutting";
     String DISCHARGE_LONGITUDINAL_C = "discharge_longitudinal_section.c";
 
     String LONGITUDINAL_W = "longitudinal_section.w";
diff -r 04eb62eae722 -r fc0cdcae8f07 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java	Thu Feb 28 12:58:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java	Thu Feb 28 13:09:26 2013 +0100
@@ -1,7 +1,9 @@
 package de.intevation.flys.artifacts.states;
 
 import de.intevation.artifactdatabase.state.Facet;
+import de.intevation.artifactdatabase.state.FacetActivity;
 
+import de.intevation.artifacts.Artifact;
 import de.intevation.artifacts.CallContext;
 
 import de.intevation.flys.artifacts.ChartArtifact;
@@ -32,6 +34,26 @@
     private static Logger log =
         Logger.getLogger(DischargeLongitudinalSection.class);
 
+    static {
+        // Active/deactivate facets.
+        FacetActivity.Registry.getInstance().register(
+            "winfo",
+            new FacetActivity() {
+                @Override
+                public Boolean isInitialActive(
+                    Artifact artifact,
+                    Facet    facet,
+                    String   output
+                ) {
+                    String name = facet.getName();
+                    if (name.equals(DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT)) {
+                        return Boolean.FALSE;
+                    }
+                    return Boolean.TRUE;
+                }
+            });
+    }
+
     @Override
     public Object computeAdvance(
         FLYSArtifact artifact,
@@ -80,14 +102,24 @@
 
                 Facet s = new CrossSectionWaterLineFacet(i, nameW);
 
+                Facet q = new WaterlevelFacet(
+                    i, DISCHARGE_LONGITUDINAL_Q, nameQ);
                 facets.add(s);
                 facets.add(w);
+                facets.add(q);
             }
-
-            Facet q = new WaterlevelFacet(
-                i, DISCHARGE_LONGITUDINAL_Q, nameQ);
-
-            facets.add(q);
+            else {
+                Facet q;
+                if (nameQ.contains("geschnitten")) {
+                    q = new WaterlevelFacet(
+                        i, DISCHARGE_LONGITUDINAL_Q_INFOLD_CUT, nameQ);
+                }
+                else {
+                    q = new WaterlevelFacet(
+                        i, DISCHARGE_LONGITUDINAL_Q_INFOLD, nameQ);
+                }
+                facets.add(q);
+            }
 
             if (wqkms[i] instanceof WQCKms) {
                 // TODO DO i18n
diff -r 04eb62eae722 -r fc0cdcae8f07 flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Thu Feb 28 12:58:25 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java	Thu Feb 28 13:09:26 2013 +0100
@@ -54,7 +54,7 @@
 
         Facet facet = artifactFacet.getFacet();
 
-        if (name.equals(DISCHARGE_LONGITUDINAL_Q)) {
+        if (name.contains(DISCHARGE_LONGITUDINAL_Q)) {
             doQOut(
                 (WQKms) artifactFacet.getData(context),
                 artifactFacet,


More information about the Dive4elements-commits mailing list